diff options
| author | 2019-01-07 01:11:03 -0300 | |
|---|---|---|
| committer | 2019-01-07 16:20:39 -0300 | |
| commit | 179ee963db1c8310e533daa4457b02b7a8141539 (patch) | |
| tree | f511ec266467559a841926b9f7bf27c72b8f3e46 /src | |
| parent | gl_shader_cache: Use dirty flags for shaders (diff) | |
| download | yuzu-179ee963db1c8310e533daa4457b02b7a8141539.tar.gz yuzu-179ee963db1c8310e533daa4457b02b7a8141539.tar.xz yuzu-179ee963db1c8310e533daa4457b02b7a8141539.zip | |
gl_rasterizer_cache: Use dirty flags for color buffers
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 2 |
4 files changed, 24 insertions, 4 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 0ed7bc5d8..88483eab9 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -135,6 +135,15 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 135 | 135 | ||
| 136 | if (regs.reg_array[method_call.method] != method_call.argument) { | 136 | if (regs.reg_array[method_call.method] != method_call.argument) { |
| 137 | regs.reg_array[method_call.method] = method_call.argument; | 137 | regs.reg_array[method_call.method] = method_call.argument; |
| 138 | // Color buffers | ||
| 139 | constexpr u32 first_rt_reg = MAXWELL3D_REG_INDEX(rt); | ||
| 140 | constexpr u32 registers_per_rt = sizeof(regs.rt[0]) / sizeof(u32); | ||
| 141 | if (method_call.method >= first_rt_reg && | ||
| 142 | method_call.method < first_rt_reg + registers_per_rt * Regs::NumRenderTargets) { | ||
| 143 | const std::size_t rt_index = (method_call.method - first_rt_reg) / registers_per_rt; | ||
| 144 | dirty_flags.color_buffer |= 1u << static_cast<u32>(rt_index); | ||
| 145 | } | ||
| 146 | |||
| 138 | // Shader | 147 | // Shader |
| 139 | constexpr u32 shader_registers_count = | 148 | constexpr u32 shader_registers_count = |
| 140 | sizeof(regs.shader_config[0]) * Regs::MaxShaderProgram / sizeof(u32); | 149 | sizeof(regs.shader_config[0]) * Regs::MaxShaderProgram / sizeof(u32); |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index d50e5a126..8d0e18d80 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -1089,12 +1089,15 @@ public: | |||
| 1089 | MemoryManager& memory_manager; | 1089 | MemoryManager& memory_manager; |
| 1090 | 1090 | ||
| 1091 | struct DirtyFlags { | 1091 | struct DirtyFlags { |
| 1092 | u8 color_buffer = 0xFF; | ||
| 1093 | |||
| 1092 | bool shaders = true; | 1094 | bool shaders = true; |
| 1093 | 1095 | ||
| 1094 | bool vertex_attrib_format = true; | 1096 | bool vertex_attrib_format = true; |
| 1095 | u32 vertex_array = 0xFFFFFFFF; | 1097 | u32 vertex_array = 0xFFFFFFFF; |
| 1096 | 1098 | ||
| 1097 | void OnMemoryWrite() { | 1099 | void OnMemoryWrite() { |
| 1100 | color_buffer = 0xFF; | ||
| 1098 | shaders = true; | 1101 | shaders = true; |
| 1099 | vertex_array = 0xFFFFFFFF; | 1102 | vertex_array = 0xFFFFFFFF; |
| 1100 | } | 1103 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index d3dcb9a46..0059b336a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -933,21 +933,27 @@ Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) { | |||
| 933 | } | 933 | } |
| 934 | 934 | ||
| 935 | Surface RasterizerCacheOpenGL::GetColorBufferSurface(std::size_t index, bool preserve_contents) { | 935 | Surface RasterizerCacheOpenGL::GetColorBufferSurface(std::size_t index, bool preserve_contents) { |
| 936 | const auto& regs{Core::System::GetInstance().GPU().Maxwell3D().regs}; | 936 | auto& gpu{Core::System::GetInstance().GPU().Maxwell3D()}; |
| 937 | const auto& regs{gpu.regs}; | ||
| 938 | |||
| 939 | if ((gpu.dirty_flags.color_buffer & (1u << static_cast<u32>(index))) == 0) { | ||
| 940 | return last_color_buffers[index]; | ||
| 941 | } | ||
| 942 | gpu.dirty_flags.color_buffer &= ~(1u << static_cast<u32>(index)); | ||
| 937 | 943 | ||
| 938 | ASSERT(index < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets); | 944 | ASSERT(index < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets); |
| 939 | 945 | ||
| 940 | if (index >= regs.rt_control.count) { | 946 | if (index >= regs.rt_control.count) { |
| 941 | return {}; | 947 | return last_color_buffers[index] = {}; |
| 942 | } | 948 | } |
| 943 | 949 | ||
| 944 | if (regs.rt[index].Address() == 0 || regs.rt[index].format == Tegra::RenderTargetFormat::NONE) { | 950 | if (regs.rt[index].Address() == 0 || regs.rt[index].format == Tegra::RenderTargetFormat::NONE) { |
| 945 | return {}; | 951 | return last_color_buffers[index] = {}; |
| 946 | } | 952 | } |
| 947 | 953 | ||
| 948 | const SurfaceParams color_params{SurfaceParams::CreateForFramebuffer(index)}; | 954 | const SurfaceParams color_params{SurfaceParams::CreateForFramebuffer(index)}; |
| 949 | 955 | ||
| 950 | return GetSurface(color_params, preserve_contents); | 956 | return last_color_buffers[index] = GetSurface(color_params, preserve_contents); |
| 951 | } | 957 | } |
| 952 | 958 | ||
| 953 | void RasterizerCacheOpenGL::LoadSurface(const Surface& surface) { | 959 | void RasterizerCacheOpenGL::LoadSurface(const Surface& surface) { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 7223700c4..3bdd141a7 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -396,6 +396,8 @@ private: | |||
| 396 | /// Use a Pixel Buffer Object to download the previous texture and then upload it to the new one | 396 | /// Use a Pixel Buffer Object to download the previous texture and then upload it to the new one |
| 397 | /// using the new format. | 397 | /// using the new format. |
| 398 | OGLBuffer copy_pbo; | 398 | OGLBuffer copy_pbo; |
| 399 | |||
| 400 | std::array<Surface, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> last_color_buffers; | ||
| 399 | }; | 401 | }; |
| 400 | 402 | ||
| 401 | } // namespace OpenGL | 403 | } // namespace OpenGL |