diff options
| author | 2019-01-07 02:09:39 -0300 | |
|---|---|---|
| committer | 2019-01-07 16:22:28 -0300 | |
| commit | b683e41fca8f88bf21085ccb3eee1dd6a91e293e (patch) | |
| tree | 3b33a50ecc5725c4d42bf4adb2526352dc901629 /src | |
| parent | gl_rasterizer_cache: Use dirty flags for color buffers (diff) | |
| download | yuzu-b683e41fca8f88bf21085ccb3eee1dd6a91e293e.tar.gz yuzu-b683e41fca8f88bf21085ccb3eee1dd6a91e293e.tar.xz yuzu-b683e41fca8f88bf21085ccb3eee1dd6a91e293e.zip | |
gl_rasterizer_cache: Use dirty flags for the depth buffer
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 10 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 13 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 1 |
4 files changed, 23 insertions, 3 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 88483eab9..d64a5080b 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -144,6 +144,16 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 144 | dirty_flags.color_buffer |= 1u << static_cast<u32>(rt_index); | 144 | dirty_flags.color_buffer |= 1u << static_cast<u32>(rt_index); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | // Zeta buffer | ||
| 148 | constexpr u32 registers_in_zeta = sizeof(regs.zeta) / sizeof(u32); | ||
| 149 | if (method_call.method == MAXWELL3D_REG_INDEX(zeta_enable) || | ||
| 150 | method_call.method == MAXWELL3D_REG_INDEX(zeta_width) || | ||
| 151 | method_call.method == MAXWELL3D_REG_INDEX(zeta_height) || | ||
| 152 | (method_call.method >= MAXWELL3D_REG_INDEX(zeta) && | ||
| 153 | method_call.method < MAXWELL3D_REG_INDEX(zeta) + registers_in_zeta)) { | ||
| 154 | dirty_flags.zeta_buffer = true; | ||
| 155 | } | ||
| 156 | |||
| 147 | // Shader | 157 | // Shader |
| 148 | constexpr u32 shader_registers_count = | 158 | constexpr u32 shader_registers_count = |
| 149 | sizeof(regs.shader_config[0]) * Regs::MaxShaderProgram / sizeof(u32); | 159 | 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 8d0e18d80..1f76aa670 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -1090,6 +1090,7 @@ public: | |||
| 1090 | 1090 | ||
| 1091 | struct DirtyFlags { | 1091 | struct DirtyFlags { |
| 1092 | u8 color_buffer = 0xFF; | 1092 | u8 color_buffer = 0xFF; |
| 1093 | bool zeta_buffer = true; | ||
| 1093 | 1094 | ||
| 1094 | bool shaders = true; | 1095 | bool shaders = true; |
| 1095 | 1096 | ||
| @@ -1098,6 +1099,7 @@ public: | |||
| 1098 | 1099 | ||
| 1099 | void OnMemoryWrite() { | 1100 | void OnMemoryWrite() { |
| 1100 | color_buffer = 0xFF; | 1101 | color_buffer = 0xFF; |
| 1102 | zeta_buffer = true; | ||
| 1101 | shaders = true; | 1103 | shaders = true; |
| 1102 | vertex_array = 0xFFFFFFFF; | 1104 | vertex_array = 0xFFFFFFFF; |
| 1103 | } | 1105 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 0059b336a..d26a5f4de 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -919,9 +919,16 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextu | |||
| 919 | } | 919 | } |
| 920 | 920 | ||
| 921 | Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) { | 921 | Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) { |
| 922 | const auto& regs{Core::System::GetInstance().GPU().Maxwell3D().regs}; | 922 | auto& gpu{Core::System::GetInstance().GPU().Maxwell3D()}; |
| 923 | const auto& regs{gpu.regs}; | ||
| 924 | |||
| 925 | if (!gpu.dirty_flags.zeta_buffer) { | ||
| 926 | return last_depth_buffer; | ||
| 927 | } | ||
| 928 | gpu.dirty_flags.zeta_buffer = false; | ||
| 929 | |||
| 923 | if (!regs.zeta.Address() || !regs.zeta_enable) { | 930 | if (!regs.zeta.Address() || !regs.zeta_enable) { |
| 924 | return {}; | 931 | return last_depth_buffer = {}; |
| 925 | } | 932 | } |
| 926 | 933 | ||
| 927 | SurfaceParams depth_params{SurfaceParams::CreateForDepthBuffer( | 934 | SurfaceParams depth_params{SurfaceParams::CreateForDepthBuffer( |
| @@ -929,7 +936,7 @@ Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) { | |||
| 929 | regs.zeta.memory_layout.block_width, regs.zeta.memory_layout.block_height, | 936 | regs.zeta.memory_layout.block_width, regs.zeta.memory_layout.block_height, |
| 930 | regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)}; | 937 | regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)}; |
| 931 | 938 | ||
| 932 | return GetSurface(depth_params, preserve_contents); | 939 | return last_depth_buffer = GetSurface(depth_params, preserve_contents); |
| 933 | } | 940 | } |
| 934 | 941 | ||
| 935 | Surface RasterizerCacheOpenGL::GetColorBufferSurface(std::size_t index, bool preserve_contents) { | 942 | Surface RasterizerCacheOpenGL::GetColorBufferSurface(std::size_t index, bool preserve_contents) { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 3bdd141a7..37611c4fc 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -398,6 +398,7 @@ private: | |||
| 398 | OGLBuffer copy_pbo; | 398 | OGLBuffer copy_pbo; |
| 399 | 399 | ||
| 400 | std::array<Surface, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> last_color_buffers; | 400 | std::array<Surface, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> last_color_buffers; |
| 401 | Surface last_depth_buffer; | ||
| 401 | }; | 402 | }; |
| 402 | 403 | ||
| 403 | } // namespace OpenGL | 404 | } // namespace OpenGL |