diff options
| author | 2019-05-10 23:42:08 -0400 | |
|---|---|---|
| committer | 2019-06-20 21:36:12 -0300 | |
| commit | 1bbc9debfbcbd960874e2f877604506d174f613c (patch) | |
| tree | a5977d5db90882e0eb5240af45d42aad4a3dd266 /src | |
| parent | texture_cache: Implement GPU Dirty Flags (diff) | |
| download | yuzu-1bbc9debfbcbd960874e2f877604506d174f613c.tar.gz yuzu-1bbc9debfbcbd960874e2f877604506d174f613c.tar.xz yuzu-1bbc9debfbcbd960874e2f877604506d174f613c.zip | |
Remove Framebuffer reconfiguration and restrict rendertarget protection
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 5 | ||||
| -rw-r--r-- | src/video_core/texture_cache/surface_base.h | 15 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 30 |
4 files changed, 27 insertions, 39 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 3baf1522d..2d6fd154a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -461,15 +461,15 @@ void RasterizerOpenGL::LoadDiskResources(const std::atomic_bool& stop_loading, | |||
| 461 | } | 461 | } |
| 462 | 462 | ||
| 463 | std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers( | 463 | std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers( |
| 464 | OpenGLState& current_state, bool must_reconfigure, bool using_color_fb, bool using_depth_fb, | 464 | OpenGLState& current_state, bool using_color_fb, bool using_depth_fb, bool preserve_contents, |
| 465 | bool preserve_contents, std::optional<std::size_t> single_color_target) { | 465 | std::optional<std::size_t> single_color_target) { |
| 466 | MICROPROFILE_SCOPE(OpenGL_Framebuffer); | 466 | MICROPROFILE_SCOPE(OpenGL_Framebuffer); |
| 467 | auto& gpu = system.GPU().Maxwell3D(); | 467 | auto& gpu = system.GPU().Maxwell3D(); |
| 468 | const auto& regs = gpu.regs; | 468 | const auto& regs = gpu.regs; |
| 469 | 469 | ||
| 470 | const FramebufferConfigState fb_config_state{using_color_fb, using_depth_fb, preserve_contents, | 470 | const FramebufferConfigState fb_config_state{using_color_fb, using_depth_fb, preserve_contents, |
| 471 | single_color_target}; | 471 | single_color_target}; |
| 472 | if (!must_reconfigure && fb_config_state == current_framebuffer_config_state && | 472 | if (fb_config_state == current_framebuffer_config_state && |
| 473 | gpu.dirty_flags.color_buffer.none() && !gpu.dirty_flags.zeta_buffer) { | 473 | gpu.dirty_flags.color_buffer.none() && !gpu.dirty_flags.zeta_buffer) { |
| 474 | // Only skip if the previous ConfigureFramebuffers call was from the same kind (multiple or | 474 | // Only skip if the previous ConfigureFramebuffers call was from the same kind (multiple or |
| 475 | // single color targets). This is done because the guest registers may not change but the | 475 | // single color targets). This is done because the guest registers may not change but the |
| @@ -622,9 +622,8 @@ void RasterizerOpenGL::Clear() { | |||
| 622 | return; | 622 | return; |
| 623 | } | 623 | } |
| 624 | 624 | ||
| 625 | const auto [clear_depth, clear_stencil] = | 625 | const auto [clear_depth, clear_stencil] = ConfigureFramebuffers( |
| 626 | ConfigureFramebuffers(clear_state, false, use_color, use_depth || use_stencil, false, | 626 | clear_state, use_color, use_depth || use_stencil, false, regs.clear_buffers.RT.Value()); |
| 627 | regs.clear_buffers.RT.Value()); | ||
| 628 | if (regs.clear_flags.scissor) { | 627 | if (regs.clear_flags.scissor) { |
| 629 | SyncScissorTest(clear_state); | 628 | SyncScissorTest(clear_state); |
| 630 | } | 629 | } |
| @@ -659,7 +658,6 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 659 | auto& gpu = system.GPU().Maxwell3D(); | 658 | auto& gpu = system.GPU().Maxwell3D(); |
| 660 | const auto& regs = gpu.regs; | 659 | const auto& regs = gpu.regs; |
| 661 | 660 | ||
| 662 | ConfigureFramebuffers(state); | ||
| 663 | SyncColorMask(); | 661 | SyncColorMask(); |
| 664 | SyncFragmentColorClampState(); | 662 | SyncFragmentColorClampState(); |
| 665 | SyncMultiSampleState(); | 663 | SyncMultiSampleState(); |
| @@ -706,9 +704,7 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 706 | DrawParameters params = SetupDraw(); | 704 | DrawParameters params = SetupDraw(); |
| 707 | SetupShaders(params.primitive_mode); | 705 | SetupShaders(params.primitive_mode); |
| 708 | 706 | ||
| 709 | if (texture_cache.ConsumeReconfigurationFlag()) { | 707 | ConfigureFramebuffers(state); |
| 710 | ConfigureFramebuffers(state, true); | ||
| 711 | } | ||
| 712 | 708 | ||
| 713 | buffer_cache.Unmap(); | 709 | buffer_cache.Unmap(); |
| 714 | 710 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 970637efa..be5ac1b9f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -111,9 +111,8 @@ private: | |||
| 111 | * (requires using_depth_fb to be true) | 111 | * (requires using_depth_fb to be true) |
| 112 | */ | 112 | */ |
| 113 | std::pair<bool, bool> ConfigureFramebuffers( | 113 | std::pair<bool, bool> ConfigureFramebuffers( |
| 114 | OpenGLState& current_state, bool must_reconfigure = false, bool use_color_fb = true, | 114 | OpenGLState& current_state, bool use_color_fb = true, bool using_depth_fb = true, |
| 115 | bool using_depth_fb = true, bool preserve_contents = true, | 115 | bool preserve_contents = true, std::optional<std::size_t> single_color_target = {}); |
| 116 | std::optional<std::size_t> single_color_target = {}); | ||
| 117 | 116 | ||
| 118 | /// Configures the current constbuffers to use for the draw command. | 117 | /// Configures the current constbuffers to use for the draw command. |
| 119 | void SetupDrawConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, | 118 | void SetupDrawConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, |
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h index 095deb602..78db2d665 100644 --- a/src/video_core/texture_cache/surface_base.h +++ b/src/video_core/texture_cache/surface_base.h | |||
| @@ -218,12 +218,12 @@ public: | |||
| 218 | virtual void DownloadTexture(std::vector<u8>& staging_buffer) = 0; | 218 | virtual void DownloadTexture(std::vector<u8>& staging_buffer) = 0; |
| 219 | 219 | ||
| 220 | void MarkAsModified(const bool is_modified_, const u64 tick) { | 220 | void MarkAsModified(const bool is_modified_, const u64 tick) { |
| 221 | is_modified = is_modified_ || is_protected; | 221 | is_modified = is_modified_ || is_target; |
| 222 | modification_tick = tick; | 222 | modification_tick = tick; |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | void MarkAsProtected(const bool is_protected) { | 225 | void MarkAsRenderTarget(const bool is_target) { |
| 226 | this->is_protected = is_protected; | 226 | this->is_target = is_target; |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | void MarkAsPicked(const bool is_picked) { | 229 | void MarkAsPicked(const bool is_picked) { |
| @@ -235,7 +235,12 @@ public: | |||
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | bool IsProtected() const { | 237 | bool IsProtected() const { |
| 238 | return is_protected; | 238 | // Only 3D Slices are to be protected |
| 239 | return is_target && params.block_depth > 0; | ||
| 240 | } | ||
| 241 | |||
| 242 | bool IsRenderTarget() const { | ||
| 243 | return is_target; | ||
| 239 | } | 244 | } |
| 240 | 245 | ||
| 241 | bool IsRegistered() const { | 246 | bool IsRegistered() const { |
| @@ -307,7 +312,7 @@ private: | |||
| 307 | } | 312 | } |
| 308 | 313 | ||
| 309 | bool is_modified{}; | 314 | bool is_modified{}; |
| 310 | bool is_protected{}; | 315 | bool is_target{}; |
| 311 | bool is_registered{}; | 316 | bool is_registered{}; |
| 312 | bool is_picked{}; | 317 | bool is_picked{}; |
| 313 | u64 modification_tick{}; | 318 | u64 modification_tick{}; |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 8aa0d6515..4ac5668c8 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -105,11 +105,11 @@ public: | |||
| 105 | regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)}; | 105 | regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)}; |
| 106 | auto surface_view = GetSurface(gpu_addr, depth_params, preserve_contents); | 106 | auto surface_view = GetSurface(gpu_addr, depth_params, preserve_contents); |
| 107 | if (depth_buffer.target) | 107 | if (depth_buffer.target) |
| 108 | depth_buffer.target->MarkAsProtected(false); | 108 | depth_buffer.target->MarkAsRenderTarget(false); |
| 109 | depth_buffer.target = surface_view.first; | 109 | depth_buffer.target = surface_view.first; |
| 110 | depth_buffer.view = surface_view.second; | 110 | depth_buffer.view = surface_view.second; |
| 111 | if (depth_buffer.target) | 111 | if (depth_buffer.target) |
| 112 | depth_buffer.target->MarkAsProtected(true); | 112 | depth_buffer.target->MarkAsRenderTarget(true); |
| 113 | return surface_view.second; | 113 | return surface_view.second; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| @@ -138,11 +138,11 @@ public: | |||
| 138 | auto surface_view = GetSurface(gpu_addr, SurfaceParams::CreateForFramebuffer(system, index), | 138 | auto surface_view = GetSurface(gpu_addr, SurfaceParams::CreateForFramebuffer(system, index), |
| 139 | preserve_contents); | 139 | preserve_contents); |
| 140 | if (render_targets[index].target) | 140 | if (render_targets[index].target) |
| 141 | render_targets[index].target->MarkAsProtected(false); | 141 | render_targets[index].target->MarkAsRenderTarget(false); |
| 142 | render_targets[index].target = surface_view.first; | 142 | render_targets[index].target = surface_view.first; |
| 143 | render_targets[index].view = surface_view.second; | 143 | render_targets[index].view = surface_view.second; |
| 144 | if (render_targets[index].target) | 144 | if (render_targets[index].target) |
| 145 | render_targets[index].target->MarkAsProtected(true); | 145 | render_targets[index].target->MarkAsRenderTarget(true); |
| 146 | return surface_view.second; | 146 | return surface_view.second; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| @@ -158,7 +158,7 @@ public: | |||
| 158 | 158 | ||
| 159 | void SetEmptyDepthBuffer() { | 159 | void SetEmptyDepthBuffer() { |
| 160 | if (depth_buffer.target != nullptr) { | 160 | if (depth_buffer.target != nullptr) { |
| 161 | depth_buffer.target->MarkAsProtected(false); | 161 | depth_buffer.target->MarkAsRenderTarget(false); |
| 162 | depth_buffer.target = nullptr; | 162 | depth_buffer.target = nullptr; |
| 163 | depth_buffer.view = nullptr; | 163 | depth_buffer.view = nullptr; |
| 164 | } | 164 | } |
| @@ -166,7 +166,7 @@ public: | |||
| 166 | 166 | ||
| 167 | void SetEmptyColorBuffer(std::size_t index) { | 167 | void SetEmptyColorBuffer(std::size_t index) { |
| 168 | if (render_targets[index].target != nullptr) { | 168 | if (render_targets[index].target != nullptr) { |
| 169 | render_targets[index].target->MarkAsProtected(false); | 169 | render_targets[index].target->MarkAsRenderTarget(false); |
| 170 | render_targets[index].target = nullptr; | 170 | render_targets[index].target = nullptr; |
| 171 | render_targets[index].view = nullptr; | 171 | render_targets[index].view = nullptr; |
| 172 | } | 172 | } |
| @@ -200,12 +200,6 @@ public: | |||
| 200 | return ++ticks; | 200 | return ++ticks; |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | bool ConsumeReconfigurationFlag() { | ||
| 204 | const bool result = force_reconfiguration; | ||
| 205 | force_reconfiguration = false; | ||
| 206 | return result; | ||
| 207 | } | ||
| 208 | |||
| 209 | protected: | 203 | protected: |
| 210 | TextureCache(Core::System& system, VideoCore::RasterizerInterface& rasterizer) | 204 | TextureCache(Core::System& system, VideoCore::RasterizerInterface& rasterizer) |
| 211 | : system{system}, rasterizer{rasterizer} { | 205 | : system{system}, rasterizer{rasterizer} { |
| @@ -242,8 +236,8 @@ protected: | |||
| 242 | rasterizer.UpdatePagesCachedCount(*cpu_addr, size, 1); | 236 | rasterizer.UpdatePagesCachedCount(*cpu_addr, size, 1); |
| 243 | } | 237 | } |
| 244 | 238 | ||
| 245 | void Unregister(TSurface surface, const bool force_unregister = false) { | 239 | void Unregister(TSurface surface) { |
| 246 | if (surface->IsProtected() && !force_unregister) { | 240 | if (surface->IsProtected()) { |
| 247 | return; | 241 | return; |
| 248 | } | 242 | } |
| 249 | const GPUVAddr gpu_addr = surface->GetGpuAddr(); | 243 | const GPUVAddr gpu_addr = surface->GetGpuAddr(); |
| @@ -392,10 +386,8 @@ private: | |||
| 392 | std::min(src_params.height, dst_height), 1); | 386 | std::min(src_params.height, dst_height), 1); |
| 393 | ImageCopy(surface, new_surface, copy_params); | 387 | ImageCopy(surface, new_surface, copy_params); |
| 394 | } | 388 | } |
| 395 | force_reconfiguration = false; | ||
| 396 | for (auto surface : overlaps) { | 389 | for (auto surface : overlaps) { |
| 397 | force_reconfiguration |= surface->IsProtected(); | 390 | Unregister(surface); |
| 398 | Unregister(surface, true); | ||
| 399 | } | 391 | } |
| 400 | new_surface->MarkAsModified(modified, Tick()); | 392 | new_surface->MarkAsModified(modified, Tick()); |
| 401 | Register(new_surface); | 393 | Register(new_surface); |
| @@ -567,10 +559,6 @@ private: | |||
| 567 | 559 | ||
| 568 | u64 ticks{}; | 560 | u64 ticks{}; |
| 569 | 561 | ||
| 570 | // Sometimes Setup Textures can hit a surface that's on the render target, when this happens | ||
| 571 | // we force a reconfiguration of the frame buffer after setup. | ||
| 572 | bool force_reconfiguration; | ||
| 573 | |||
| 574 | // The internal Cache is different for the Texture Cache. It's based on buckets | 562 | // The internal Cache is different for the Texture Cache. It's based on buckets |
| 575 | // of 1MB. This fits better for the purpose of this cache as textures are normaly | 563 | // of 1MB. This fits better for the purpose of this cache as textures are normaly |
| 576 | // large in size. | 564 | // large in size. |