summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp24
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h9
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 71829fee0..5ea1c7746 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -486,9 +486,9 @@ void RasterizerOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {
486 cached_pages.add({pages_interval, delta}); 486 cached_pages.add({pages_interval, delta});
487} 487}
488 488
489void RasterizerOpenGL::ConfigureFramebuffers(OpenGLState& current_state, bool using_color_fb, 489std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers(
490 bool using_depth_fb, bool preserve_contents, 490 OpenGLState& current_state, bool using_color_fb, bool using_depth_fb, bool preserve_contents,
491 std::optional<std::size_t> single_color_target) { 491 std::optional<std::size_t> single_color_target) {
492 MICROPROFILE_SCOPE(OpenGL_Framebuffer); 492 MICROPROFILE_SCOPE(OpenGL_Framebuffer);
493 const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 493 const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
494 const auto& regs = gpu.regs; 494 const auto& regs = gpu.regs;
@@ -500,7 +500,7 @@ void RasterizerOpenGL::ConfigureFramebuffers(OpenGLState& current_state, bool us
500 // Only skip if the previous ConfigureFramebuffers call was from the same kind (multiple or 500 // Only skip if the previous ConfigureFramebuffers call was from the same kind (multiple or
501 // single color targets). This is done because the guest registers may not change but the 501 // single color targets). This is done because the guest registers may not change but the
502 // host framebuffer may contain different attachments 502 // host framebuffer may contain different attachments
503 return; 503 return current_depth_stencil_usage;
504 } 504 }
505 current_framebuffer_config_state = fb_config_state; 505 current_framebuffer_config_state = fb_config_state;
506 506
@@ -570,12 +570,14 @@ void RasterizerOpenGL::ConfigureFramebuffers(OpenGLState& current_state, bool us
570 depth_surface->MarkAsModified(true, res_cache); 570 depth_surface->MarkAsModified(true, res_cache);
571 571
572 fbkey.zeta = depth_surface->Texture().handle; 572 fbkey.zeta = depth_surface->Texture().handle;
573 fbkey.stencil_enable = regs.stencil_enable; 573 fbkey.stencil_enable = regs.stencil_enable &&
574 depth_surface->GetSurfaceParams().type == SurfaceType::DepthStencil;
574 } 575 }
575 576
576 SetupCachedFramebuffer(fbkey, current_state); 577 SetupCachedFramebuffer(fbkey, current_state);
577
578 SyncViewport(current_state); 578 SyncViewport(current_state);
579
580 return current_depth_stencil_usage = {static_cast<bool>(depth_surface), fbkey.stencil_enable};
579} 581}
580 582
581void RasterizerOpenGL::Clear() { 583void RasterizerOpenGL::Clear() {
@@ -643,8 +645,8 @@ void RasterizerOpenGL::Clear() {
643 return; 645 return;
644 } 646 }
645 647
646 ConfigureFramebuffers(clear_state, use_color, use_depth || use_stencil, false, 648 const auto [clear_depth, clear_stencil] = ConfigureFramebuffers(
647 regs.clear_buffers.RT.Value()); 649 clear_state, use_color, use_depth || use_stencil, false, regs.clear_buffers.RT.Value());
648 if (regs.clear_flags.scissor) { 650 if (regs.clear_flags.scissor) {
649 SyncScissorTest(clear_state); 651 SyncScissorTest(clear_state);
650 } 652 }
@@ -659,11 +661,11 @@ void RasterizerOpenGL::Clear() {
659 glClearBufferfv(GL_COLOR, regs.clear_buffers.RT, regs.clear_color); 661 glClearBufferfv(GL_COLOR, regs.clear_buffers.RT, regs.clear_color);
660 } 662 }
661 663
662 if (use_depth && use_stencil) { 664 if (clear_depth && clear_stencil) {
663 glClearBufferfi(GL_DEPTH_STENCIL, 0, regs.clear_depth, regs.clear_stencil); 665 glClearBufferfi(GL_DEPTH_STENCIL, 0, regs.clear_depth, regs.clear_stencil);
664 } else if (use_depth) { 666 } else if (clear_depth) {
665 glClearBufferfv(GL_DEPTH, 0, &regs.clear_depth); 667 glClearBufferfv(GL_DEPTH, 0, &regs.clear_depth);
666 } else if (use_stencil) { 668 } else if (clear_stencil) {
667 glClearBufferiv(GL_STENCIL, 0, &regs.clear_stencil); 669 glClearBufferiv(GL_STENCIL, 0, &regs.clear_stencil);
668 } 670 }
669} 671}
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 21c51f874..f6824c402 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -122,10 +122,12 @@ private:
122 * @param using_depth_fb If true, configure the depth/stencil framebuffer. 122 * @param using_depth_fb If true, configure the depth/stencil framebuffer.
123 * @param preserve_contents If true, tries to preserve data from a previously used framebuffer. 123 * @param preserve_contents If true, tries to preserve data from a previously used framebuffer.
124 * @param single_color_target Specifies if a single color buffer target should be used. 124 * @param single_color_target Specifies if a single color buffer target should be used.
125 * @returns If depth (first) or stencil (second) are being stored in the bound zeta texture
126 * (requires using_depth_fb to be true)
125 */ 127 */
126 void ConfigureFramebuffers(OpenGLState& current_state, bool use_color_fb = true, 128 std::pair<bool, bool> ConfigureFramebuffers(
127 bool using_depth_fb = true, bool preserve_contents = true, 129 OpenGLState& current_state, bool use_color_fb = true, bool using_depth_fb = true,
128 std::optional<std::size_t> single_color_target = {}); 130 bool preserve_contents = true, std::optional<std::size_t> single_color_target = {});
129 131
130 /** 132 /**
131 * Configures the current constbuffers to use for the draw command. 133 * Configures the current constbuffers to use for the draw command.
@@ -221,6 +223,7 @@ private:
221 223
222 std::map<FramebufferCacheKey, OGLFramebuffer> framebuffer_cache; 224 std::map<FramebufferCacheKey, OGLFramebuffer> framebuffer_cache;
223 FramebufferConfigState current_framebuffer_config_state; 225 FramebufferConfigState current_framebuffer_config_state;
226 std::pair<bool, bool> current_depth_stencil_usage{};
224 227
225 std::array<SamplerInfo, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> texture_samplers; 228 std::array<SamplerInfo, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> texture_samplers;
226 229