mirror of https://github.com/PCSX2/pcsx2.git
GS-hw: Combine BLEND_C_CLR2_AF and BLEND_C_CLR3_AS in one shader bit.
Free a shader bit.
This commit is contained in:
parent
3d40b23496
commit
ae14afd5f7
|
@ -769,17 +769,16 @@ void ps_blend(inout float4 Color, float As, float2 pos_xy)
|
||||||
|
|
||||||
Color.rgb = (float3)255.0f;
|
Color.rgb = (float3)255.0f;
|
||||||
}
|
}
|
||||||
else if (PS_CLR_HW == 2 || PS_CLR_HW == 3)
|
else if (PS_CLR_HW == 2)
|
||||||
{
|
{
|
||||||
// PS_CLR_HW 2 Af, PS_CLR_HW 3 As
|
|
||||||
// Cd*As or Cd*F
|
// Cd*As or Cd*F
|
||||||
|
|
||||||
float Alpha = PS_CLR_HW == 2 ? Af : As;
|
float Alpha = PS_BLEND_C == 2 ? Af : As;
|
||||||
|
|
||||||
Color.rgb = max((float3)0.0f, (Alpha - (float3)1.0f));
|
Color.rgb = max((float3)0.0f, (Alpha - (float3)1.0f));
|
||||||
Color.rgb *= (float3)255.0f;
|
Color.rgb *= (float3)255.0f;
|
||||||
}
|
}
|
||||||
else if (PS_CLR_HW == 4)
|
else if (PS_CLR_HW == 3)
|
||||||
{
|
{
|
||||||
// Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad
|
// Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad
|
||||||
// Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value
|
// Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value
|
||||||
|
|
|
@ -729,11 +729,10 @@ void ps_blend(inout vec4 Color, float As)
|
||||||
// Needed for Cd * (As/Ad/F + 1) blending modes
|
// Needed for Cd * (As/Ad/F + 1) blending modes
|
||||||
#if PS_CLR_HW == 1
|
#if PS_CLR_HW == 1
|
||||||
Color.rgb = vec3(255.0f);
|
Color.rgb = vec3(255.0f);
|
||||||
#elif PS_CLR_HW == 2 || PS_CLR_HW == 3
|
#elif PS_CLR_HW == 2
|
||||||
// PS_CLR_HW 2 Af, PS_CLR_HW 3 As
|
|
||||||
// Cd*As or Cd*F
|
// Cd*As or Cd*F
|
||||||
|
|
||||||
#if PS_CLR_HW == 2
|
#if PS_BLEND_C == 2
|
||||||
float Alpha = Af;
|
float Alpha = Af;
|
||||||
#else
|
#else
|
||||||
float Alpha = As;
|
float Alpha = As;
|
||||||
|
@ -741,7 +740,7 @@ void ps_blend(inout vec4 Color, float As)
|
||||||
|
|
||||||
Color.rgb = max(vec3(0.0f), (Alpha - vec3(1.0f)));
|
Color.rgb = max(vec3(0.0f), (Alpha - vec3(1.0f)));
|
||||||
Color.rgb *= vec3(255.0f);
|
Color.rgb *= vec3(255.0f);
|
||||||
#elif PS_CLR_HW == 4
|
#elif PS_CLR_HW == 3
|
||||||
// Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad
|
// Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad
|
||||||
// Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value
|
// Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value
|
||||||
|
|
||||||
|
|
|
@ -1067,11 +1067,10 @@ void ps_blend(inout vec4 Color, float As)
|
||||||
#if PS_CLR_HW == 1
|
#if PS_CLR_HW == 1
|
||||||
// Needed for Cd * (As/Ad/F + 1) blending modes
|
// Needed for Cd * (As/Ad/F + 1) blending modes
|
||||||
Color.rgb = vec3(255.0f);
|
Color.rgb = vec3(255.0f);
|
||||||
#elif PS_CLR_HW == 2 || PS_CLR_HW == 3
|
#elif PS_CLR_HW == 2
|
||||||
// PS_CLR_HW 2 Af, PS_CLR_HW 3 As
|
|
||||||
// Cd*As or Cd*F
|
// Cd*As or Cd*F
|
||||||
|
|
||||||
#if PS_CLR_HW == 2
|
#if PS_BLEND_C == 2
|
||||||
float Alpha = Af;
|
float Alpha = Af;
|
||||||
#else
|
#else
|
||||||
float Alpha = As;
|
float Alpha = As;
|
||||||
|
@ -1079,7 +1078,7 @@ void ps_blend(inout vec4 Color, float As)
|
||||||
|
|
||||||
Color.rgb = max(vec3(0.0f), (Alpha - vec3(1.0f)));
|
Color.rgb = max(vec3(0.0f), (Alpha - vec3(1.0f)));
|
||||||
Color.rgb *= vec3(255.0f);
|
Color.rgb *= vec3(255.0f);
|
||||||
#elif PS_CLR_HW == 4
|
#elif PS_CLR_HW == 3
|
||||||
// Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad
|
// Needed for Cs*Ad, Cs*Ad + Cd, Cd - Cs*Ad
|
||||||
// Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value
|
// Multiply Color.rgb by (255/128) to compensate for wrong Ad/255 value
|
||||||
|
|
||||||
|
|
|
@ -534,8 +534,8 @@ std::array<HWBlend, 3*3*3*3 + 1> GSDevice::m_blendMap =
|
||||||
{ BLEND_ACCU , OP_ADD , SRC1_ALPHA , CONST_ONE} , //?0201: (Cs - 0)*As + Cd ==> Cs*As + Cd
|
{ BLEND_ACCU , OP_ADD , SRC1_ALPHA , CONST_ONE} , //?0201: (Cs - 0)*As + Cd ==> Cs*As + Cd
|
||||||
{ BLEND_NO_REC , OP_ADD , SRC1_ALPHA , CONST_ZERO} , // 0202: (Cs - 0)*As + 0 ==> Cs*As
|
{ BLEND_NO_REC , OP_ADD , SRC1_ALPHA , CONST_ZERO} , // 0202: (Cs - 0)*As + 0 ==> Cs*As
|
||||||
{ BLEND_A_MAX , OP_ADD , CONST_ONE , CONST_ZERO} , //*0210: (Cs - 0)*Ad + Cs ==> Cs*(Ad + 1)
|
{ BLEND_A_MAX , OP_ADD , CONST_ONE , CONST_ZERO} , //*0210: (Cs - 0)*Ad + Cs ==> Cs*(Ad + 1)
|
||||||
{ BLEND_C_CLR4 , OP_ADD , DST_ALPHA , CONST_ONE} , // 0211: (Cs - 0)*Ad + Cd ==> Cs*Ad + Cd
|
{ BLEND_C_CLR3 , OP_ADD , DST_ALPHA , CONST_ONE} , // 0211: (Cs - 0)*Ad + Cd ==> Cs*Ad + Cd
|
||||||
{ BLEND_C_CLR4 , OP_ADD , DST_ALPHA , CONST_ZERO} , // 0212: (Cs - 0)*Ad + 0 ==> Cs*Ad
|
{ BLEND_C_CLR3 , OP_ADD , DST_ALPHA , CONST_ZERO} , // 0212: (Cs - 0)*Ad + 0 ==> Cs*Ad
|
||||||
{ BLEND_NO_REC | BLEND_A_MAX , OP_ADD , CONST_ONE , CONST_ZERO} , //*0220: (Cs - 0)*F + Cs ==> Cs*(F + 1)
|
{ BLEND_NO_REC | BLEND_A_MAX , OP_ADD , CONST_ONE , CONST_ZERO} , //*0220: (Cs - 0)*F + Cs ==> Cs*(F + 1)
|
||||||
{ BLEND_ACCU , OP_ADD , CONST_COLOR , CONST_ONE} , //?0221: (Cs - 0)*F + Cd ==> Cs*F + Cd
|
{ BLEND_ACCU , OP_ADD , CONST_COLOR , CONST_ONE} , //?0221: (Cs - 0)*F + Cd ==> Cs*F + Cd
|
||||||
{ BLEND_NO_REC , OP_ADD , CONST_COLOR , CONST_ZERO} , // 0222: (Cs - 0)*F + 0 ==> Cs*F
|
{ BLEND_NO_REC , OP_ADD , CONST_COLOR , CONST_ZERO} , // 0222: (Cs - 0)*F + 0 ==> Cs*F
|
||||||
|
@ -559,7 +559,7 @@ std::array<HWBlend, 3*3*3*3 + 1> GSDevice::m_blendMap =
|
||||||
{ BLEND_NO_REC , OP_ADD , CONST_ZERO , CONST_ZERO} , // 1122: (Cd - Cd)*F + 0 ==> 0
|
{ BLEND_NO_REC , OP_ADD , CONST_ZERO , CONST_ZERO} , // 1122: (Cd - Cd)*F + 0 ==> 0
|
||||||
{ 0 , OP_ADD , CONST_ONE , SRC1_ALPHA} , // 1200: (Cd - 0)*As + Cs ==> Cs + Cd*As
|
{ 0 , OP_ADD , CONST_ONE , SRC1_ALPHA} , // 1200: (Cd - 0)*As + Cs ==> Cs + Cd*As
|
||||||
{ BLEND_C_CLR1 , OP_ADD , DST_COLOR , SRC1_ALPHA} , //#1201: (Cd - 0)*As + Cd ==> Cd*(1 + As)
|
{ BLEND_C_CLR1 , OP_ADD , DST_COLOR , SRC1_ALPHA} , //#1201: (Cd - 0)*As + Cd ==> Cd*(1 + As)
|
||||||
{ BLEND_C_CLR3_AS , OP_ADD , DST_COLOR , SRC1_ALPHA} , // 1202: (Cd - 0)*As + 0 ==> Cd*As
|
{ BLEND_C_CLR2_AS , OP_ADD , DST_COLOR , SRC1_ALPHA} , // 1202: (Cd - 0)*As + 0 ==> Cd*As
|
||||||
{ 0 , OP_ADD , CONST_ONE , DST_ALPHA} , // 1210: (Cd - 0)*Ad + Cs ==> Cs + Cd*Ad
|
{ 0 , OP_ADD , CONST_ONE , DST_ALPHA} , // 1210: (Cd - 0)*Ad + Cs ==> Cs + Cd*Ad
|
||||||
{ BLEND_C_CLR1 , OP_ADD , DST_COLOR , DST_ALPHA} , //#1211: (Cd - 0)*Ad + Cd ==> Cd*(1 + Ad)
|
{ BLEND_C_CLR1 , OP_ADD , DST_COLOR , DST_ALPHA} , //#1211: (Cd - 0)*Ad + Cd ==> Cd*(1 + Ad)
|
||||||
{ 0 , OP_ADD , CONST_ZERO , DST_ALPHA} , // 1212: (Cd - 0)*Ad + 0 ==> Cd*Ad
|
{ 0 , OP_ADD , CONST_ZERO , DST_ALPHA} , // 1212: (Cd - 0)*Ad + 0 ==> Cd*Ad
|
||||||
|
@ -570,7 +570,7 @@ std::array<HWBlend, 3*3*3*3 + 1> GSDevice::m_blendMap =
|
||||||
{ BLEND_ACCU , OP_REV_SUBTRACT , SRC1_ALPHA , CONST_ONE} , //?2001: (0 - Cs)*As + Cd ==> Cd - Cs*As
|
{ BLEND_ACCU , OP_REV_SUBTRACT , SRC1_ALPHA , CONST_ONE} , //?2001: (0 - Cs)*As + Cd ==> Cd - Cs*As
|
||||||
{ BLEND_NO_REC , OP_REV_SUBTRACT , SRC1_ALPHA , CONST_ZERO} , // 2002: (0 - Cs)*As + 0 ==> 0 - Cs*As
|
{ BLEND_NO_REC , OP_REV_SUBTRACT , SRC1_ALPHA , CONST_ZERO} , // 2002: (0 - Cs)*As + 0 ==> 0 - Cs*As
|
||||||
{ 0 , OP_ADD , INV_DST_ALPHA , CONST_ZERO} , // 2010: (0 - Cs)*Ad + Cs ==> Cs*(1 - Ad)
|
{ 0 , OP_ADD , INV_DST_ALPHA , CONST_ZERO} , // 2010: (0 - Cs)*Ad + Cs ==> Cs*(1 - Ad)
|
||||||
{ BLEND_C_CLR4 , OP_REV_SUBTRACT , DST_ALPHA , CONST_ONE} , // 2011: (0 - Cs)*Ad + Cd ==> Cd - Cs*Ad
|
{ BLEND_C_CLR3 , OP_REV_SUBTRACT , DST_ALPHA , CONST_ONE} , // 2011: (0 - Cs)*Ad + Cd ==> Cd - Cs*Ad
|
||||||
{ 0 , OP_REV_SUBTRACT , DST_ALPHA , CONST_ZERO} , // 2012: (0 - Cs)*Ad + 0 ==> 0 - Cs*Ad
|
{ 0 , OP_REV_SUBTRACT , DST_ALPHA , CONST_ZERO} , // 2012: (0 - Cs)*Ad + 0 ==> 0 - Cs*Ad
|
||||||
{ BLEND_NO_REC , OP_ADD , INV_CONST_COLOR , CONST_ZERO} , // 2020: (0 - Cs)*F + Cs ==> Cs*(1 - F)
|
{ BLEND_NO_REC , OP_ADD , INV_CONST_COLOR , CONST_ZERO} , // 2020: (0 - Cs)*F + Cs ==> Cs*(1 - F)
|
||||||
{ BLEND_ACCU , OP_REV_SUBTRACT , CONST_COLOR , CONST_ONE} , //?2021: (0 - Cs)*F + Cd ==> Cd - Cs*F
|
{ BLEND_ACCU , OP_REV_SUBTRACT , CONST_COLOR , CONST_ONE} , //?2021: (0 - Cs)*F + Cd ==> Cd - Cs*F
|
||||||
|
|
|
@ -122,8 +122,8 @@ enum HWBlendFlags
|
||||||
BLEND_A_MAX = 0x80, // Impossible blending uses coeff bigger than 1
|
BLEND_A_MAX = 0x80, // Impossible blending uses coeff bigger than 1
|
||||||
BLEND_C_CLR1 = 0x100, // Clear color blending (use directly the destination color as blending factor)
|
BLEND_C_CLR1 = 0x100, // Clear color blending (use directly the destination color as blending factor)
|
||||||
BLEND_C_CLR2_AF = 0x200, // Clear color blending (use directly the destination color as blending factor)
|
BLEND_C_CLR2_AF = 0x200, // Clear color blending (use directly the destination color as blending factor)
|
||||||
BLEND_C_CLR3_AS = 0x400, // Clear color blending (use directly the destination color as blending factor)
|
BLEND_C_CLR2_AS = 0x400, // Clear color blending (use directly the destination color as blending factor)
|
||||||
BLEND_C_CLR4 = 0x800, // Multiply Cs by (255/128) to compensate for wrong Ad/255 value, should be Ad/128
|
BLEND_C_CLR3 = 0x800, // Multiply Cs by (255/128) to compensate for wrong Ad/255 value, should be Ad/128
|
||||||
BLEND_NO_REC = 0x1000, // Doesn't require sampling of the RT as a texture
|
BLEND_NO_REC = 0x1000, // Doesn't require sampling of the RT as a texture
|
||||||
BLEND_ACCU = 0x2000, // Allow to use a mix of SW and HW blending to keep the best of the 2 worlds
|
BLEND_ACCU = 0x2000, // Allow to use a mix of SW and HW blending to keep the best of the 2 worlds
|
||||||
};
|
};
|
||||||
|
|
|
@ -603,7 +603,7 @@ void GSRendererNew::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER)
|
||||||
// Blend can be done on hw. As and F cases should be accurate.
|
// Blend can be done on hw. As and F cases should be accurate.
|
||||||
// BLEND_C_CLR1 with Ad, BLEND_C_CLR4 Cs > 0.5f will require sw blend.
|
// BLEND_C_CLR1 with Ad, BLEND_C_CLR4 Cs > 0.5f will require sw blend.
|
||||||
// BLEND_C_CLR1 with As/F, BLEND_C_CLR2_AF, BLEND_C_CLR3_AS can be done in hw.
|
// BLEND_C_CLR1 with As/F, BLEND_C_CLR2_AF, BLEND_C_CLR3_AS can be done in hw.
|
||||||
const bool clr_blend = !!(blend_flag & (BLEND_C_CLR1 | BLEND_C_CLR2_AF | BLEND_C_CLR3_AS | BLEND_C_CLR4));
|
const bool clr_blend = !!(blend_flag & (BLEND_C_CLR1 | BLEND_C_CLR2_AF | BLEND_C_CLR2_AS | BLEND_C_CLR3));
|
||||||
// FBMASK already reads the fb so it is safe to enable sw blend when there is no overlap.
|
// FBMASK already reads the fb so it is safe to enable sw blend when there is no overlap.
|
||||||
const bool fbmask_no_overlap = m_conf.require_one_barrier && (m_prim_overlap == PRIM_OVERLAP_NO);
|
const bool fbmask_no_overlap = m_conf.require_one_barrier && (m_prim_overlap == PRIM_OVERLAP_NO);
|
||||||
|
|
||||||
|
@ -793,19 +793,20 @@ void GSRendererNew::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER)
|
||||||
{
|
{
|
||||||
m_conf.ps.clr_hw = 1;
|
m_conf.ps.clr_hw = 1;
|
||||||
}
|
}
|
||||||
else if (blend_flag & BLEND_C_CLR2_AF)
|
else if (blend_flag & (BLEND_C_CLR2_AF | BLEND_C_CLR2_AS))
|
||||||
{
|
{
|
||||||
|
if (ALPHA.C == 2)
|
||||||
|
{
|
||||||
|
m_conf.ps.blend_c = 2;
|
||||||
m_conf.cb_ps.TA_MaxDepth_Af.a = static_cast<float>(ALPHA.FIX) / 128.0f;
|
m_conf.cb_ps.TA_MaxDepth_Af.a = static_cast<float>(ALPHA.FIX) / 128.0f;
|
||||||
|
}
|
||||||
|
|
||||||
m_conf.ps.clr_hw = 2;
|
m_conf.ps.clr_hw = 2;
|
||||||
}
|
}
|
||||||
else if (blend_flag & BLEND_C_CLR3_AS)
|
else if (blend_flag & BLEND_C_CLR3)
|
||||||
{
|
{
|
||||||
m_conf.ps.clr_hw = 3;
|
m_conf.ps.clr_hw = 3;
|
||||||
}
|
}
|
||||||
else if (blend_flag & BLEND_C_CLR4)
|
|
||||||
{
|
|
||||||
m_conf.ps.clr_hw = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_conf.ps.dfmt == 1 && ALPHA.C == 1)
|
if (m_conf.ps.dfmt == 1 && ALPHA.C == 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue