diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 24 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 9 |
2 files changed, 19 insertions, 14 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index c6d63ed7d..e3163389f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -477,9 +477,9 @@ void RasterizerOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { | |||
| 477 | cached_pages.add({pages_interval, delta}); | 477 | cached_pages.add({pages_interval, delta}); |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | void RasterizerOpenGL::ConfigureFramebuffers(OpenGLState& current_state, bool using_color_fb, | 480 | std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers( |
| 481 | bool using_depth_fb, bool preserve_contents, | 481 | OpenGLState& current_state, bool using_color_fb, bool using_depth_fb, bool preserve_contents, |
| 482 | std::optional<std::size_t> single_color_target) { | 482 | std::optional<std::size_t> single_color_target) { |
| 483 | MICROPROFILE_SCOPE(OpenGL_Framebuffer); | 483 | MICROPROFILE_SCOPE(OpenGL_Framebuffer); |
| 484 | const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); | 484 | const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); |
| 485 | const auto& regs = gpu.regs; | 485 | const auto& regs = gpu.regs; |
| @@ -491,7 +491,7 @@ void RasterizerOpenGL::ConfigureFramebuffers(OpenGLState& current_state, bool us | |||
| 491 | // Only skip if the previous ConfigureFramebuffers call was from the same kind (multiple or | 491 | // Only skip if the previous ConfigureFramebuffers call was from the same kind (multiple or |
| 492 | // single color targets). This is done because the guest registers may not change but the | 492 | // single color targets). This is done because the guest registers may not change but the |
| 493 | // host framebuffer may contain different attachments | 493 | // host framebuffer may contain different attachments |
| 494 | return; | 494 | return current_depth_stencil_usage; |
| 495 | } | 495 | } |
| 496 | current_framebuffer_config_state = fb_config_state; | 496 | current_framebuffer_config_state = fb_config_state; |
| 497 | 497 | ||
| @@ -561,12 +561,14 @@ void RasterizerOpenGL::ConfigureFramebuffers(OpenGLState& current_state, bool us | |||
| 561 | depth_surface->MarkAsModified(true, res_cache); | 561 | depth_surface->MarkAsModified(true, res_cache); |
| 562 | 562 | ||
| 563 | fbkey.zeta = depth_surface->Texture().handle; | 563 | fbkey.zeta = depth_surface->Texture().handle; |
| 564 | fbkey.stencil_enable = regs.stencil_enable; | 564 | fbkey.stencil_enable = regs.stencil_enable && |
| 565 | depth_surface->GetSurfaceParams().type == SurfaceType::DepthStencil; | ||
| 565 | } | 566 | } |
| 566 | 567 | ||
| 567 | SetupCachedFramebuffer(fbkey, current_state); | 568 | SetupCachedFramebuffer(fbkey, current_state); |
| 568 | |||
| 569 | SyncViewport(current_state); | 569 | SyncViewport(current_state); |
| 570 | |||
| 571 | return current_depth_stencil_usage = {static_cast<bool>(depth_surface), fbkey.stencil_enable}; | ||
| 570 | } | 572 | } |
| 571 | 573 | ||
| 572 | void RasterizerOpenGL::Clear() { | 574 | void RasterizerOpenGL::Clear() { |
| @@ -634,8 +636,8 @@ void RasterizerOpenGL::Clear() { | |||
| 634 | return; | 636 | return; |
| 635 | } | 637 | } |
| 636 | 638 | ||
| 637 | ConfigureFramebuffers(clear_state, use_color, use_depth || use_stencil, false, | 639 | const auto [clear_depth, clear_stencil] = ConfigureFramebuffers( |
| 638 | regs.clear_buffers.RT.Value()); | 640 | clear_state, use_color, use_depth || use_stencil, false, regs.clear_buffers.RT.Value()); |
| 639 | if (regs.clear_flags.scissor) { | 641 | if (regs.clear_flags.scissor) { |
| 640 | SyncScissorTest(clear_state); | 642 | SyncScissorTest(clear_state); |
| 641 | } | 643 | } |
| @@ -650,11 +652,11 @@ void RasterizerOpenGL::Clear() { | |||
| 650 | glClearBufferfv(GL_COLOR, regs.clear_buffers.RT, regs.clear_color); | 652 | glClearBufferfv(GL_COLOR, regs.clear_buffers.RT, regs.clear_color); |
| 651 | } | 653 | } |
| 652 | 654 | ||
| 653 | if (use_depth && use_stencil) { | 655 | if (clear_depth && clear_stencil) { |
| 654 | glClearBufferfi(GL_DEPTH_STENCIL, 0, regs.clear_depth, regs.clear_stencil); | 656 | glClearBufferfi(GL_DEPTH_STENCIL, 0, regs.clear_depth, regs.clear_stencil); |
| 655 | } else if (use_depth) { | 657 | } else if (clear_depth) { |
| 656 | glClearBufferfv(GL_DEPTH, 0, ®s.clear_depth); | 658 | glClearBufferfv(GL_DEPTH, 0, ®s.clear_depth); |
| 657 | } else if (use_stencil) { | 659 | } else if (clear_stencil) { |
| 658 | glClearBufferiv(GL_STENCIL, 0, ®s.clear_stencil); | 660 | glClearBufferiv(GL_STENCIL, 0, ®s.clear_stencil); |
| 659 | } | 661 | } |
| 660 | } | 662 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 22a0796b6..7f2bf0f8b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -121,10 +121,12 @@ private: | |||
| 121 | * @param using_depth_fb If true, configure the depth/stencil framebuffer. | 121 | * @param using_depth_fb If true, configure the depth/stencil framebuffer. |
| 122 | * @param preserve_contents If true, tries to preserve data from a previously used framebuffer. | 122 | * @param preserve_contents If true, tries to preserve data from a previously used framebuffer. |
| 123 | * @param single_color_target Specifies if a single color buffer target should be used. | 123 | * @param single_color_target Specifies if a single color buffer target should be used. |
| 124 | * @returns If depth (first) or stencil (second) are being stored in the bound zeta texture | ||
| 125 | * (requires using_depth_fb to be true) | ||
| 124 | */ | 126 | */ |
| 125 | void ConfigureFramebuffers(OpenGLState& current_state, bool use_color_fb = true, | 127 | std::pair<bool, bool> ConfigureFramebuffers( |
| 126 | bool using_depth_fb = true, bool preserve_contents = true, | 128 | OpenGLState& current_state, bool use_color_fb = true, bool using_depth_fb = true, |
| 127 | std::optional<std::size_t> single_color_target = {}); | 129 | bool preserve_contents = true, std::optional<std::size_t> single_color_target = {}); |
| 128 | 130 | ||
| 129 | /// Configures the current constbuffers to use for the draw command. | 131 | /// Configures the current constbuffers to use for the draw command. |
| 130 | void SetupConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, const Shader& shader, | 132 | void SetupConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, const Shader& shader, |
| @@ -213,6 +215,7 @@ private: | |||
| 213 | 215 | ||
| 214 | std::map<FramebufferCacheKey, OGLFramebuffer> framebuffer_cache; | 216 | std::map<FramebufferCacheKey, OGLFramebuffer> framebuffer_cache; |
| 215 | FramebufferConfigState current_framebuffer_config_state; | 217 | FramebufferConfigState current_framebuffer_config_state; |
| 218 | std::pair<bool, bool> current_depth_stencil_usage{}; | ||
| 216 | 219 | ||
| 217 | std::array<SamplerInfo, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> texture_samplers; | 220 | std::array<SamplerInfo, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> texture_samplers; |
| 218 | 221 | ||