GS/HW: Ger rid of clr_blend1_2 condition.

Prefer sw blend instead when Alpha > 1 on Cd*(Alpha + 1) contitions when there's no overlap
on basic blend.
This commit is contained in:
lightningterror 2024-04-24 21:04:24 +02:00
parent 8a7d5bc417
commit 4c24d96966
1 changed files with 5 additions and 21 deletions

View File

@ -4075,14 +4075,6 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, bool& DAT
const bool free_blend = blend_non_recursive // Free sw blending, doesn't require barriers or reading fb
|| accumulation_blend; // Mix of hw/sw blending
// Blend can be done on hw. As and F cases should be accurate.
// BLEND_HW1 with Ad, BLEND_HW3 might require sw blend.
// BLEND_HW1 with As/F and BLEND_HW2 can be done in hw.
bool clr_blend1_2 = (blend_flag & (BLEND_HW1 | BLEND_HW2)) && (m_conf.ps.blend_c != 1) // As or Af cases only.
&& !(m_draw_env->PABE.PABE && GetAlphaMinMax().min < 128) // No PABE as it will require sw blending.
&& (COLCLAMP.CLAMP) // Let's add a colclamp check too, hw blend will clamp to 0-1.
&& !prefer_sw_blend; // Don't run if sw blend is preferred.
// Warning no break on purpose
// Note: the [[fallthrough]] attribute tell compilers not to complain about not having breaks.
bool sw_blending = false;
@ -4091,17 +4083,17 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, bool& DAT
const bool blend_requires_barrier = (blend_flag & BLEND_A_MAX) // Impossible blending
// Sw blend, either full barrier or one barrier with no overlap.
|| prefer_sw_blend
// Blend can be done in a single draw, and we already need a barrier
// On fbfetch, one barrier is like full barrier
// Blend can be done in a single draw, and we already need a barrier.
// On fbfetch, one barrier is like full barrier.
|| (one_barrier && (no_prim_overlap || features.framebuffer_fetch))
|| ((alpha_c2_high_one || alpha_c0_high_max_one) && no_prim_overlap)
// Blending with alpha > 1 will be wrong, except BLEND_HW2.
|| (!(blend_flag & BLEND_HW2) && (alpha_c2_high_one || alpha_c0_high_max_one) && no_prim_overlap)
// Ad blends are completely wrong without sw blend (Ad is 0.5 not 1 for 128). We can spare a barrier for it.
|| (blend_ad && no_prim_overlap);
switch (GSConfig.AccurateBlendingUnit)
{
case AccBlendLevel::Maximum:
clr_blend1_2 = false;
sw_blending |= true;
[[fallthrough]];
case AccBlendLevel::Full:
@ -4122,8 +4114,6 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, bool& DAT
accumulation_blend &= !prefer_sw_blend;
// Enable sw blending for barriers.
sw_blending |= blend_requires_barrier;
// Try to do hw blend for clr2 case.
sw_blending &= !clr_blend1_2;
// Enable sw blending for free blending.
sw_blending |= free_blend;
// Do not run BLEND MIX if sw blending is already present, it's less accurate.
@ -4143,11 +4133,7 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, bool& DAT
{
case AccBlendLevel::Maximum:
// Enable sw blend when prims don't overlap.
if (no_prim_overlap)
{
clr_blend1_2 = false;
sw_blending |= true;
}
sw_blending |= no_prim_overlap;
[[fallthrough]];
case AccBlendLevel::Full:
// Enable sw blend on cases where Alpha > 128 when prims don't overlap.
@ -4167,8 +4153,6 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, bool& DAT
accumulation_blend &= !prefer_sw_blend;
// Enable sw blending for reading fb.
sw_blending |= prefer_sw_blend;
// Try to do hw blend for clr2 case.
sw_blending &= !clr_blend1_2;
// Enable sw blending for free blending.
sw_blending |= free_blend;
// Do not run BLEND MIX if sw blending is already present, it's less accurate.