diff --git a/bin/resources/shaders/dx11/tfx.fx b/bin/resources/shaders/dx11/tfx.fx index 921cbf0b49..3638c8f4a4 100644 --- a/bin/resources/shaders/dx11/tfx.fx +++ b/bin/resources/shaders/dx11/tfx.fx @@ -30,7 +30,7 @@ #define PS_ATST 1 #define PS_FOG 0 #define PS_IIP 0 -#define PS_CLR_HW 0 +#define PS_BLEND_HW 0 #define PS_FBA 0 #define PS_FBMASK 0 #define PS_LTF 1 @@ -798,9 +798,9 @@ void ps_blend(inout float4 Color, inout float4 As_rgba, float2 pos_xy) float3 D = (PS_BLEND_D == 0) ? Cs : ((PS_BLEND_D == 1) ? Cd : (float3)0.0f); // As/Af clamp alpha for Blend mix - // We shouldn't clamp blend mix with clr1 as we want alpha higher + // We shouldn't clamp blend mix with blend hw 1 as we want alpha higher float C_clamped = C; - if (PS_BLEND_MIX > 0 && PS_CLR_HW != 1) + if (PS_BLEND_MIX > 0 && PS_BLEND_HW != 1) C_clamped = min(C_clamped, 1.0f); if (PS_BLEND_A == PS_BLEND_B) @@ -819,7 +819,7 @@ void ps_blend(inout float4 Color, inout float4 As_rgba, float2 pos_xy) else Color.rgb = trunc(((A - B) * C) + D); - if (PS_CLR_HW == 1) + if (PS_BLEND_HW == 1) { // As or Af As_rgba.rgb = (float3)C; @@ -831,7 +831,7 @@ void ps_blend(inout float4 Color, inout float4 As_rgba, float2 pos_xy) float3 alpha_compensate = max((float3)1.0f, Color.rgb / (float3)255.0f); As_rgba.rgb -= alpha_compensate; } - else if (PS_CLR_HW == 2 || PS_CLR_HW == 4) + else if (PS_BLEND_HW == 2 || PS_BLEND_HW == 4) { // Compensate slightly for Cd*(As + 1) - Cs*As. // The initial factor we chose is 1 (0.00392) @@ -841,7 +841,7 @@ void ps_blend(inout float4 Color, inout float4 As_rgba, float2 pos_xy) float color_compensate = 1.0f * (C + 1.0f); Color.rgb -= (float3)color_compensate; } - else if (PS_CLR_HW == 3 || PS_CLR_HW == 5) + else if (PS_BLEND_HW == 3 || PS_BLEND_HW == 5) { // As, Ad or Af clamped. As_rgba.rgb = (float3)C_clamped; @@ -854,13 +854,13 @@ void ps_blend(inout float4 Color, inout float4 As_rgba, float2 pos_xy) } else { - if (PS_CLR_HW == 1 || PS_CLR_HW == 5) + if (PS_BLEND_HW == 1 || PS_BLEND_HW == 5) { // Needed for Cd * (As/Ad/F + 1) blending modes Color.rgb = (float3)255.0f; } - else if (PS_CLR_HW == 2 || PS_CLR_HW == 4) + else if (PS_BLEND_HW == 2 || PS_BLEND_HW == 4) { // Cd*As,Cd*Ad or Cd*F @@ -869,7 +869,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_CLR_HW == 3) + else if (PS_BLEND_HW == 3) { // 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. @@ -943,7 +943,7 @@ PS_OUTPUT ps_main(PS_INPUT input) } float4 alpha_blend; - if (PS_BLEND_C == 1 && PS_CLR_HW > 3) + if (PS_BLEND_C == 1 && PS_BLEND_HW > 3) { float4 RT = trunc(RtTexture.Load(int3(input.p.xy, 0)) * 255.0f + 0.1f); alpha_blend = (float4)(RT.a / 128.0f); diff --git a/bin/resources/shaders/opengl/tfx_fs.glsl b/bin/resources/shaders/opengl/tfx_fs.glsl index f444622d4f..037d655284 100644 --- a/bin/resources/shaders/opengl/tfx_fs.glsl +++ b/bin/resources/shaders/opengl/tfx_fs.glsl @@ -21,7 +21,7 @@ #define SW_BLEND (PS_BLEND_A || PS_BLEND_B || PS_BLEND_D) #define SW_BLEND_NEEDS_RT (SW_BLEND && (PS_BLEND_A == 1 || PS_BLEND_B == 1 || PS_BLEND_C == 1 || PS_BLEND_D == 1)) -#define SW_AD_TO_HW (PS_BLEND_C == 1 && PS_CLR_HW > 3) +#define SW_AD_TO_HW (PS_BLEND_C == 1 && PS_BLEND_HW > 3) #define PS_PRIMID_INIT (PS_DATE == 1 || PS_DATE == 2) #define NEEDS_RT_EARLY (PS_TEX_IS_FB == 1 || PS_DATE >= 5) #define NEEDS_RT (NEEDS_RT_EARLY || (!PS_PRIMID_INIT && (PS_FBMASK || SW_BLEND_NEEDS_RT || SW_AD_TO_HW))) @@ -753,9 +753,9 @@ float As = As_rgba.a; #endif // As/Af clamp alpha for Blend mix - // We shouldn't clamp blend mix with clr1 as we want alpha higher + // We shouldn't clamp blend mix with blend hw 1 as we want alpha higher float C_clamped = C; -#if PS_BLEND_MIX > 0 && PS_CLR_HW != 1 +#if PS_BLEND_MIX > 0 && PS_BLEND_HW != 1 C_clamped = min(C_clamped, 1.0f); #endif @@ -776,7 +776,7 @@ float As = As_rgba.a; Color.rgb = trunc((A - B) * C + D); #endif -#if PS_CLR_HW == 1 +#if PS_BLEND_HW == 1 // As or Af As_rgba.rgb = vec3(C); // Subtract 1 for alpha to compensate for the changed equation, @@ -786,7 +786,7 @@ float As = As_rgba.a; // changed alpha should only be done for hw blend. vec3 alpha_compensate = max(vec3(1.0f), Color.rgb / vec3(255.0f)); As_rgba.rgb -= alpha_compensate; -#elif PS_CLR_HW == 2 || PS_CLR_HW == 4 +#elif PS_BLEND_HW == 2 || PS_BLEND_HW == 4 // Compensate slightly for Cd*(As + 1) - Cs*As. // The initial factor we chose is 1 (0.00392) // as that is the minimum color Cd can be, @@ -794,7 +794,7 @@ float As = As_rgba.a; // blended value it can be. float color_compensate = 1.0f * (C + 1.0f); Color.rgb -= vec3(color_compensate); -#elif PS_CLR_HW == 3 || PS_CLR_HW == 5 +#elif PS_BLEND_HW == 3 || PS_BLEND_HW == 5 // As, Ad or Af clamped. As_rgba.rgb = vec3(C_clamped); // Cs*(Alpha + 1) might overflow, if it does then adjust alpha value @@ -806,9 +806,9 @@ float As = As_rgba.a; #else // Needed for Cd * (As/Ad/F + 1) blending modes -#if PS_CLR_HW == 1 || PS_CLR_HW == 5 +#if PS_BLEND_HW == 1 || PS_BLEND_HW == 5 Color.rgb = vec3(255.0f); -#elif PS_CLR_HW == 2 || PS_CLR_HW == 4 +#elif PS_BLEND_HW == 2 || PS_BLEND_HW == 4 // Cd*As,Cd*Ad or Cd*F #if PS_BLEND_C == 2 @@ -819,7 +819,7 @@ float As = As_rgba.a; Color.rgb = max(vec3(0.0f), (Alpha - vec3(1.0f))); Color.rgb *= vec3(255.0f); -#elif PS_CLR_HW == 3 +#elif PS_BLEND_HW == 3 // 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 97fd201fea..f43d2af8f6 100644 --- a/bin/resources/shaders/vulkan/tfx.glsl +++ b/bin/resources/shaders/vulkan/tfx.glsl @@ -320,7 +320,7 @@ void main() #define PS_TCC 1 #define PS_ATST 1 #define PS_FOG 0 -#define PS_CLR_HW 0 +#define PS_BLEND_HW 0 #define PS_FBA 0 #define PS_FBMASK 0 #define PS_LTF 1 @@ -1072,9 +1072,9 @@ void ps_blend(inout vec4 Color, inout vec4 As_rgba) #endif // As/Af clamp alpha for Blend mix - // We shouldn't clamp blend mix with clr1 as we want alpha higher + // We shouldn't clamp blend mix with blend hw 1 as we want alpha higher float C_clamped = C; - #if PS_BLEND_MIX > 0 && PS_CLR_HW != 1 + #if PS_BLEND_MIX > 0 && PS_BLEND_HW != 1 C_clamped = min(C_clamped, 1.0f); #endif @@ -1095,7 +1095,7 @@ void ps_blend(inout vec4 Color, inout vec4 As_rgba) Color.rgb = trunc((A - B) * C + D); #endif - #if PS_CLR_HW == 1 + #if PS_BLEND_HW == 1 // As or Af As_rgba.rgb = vec3(C); // Subtract 1 for alpha to compensate for the changed equation, @@ -1105,7 +1105,7 @@ void ps_blend(inout vec4 Color, inout vec4 As_rgba) // changed alpha should only be done for hw blend. vec3 alpha_compensate = max(vec3(1.0f), Color.rgb / vec3(255.0f)); As_rgba.rgb -= alpha_compensate; - #elif PS_CLR_HW == 2 || PS_CLR_HW == 4 + #elif PS_BLEND_HW == 2 || PS_BLEND_HW == 4 // Compensate slightly for Cd*(As + 1) - Cs*As. // The initial factor we chose is 1 (0.00392) // as that is the minimum color Cd can be, @@ -1113,7 +1113,7 @@ void ps_blend(inout vec4 Color, inout vec4 As_rgba) // blended value it can be. float color_compensate = 1.0f * (C + 1.0f); Color.rgb -= vec3(color_compensate); - #elif PS_CLR_HW == 3 || PS_CLR_HW == 5 + #elif PS_BLEND_HW == 3 || PS_BLEND_HW == 5 // As, Ad or Af clamped. As_rgba.rgb = vec3(C_clamped); // Cs*(Alpha + 1) might overflow, if it does then adjust alpha value @@ -1124,10 +1124,10 @@ void ps_blend(inout vec4 Color, inout vec4 As_rgba) #endif #else - #if PS_CLR_HW == 1 || PS_CLR_HW == 5 + #if PS_BLEND_HW == 1 || PS_BLEND_HW == 5 // Needed for Cd * (As/Ad/F + 1) blending modes Color.rgb = vec3(255.0f); - #elif PS_CLR_HW == 2 || PS_CLR_HW == 4 + #elif PS_BLEND_HW == 2 || PS_BLEND_HW == 4 // Cd*As,Cd*Ad or Cd*F #if PS_BLEND_C == 2 @@ -1138,7 +1138,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_CLR_HW == 3 + #elif PS_BLEND_HW == 3 // 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 @@ -1231,7 +1231,7 @@ void main() C.a = 128.0f; #endif -#if (PS_BLEND_C == 1 && PS_CLR_HW > 3) +#if (PS_BLEND_C == 1 && PS_BLEND_HW > 3) vec4 RT = trunc(subpassLoad(RtSampler) * 255.0f + 0.1f); vec4 alpha_blend = vec4(RT.a / 128.0f); #else diff --git a/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp b/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp index 4104c0af7b..5909c3732e 100644 --- a/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp @@ -152,7 +152,7 @@ void GSDevice11::SetupPS(const PSSelector& sel, const GSHWDrawConfig::PSConstant sm.AddMacro("PS_ATST", sel.atst); sm.AddMacro("PS_FOG", sel.fog); sm.AddMacro("PS_IIP", sel.iip); - sm.AddMacro("PS_CLR_HW", sel.clr_hw); + sm.AddMacro("PS_BLEND_HW", sel.clr_hw); sm.AddMacro("PS_FBA", sel.fba); sm.AddMacro("PS_FBMASK", sel.fbmask); sm.AddMacro("PS_LTF", sel.ltf); diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index d963bfd097..7741ef9893 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -1613,7 +1613,7 @@ const ID3DBlob* GSDevice12::GetTFXPixelShader(const GSHWDrawConfig::PSSelector& sm.AddMacro("PS_ATST", sel.atst); sm.AddMacro("PS_FOG", sel.fog); sm.AddMacro("PS_IIP", sel.iip); - sm.AddMacro("PS_CLR_HW", sel.clr_hw); + sm.AddMacro("PS_BLEND_HW", sel.clr_hw); sm.AddMacro("PS_FBA", sel.fba); sm.AddMacro("PS_FBMASK", sel.fbmask); sm.AddMacro("PS_LTF", sel.ltf); diff --git a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm index 66de891962..9f675277c5 100644 --- a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm +++ b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm @@ -1387,7 +1387,7 @@ void GSDeviceMTL::MRESetHWPipelineState(GSHWDrawConfig::VSSelector vssel, GSHWDr setFnConstantI(m_fn_constants, pssel.blend_b, GSMTLConstantIndex_PS_BLEND_B); setFnConstantI(m_fn_constants, pssel.blend_c, GSMTLConstantIndex_PS_BLEND_C); setFnConstantI(m_fn_constants, pssel.blend_d, GSMTLConstantIndex_PS_BLEND_D); - setFnConstantI(m_fn_constants, pssel.clr_hw, GSMTLConstantIndex_PS_CLR_HW); + setFnConstantI(m_fn_constants, pssel.clr_hw, GSMTLConstantIndex_PS_BLEND_HW); setFnConstantB(m_fn_constants, pssel.hdr, GSMTLConstantIndex_PS_HDR); setFnConstantB(m_fn_constants, pssel.colclip, GSMTLConstantIndex_PS_COLCLIP); setFnConstantI(m_fn_constants, pssel.blend_mix, GSMTLConstantIndex_PS_BLEND_MIX); diff --git a/pcsx2/GS/Renderers/Metal/GSMTLSharedHeader.h b/pcsx2/GS/Renderers/Metal/GSMTLSharedHeader.h index 119015cb8f..bbcc489417 100644 --- a/pcsx2/GS/Renderers/Metal/GSMTLSharedHeader.h +++ b/pcsx2/GS/Renderers/Metal/GSMTLSharedHeader.h @@ -182,7 +182,7 @@ enum GSMTLFnConstants GSMTLConstantIndex_PS_BLEND_B, GSMTLConstantIndex_PS_BLEND_C, GSMTLConstantIndex_PS_BLEND_D, - GSMTLConstantIndex_PS_CLR_HW, + GSMTLConstantIndex_PS_BLEND_HW, GSMTLConstantIndex_PS_HDR, GSMTLConstantIndex_PS_COLCLIP, GSMTLConstantIndex_PS_BLEND_MIX, diff --git a/pcsx2/GS/Renderers/Metal/tfx.metal b/pcsx2/GS/Renderers/Metal/tfx.metal index 52ceb535d1..2db669af25 100644 --- a/pcsx2/GS/Renderers/Metal/tfx.metal +++ b/pcsx2/GS/Renderers/Metal/tfx.metal @@ -49,7 +49,7 @@ constant uint PS_BLEND_A [[function_constant(GSMTLConstantIndex_PS_BL constant uint PS_BLEND_B [[function_constant(GSMTLConstantIndex_PS_BLEND_B)]]; constant uint PS_BLEND_C [[function_constant(GSMTLConstantIndex_PS_BLEND_C)]]; constant uint PS_BLEND_D [[function_constant(GSMTLConstantIndex_PS_BLEND_D)]]; -constant uint PS_CLR_HW [[function_constant(GSMTLConstantIndex_PS_CLR_HW)]]; +constant uint PS_BLEND_HW [[function_constant(GSMTLConstantIndex_PS_BLEND_HW)]]; constant bool PS_HDR [[function_constant(GSMTLConstantIndex_PS_HDR)]]; constant bool PS_COLCLIP [[function_constant(GSMTLConstantIndex_PS_COLCLIP)]]; constant uint PS_BLEND_MIX [[function_constant(GSMTLConstantIndex_PS_BLEND_MIX)]]; @@ -95,7 +95,7 @@ constant bool PS_TEX_IS_COLOR = !PS_TEX_IS_DEPTH; constant bool PS_HAS_PALETTE = PS_PAL_FMT != 0 || (PS_CHANNEL >= 1 && PS_CHANNEL <= 5); constant bool NOT_IIP = !IIP; constant bool SW_BLEND = (PS_BLEND_A != PS_BLEND_B) || PS_BLEND_D; -constant bool SW_AD_TO_HW = PS_BLEND_C == 1 && PS_CLR_HW > 3; +constant bool SW_AD_TO_HW = PS_BLEND_C == 1 && PS_BLEND_HW > 3; constant bool NEEDS_RT_FOR_BLEND = (((PS_BLEND_A != PS_BLEND_B) && (PS_BLEND_A == 1 || PS_BLEND_B == 1 || PS_BLEND_C == 1)) || PS_BLEND_D == 1 || SW_AD_TO_HW); constant bool NEEDS_RT_EARLY = PS_TEX_IS_FB || PS_DATE >= 5; constant bool NEEDS_RT = NEEDS_RT_EARLY || (!PS_PRIM_CHECKING_INIT && (PS_FBMASK || NEEDS_RT_FOR_BLEND)); @@ -858,9 +858,9 @@ struct PSMain float3 D = pick(PS_BLEND_D, Cs, Cd, float3(0.f)); // As/Af clamp alpha for Blend mix - // We shouldn't clamp blend mix with clr1 as we want alpha higher + // We shouldn't clamp blend mix with blend hw 1 as we want alpha higher float C_clamped = C; - if (PS_BLEND_MIX > 0 && PS_CLR_HW != 1) + if (PS_BLEND_MIX > 0 && PS_BLEND_HW != 1) C_clamped = min(C_clamped, 1.f); if (PS_BLEND_A == PS_BLEND_B) @@ -879,7 +879,7 @@ struct PSMain else Color.rgb = trunc((A - B) * C + D); - if (PS_CLR_HW == 1) + if (PS_BLEND_HW == 1) { // As or Af As_rgba.rgb = float3(C); @@ -891,7 +891,7 @@ struct PSMain float3 alpha_compensate = max(float3(1.f), Color.rgb / float3(255.f)); As_rgba.rgb -= alpha_compensate; } - else if (PS_CLR_HW == 2 || PS_CLR_HW == 4) + else if (PS_BLEND_HW == 2 || PS_BLEND_HW == 4) { // Compensate slightly for Cd*(As + 1) - Cs*As. // The initial factor we chose is 1 (0.00392) @@ -901,7 +901,7 @@ struct PSMain float color_compensate = 1.f * (C + 1.f); Color.rgb -= float3(color_compensate); } - else if (PS_CLR_HW == 3 || PS_CLR_HW == 5) + else if (PS_BLEND_HW == 3 || PS_BLEND_HW == 5) { // As, Ad or Af clamped. As_rgba.rgb = float3(C_clamped); @@ -915,16 +915,16 @@ struct PSMain else { // Needed for Cd * (As/Ad/F + 1) blending mdoes - if (PS_CLR_HW == 1 || PS_CLR_HW == 5) + if (PS_BLEND_HW == 1 || PS_BLEND_HW == 5) { Color.rgb = 255.f; } - else if (PS_CLR_HW == 2 || PS_CLR_HW == 4) + else if (PS_BLEND_HW == 2 || PS_BLEND_HW == 4) { float Alpha = PS_BLEND_C == 2 ? cb.alpha_fix : As; Color.rgb = saturate(Alpha - 1.f) * 255.f; } - else if (PS_CLR_HW == 3) + else if (PS_BLEND_HW == 3) { // 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/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index 32cc6fabdf..6153877b6f 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -1044,7 +1044,7 @@ std::string GSDeviceOGL::GetPSSource(const PSSelector& sel) + fmt::format("#define PS_TCC {}\n", sel.tcc) + fmt::format("#define PS_ATST {}\n", sel.atst) + fmt::format("#define PS_FOG {}\n", sel.fog) - + fmt::format("#define PS_CLR_HW {}\n", sel.clr_hw) + + fmt::format("#define PS_BLEND_HW {}\n", sel.clr_hw) + fmt::format("#define PS_FBA {}\n", sel.fba) + fmt::format("#define PS_LTF {}\n", sel.ltf) + fmt::format("#define PS_AUTOMATIC_LOD {}\n", sel.automatic_lod) diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index 8e1a82cf4f..9a2435e77e 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -2076,7 +2076,7 @@ VkShaderModule GSDeviceVK::GetTFXFragmentShader(const GSHWDrawConfig::PSSelector AddMacro(ss, "PS_TCC", sel.tcc); AddMacro(ss, "PS_ATST", sel.atst); AddMacro(ss, "PS_FOG", sel.fog); - AddMacro(ss, "PS_CLR_HW", sel.clr_hw); + AddMacro(ss, "PS_BLEND_HW", sel.clr_hw); AddMacro(ss, "PS_FBA", sel.fba); AddMacro(ss, "PS_LTF", sel.ltf); AddMacro(ss, "PS_AUTOMATIC_LOD", sel.automatic_lod);