From 9b4e94c4aeec9ef8f3006d4288efbcfd877e2ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 28 Aug 2022 23:14:30 +0200 Subject: [PATCH] Depal: Set scissor tightly around processed area. --- GPU/Common/TextureCacheCommon.cpp | 37 +++++++++++++------------------ 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index e6ce09ae62..0963618c06 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -1956,12 +1956,26 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer gstate_c.Dirty(DIRTY_UVSCALEOFFSET); } + // If min is not < max, then we don't have values (wasn't set during decode.) + const KnownVertexBounds &bounds = gstate_c.vertBounds; + float u1 = 0.0f; + float v1 = 0.0f; + float u2 = depalWidth; + float v2 = framebuffer->renderHeight; + if (bounds.minV < bounds.maxV) { + u1 = (bounds.minU + gstate_c.curTextureXOffset) * framebuffer->renderScaleFactor; + v1 = (bounds.minV + gstate_c.curTextureYOffset) * framebuffer->renderScaleFactor; + u2 = (bounds.maxU + gstate_c.curTextureXOffset) * framebuffer->renderScaleFactor; + v2 = (bounds.maxV + gstate_c.curTextureYOffset) * framebuffer->renderScaleFactor; + // We need to reapply the texture next time since we cropped UV. + gstate_c.Dirty(DIRTY_TEXTURE_PARAMS); + } + Draw::Framebuffer *depalFBO = framebufferManager_->GetTempFBO(TempFBO::DEPAL, depalWidth, framebuffer->renderHeight); draw_->BindTexture(0, nullptr); draw_->BindTexture(1, nullptr); draw_->BindFramebufferAsRenderTarget(depalFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Depal"); - - draw_->SetScissorRect(0, 0, (int)depalWidth, (int)framebuffer->renderHeight); + draw_->SetScissorRect(u1, v1, u2 - u1, v2 - v1); Draw::Viewport vp{ 0.0f, 0.0f, (float)depalWidth, (float)framebuffer->renderHeight, 0.0f, 1.0f }; draw_->SetViewports(1, &vp); @@ -1972,25 +1986,6 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer draw_->BindSamplerStates(0, 1, &nearest); draw_->BindSamplerStates(1, 1, &clutSampler); - // If min is not < max, then we don't have values (wasn't set during decode.) - const KnownVertexBounds &bounds = gstate_c.vertBounds; - float u1 = 0.0f; - float v1 = 0.0f; - float u2 = depalWidth; - float v2 = framebuffer->renderHeight; - if (bounds.minV < bounds.maxV) { - u1 = bounds.minU + gstate_c.curTextureXOffset; - v1 = bounds.minV + gstate_c.curTextureYOffset; - u2 = bounds.maxU + gstate_c.curTextureXOffset; - v2 = bounds.maxV + gstate_c.curTextureYOffset; - // We need to reapply the texture next time since we cropped UV. - gstate_c.Dirty(DIRTY_TEXTURE_PARAMS); - } - u1 *= framebuffer->renderScaleFactor; - v1 *= framebuffer->renderScaleFactor; - u2 *= framebuffer->renderScaleFactor; - v2 *= framebuffer->renderScaleFactor; - draw2D_->Blit(textureShader, u1, v1, u2, v2, u1, v1, u2, v2, framebuffer->renderWidth, framebuffer->renderHeight, depalWidth, framebuffer->renderHeight, false, framebuffer->renderScaleFactor); gstate_c.curTextureWidth = texWidth;