From 58628b8dd357bd3961e7977ebdbe96ac4b6ceeda Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Sat, 24 Feb 2024 22:26:55 +0100 Subject: [PATCH] GS/HW: Make sure we don't multiply Cs if Ad is corrected. Another potential to avoid copies. --- bin/resources/shaders/dx11/tfx.fx | 2 +- bin/resources/shaders/opengl/tfx_fs.glsl | 2 +- bin/resources/shaders/vulkan/tfx.glsl | 2 +- pcsx2/GS/Renderers/Metal/tfx.metal | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/resources/shaders/dx11/tfx.fx b/bin/resources/shaders/dx11/tfx.fx index ef4c0450c0..6713fa28f9 100644 --- a/bin/resources/shaders/dx11/tfx.fx +++ b/bin/resources/shaders/dx11/tfx.fx @@ -930,7 +930,7 @@ void ps_blend(inout float4 Color, inout float4 As_rgba, float2 pos_xy) Color.rgb = max((float3)0.0f, (Alpha - (float3)1.0f)); Color.rgb *= (float3)255.0f; } - else if (PS_BLEND_HW == 3) + else if (PS_BLEND_HW == 3 && PS_RTA_CORRECTION == 0) { // Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad // Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value when rgb are below 128. diff --git a/bin/resources/shaders/opengl/tfx_fs.glsl b/bin/resources/shaders/opengl/tfx_fs.glsl index 5cafc59050..0dcae0d976 100644 --- a/bin/resources/shaders/opengl/tfx_fs.glsl +++ b/bin/resources/shaders/opengl/tfx_fs.glsl @@ -910,7 +910,7 @@ float As = As_rgba.a; Color.rgb = max(vec3(0.0f), (Alpha - vec3(1.0f))); Color.rgb *= vec3(255.0f); -#elif PS_BLEND_HW == 3 +#elif PS_BLEND_HW == 3 && PS_RTA_CORRECTION == 0 // Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad // Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value when rgb are below 128. // When any color channel is higher than 128 then adjust the compensation automatically diff --git a/bin/resources/shaders/vulkan/tfx.glsl b/bin/resources/shaders/vulkan/tfx.glsl index 1619e70d6c..fcf75efcf0 100644 --- a/bin/resources/shaders/vulkan/tfx.glsl +++ b/bin/resources/shaders/vulkan/tfx.glsl @@ -1163,7 +1163,7 @@ void ps_blend(inout vec4 Color, inout vec4 As_rgba) Color.rgb = max(vec3(0.0f), (Alpha - vec3(1.0f))); Color.rgb *= vec3(255.0f); - #elif PS_BLEND_HW == 3 + #elif PS_BLEND_HW == 3 && PS_RTA_CORRECTION == 0 // Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad // Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value when rgb are below 128. // When any color channel is higher than 128 then adjust the compensation automatically diff --git a/pcsx2/GS/Renderers/Metal/tfx.metal b/pcsx2/GS/Renderers/Metal/tfx.metal index cdd66e79aa..e13c2824d2 100644 --- a/pcsx2/GS/Renderers/Metal/tfx.metal +++ b/pcsx2/GS/Renderers/Metal/tfx.metal @@ -991,7 +991,7 @@ struct PSMain float Alpha = PS_BLEND_C == 2 ? cb.alpha_fix : As; Color.rgb = saturate(Alpha - 1.f) * 255.f; } - else if (PS_BLEND_HW == 3) + else if (PS_BLEND_HW == 3 && PS_RTA_CORRECTION == 0) { // Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad // Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value when rgb are below 128.