From 93c9eb196f4444495f50220c3e6b89d2f0b582db Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Fri, 22 Oct 2021 22:59:30 -0400 Subject: [PATCH] gl_rasterizer: Fix ScissorTest and Clear when scaling --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index bb24a0656..4df8a684a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -184,6 +184,9 @@ void RasterizerOpenGL::Clear() { SyncRasterizeEnable(); SyncStencilTestState(); + std::scoped_lock lock{texture_cache.mutex}; + texture_cache.UpdateRenderTargets(true); + state_tracker.BindFramebuffer(texture_cache.GetFramebuffer()->Handle()); if (regs.clear_flags.scissor) { SyncScissorTest(); } else { @@ -192,10 +195,6 @@ void RasterizerOpenGL::Clear() { } UNIMPLEMENTED_IF(regs.clear_flags.viewport); - std::scoped_lock lock{texture_cache.mutex}; - texture_cache.UpdateRenderTargets(true); - state_tracker.BindFramebuffer(texture_cache.GetFramebuffer()->Handle()); - if (use_color) { glClearBufferfv(GL_COLOR, regs.clear_buffers.RT, regs.clear_color); } @@ -925,12 +924,9 @@ void RasterizerOpenGL::SyncScissorTest() { const auto& regs = maxwell3d.regs; const auto& resolution = Settings::values.resolution_info; - const auto scale_up = [resolution](u32 value) -> u32 { - if (value == 0) { - return 0U; - } - const u32 converted_value = (value * resolution.up_scale) >> resolution.down_shift; - return std::max(converted_value, 1U); + const bool is_rescaling{texture_cache.IsRescaling()}; + const auto scale_up = [resolution, is_rescaling](u32 value) { + return is_rescaling ? resolution.ScaleUp(value) : value; }; for (std::size_t index = 0; index < Maxwell::NumViewports; ++index) { if (!force && !flags[Dirty::Scissor0 + index]) {