mirror of https://github.com/PCSX2/pcsx2.git
GS-hw: Support Ad masked alpha on blend mix 1 and 2 clr cases.
This commit is contained in:
parent
248e94dc4c
commit
59aba9f757
|
@ -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)
|
||||
else if (PS_CLR_HW == 2 || PS_CLR_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)
|
||||
else if (PS_CLR_HW == 3 || PS_CLR_HW == 5)
|
||||
{
|
||||
// As, Ad or Af clamped.
|
||||
As_rgba.rgb = (float3)C_clamped;
|
||||
|
|
|
@ -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
|
||||
#elif PS_CLR_HW == 2 || PS_CLR_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
|
||||
#elif PS_CLR_HW == 3 || PS_CLR_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
|
||||
|
|
|
@ -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
|
||||
#elif PS_CLR_HW == 2 || PS_CLR_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
|
||||
#elif PS_CLR_HW == 3 || PS_CLR_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
|
||||
|
|
|
@ -3134,7 +3134,7 @@ void GSRendererHW::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER, bool&
|
|||
{
|
||||
// Compensate slightly for Cd*(As + 1) - Cs*As.
|
||||
// Try to compensate a bit with subtracting 1 (0.00392) * (Alpha + 1) from Cs.
|
||||
m_conf.ps.clr_hw = 2;
|
||||
m_conf.ps.clr_hw = blend_ad_alpha_masked ? 4 : 2;
|
||||
}
|
||||
|
||||
m_conf.ps.blend_a = 0;
|
||||
|
@ -3146,7 +3146,7 @@ void GSRendererHW::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER, bool&
|
|||
// Allow to compensate when Cs*(Alpha + 1) overflows, to compensate we change
|
||||
// the alpha output value for Cd*Alpha.
|
||||
m_conf.blend = {true, GSDevice::CONST_ONE, GSDevice::SRC1_COLOR, blend.op, false, 0};
|
||||
m_conf.ps.clr_hw = 3;
|
||||
m_conf.ps.clr_hw = blend_ad_alpha_masked ? 5 : 3;
|
||||
m_conf.ps.no_color1 = false;
|
||||
|
||||
m_conf.ps.blend_a = 0;
|
||||
|
@ -3165,6 +3165,8 @@ void GSRendererHW::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER, bool&
|
|||
{
|
||||
m_conf.require_one_barrier |= true;
|
||||
// Swap Ad with As for hw blend
|
||||
// Check if blend mix 1 or 2 already enabled clr
|
||||
if (m_conf.ps.clr_hw == 0)
|
||||
m_conf.ps.clr_hw = 6;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
else if (PS_CLR_HW == 2 || PS_CLR_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)
|
||||
else if (PS_CLR_HW == 3 || PS_CLR_HW == 5)
|
||||
{
|
||||
// As, Ad or Af clamped.
|
||||
As_rgba.rgb = float3(C_clamped);
|
||||
|
|
Loading…
Reference in New Issue