From 6ccb55d6f7f7124558638d6fa144107c3efbc17d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 12 Dec 2022 13:12:18 +1000 Subject: [PATCH] GS: Remove additional copy in FXAA/ShadeBoost --- pcsx2/GS/Renderers/Common/GSDevice.cpp | 34 +++++++++----------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/pcsx2/GS/Renderers/Common/GSDevice.cpp b/pcsx2/GS/Renderers/Common/GSDevice.cpp index 491ef692d1..d43c0927b1 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.cpp +++ b/pcsx2/GS/Renderers/Common/GSDevice.cpp @@ -387,38 +387,25 @@ void GSDevice::Interlace(const GSVector2i& ds, int field, int mode, float yoffse default: m_current = m_merge; } - - if ((GSConfig.FXAA || GSConfig.ShadeBoost) && m_current != m_merge) - { - const GSVector2i s = m_current->GetSize(); - ResizeTexture(&m_merge, GSTexture::Type::RenderTarget, s.x, s.y, false); - StretchRect(m_current, GSVector4(0, 0, 1, 1), m_merge, GSVector4(0, 0, ds.x, ds.y), ShaderConvert::COPY, false); - m_current = m_merge; - } } void GSDevice::FXAA() { - const GSVector2i s = m_current->GetSize(); - - if (ResizeTexture(&m_target_tmp, GSTexture::Type::RenderTarget, s.x, s.y, false)) + // Combining FXAA+ShadeBoost can't share the same target. + GSTexture*& dTex = (m_current == m_target_tmp) ? m_merge : m_target_tmp; + if (ResizeTexture(&dTex, GSTexture::Type::RenderTarget, m_current->GetWidth(), m_current->GetHeight(), false, true)) { - const GSVector4 sRect(0, 0, 1, 1); - const GSVector4 dRect(0, 0, s.x, s.y); - - StretchRect(m_current, sRect, m_target_tmp, dRect, ShaderConvert::TRANSPARENCY_FILTER, false); - DoFXAA(m_target_tmp, m_current); + InvalidateRenderTarget(dTex); + DoFXAA(m_current, dTex); + m_current = dTex; } } void GSDevice::ShadeBoost() { - const GSVector2i s = m_current->GetSize(); - - if (ResizeTexture(&m_target_tmp, GSTexture::Type::RenderTarget, s.x, s.y, false)) + if (ResizeTexture(&m_target_tmp, GSTexture::Type::RenderTarget, m_current->GetWidth(), m_current->GetHeight(), false, true)) { - const GSVector4 sRect(0, 0, 1, 1); - const GSVector4 dRect(0, 0, s.x, s.y); + InvalidateRenderTarget(m_target_tmp); // predivide to avoid the divide (multiply) in the shader const float params[4] = { @@ -427,8 +414,9 @@ void GSDevice::ShadeBoost() static_cast(GSConfig.ShadeBoost_Saturation) * (1.0f / 50.0f), }; - StretchRect(m_current, sRect, m_target_tmp, dRect, ShaderConvert::COPY, false); - DoShadeBoost(m_target_tmp, m_current, params); + DoShadeBoost(m_current, m_target_tmp, params); + + m_current = m_target_tmp; } }