gsdx-d3d11: Always enable sw colclip for BLEND_NO_BAR.

- Free blending and it's faster than standard hdr algo when Blending
Accuracy is disabled.

- Add assert when disabling hw blending, hw blending should only be disabled
on free/no barrier blending. D3D11 lacks other types of blending.

- Use const to get rid of some warnings.
This commit is contained in:
lightningterror 2020-02-23 22:24:32 +01:00
parent 95e91b8f44
commit 3f467cae67
1 changed files with 23 additions and 19 deletions

View File

@ -496,7 +496,7 @@ void GSRendererDX11::EmulateChannelShuffle(GSTexture** rt, const GSTextureCache:
void GSRendererDX11::EmulateBlending()
{
// Partial port of OGL SW blending. Currently only works for accumulation blend.
// Partial port of OGL SW blending. Currently only works for accumulation and no barrier blend.
const GIFRegALPHA& ALPHA = m_context->ALPHA;
bool sw_blending = false;
@ -526,43 +526,45 @@ void GSRendererDX11::EmulateBlending()
}
}
uint8 blend_index = uint8(((ALPHA.A * 3 + ALPHA.B) * 3 + ALPHA.C) * 3 + ALPHA.D);
int blend_flag = m_dev->GetBlendFlags(blend_index);
// SW free blend.
bool free_blend = !!(blend_flag & (BLEND_NO_BAR|BLEND_ACCU));
const uint8 blend_index = uint8(((ALPHA.A * 3 + ALPHA.B) * 3 + ALPHA.C) * 3 + ALPHA.D);
const int blend_flag = m_dev->GetBlendFlags(blend_index);
// Do the multiplication in shader for blending accumulation: Cs*As + Cd or Cs*Af + Cd
bool accumulation_blend = !!(blend_flag & BLEND_ACCU);
const bool accumulation_blend = !!(blend_flag & BLEND_ACCU);
// Blending doesn't require barrier
const bool no_barrier_blend = !!(blend_flag & BLEND_NO_BAR);
switch (m_sw_blending)
{
case ACC_BLEND_HIGH_D3D11:
case ACC_BLEND_MEDIUM_D3D11:
case ACC_BLEND_BASIC_D3D11:
sw_blending |= free_blend;
sw_blending |= accumulation_blend || no_barrier_blend;
// fall through
default: break;
}
// Color clip
if (m_env.COLCLAMP.CLAMP == 0)
{
if (accumulation_blend)
// fprintf(stderr, "%d: COLCLIP Info (Blending: %d/%d/%d/%d)\n", s_n, ALPHA.A, ALPHA.B, ALPHA.C, ALPHA.D);
if (no_barrier_blend)
{
// fprintf(stderr, "%d: COLCLIP HDR mode with accumulation blend\n", s_n);
// The fastest algo that requires a single pass
// fprintf(stderr, "%d: COLCLIP Free mode ENABLED\n", s_n);
m_ps_sel.colclip = 1;
sw_blending = true;
}
else if (accumulation_blend)
{
// fprintf(stderr, "%d: COLCLIP Fast HDR mode ENABLED\n", s_n);
sw_blending = true;
m_ps_sel.hdr = 1;
}
else if (sw_blending)
{
// So far only BLEND_NO_BAR should hit this path, it's faster than standard HDR algo.
// Note: Isolate the code to BLEND_NO_BAR if other blending conditions are added.
// fprintf(stderr, "%d: COLCLIP SW ENABLED (blending is %d/%d/%d/%d)\n", s_n, ALPHA.A, ALPHA.B, ALPHA.C, ALPHA.D);
m_ps_sel.colclip = 1;
}
else
{
// fprintf(stderr, "%d: COLCLIP HDR mode\n", s_n);
// fprintf(stderr, "%d: COLCLIP HDR mode ENABLED\n", s_n);
m_ps_sel.hdr = 1;
}
}
@ -594,8 +596,10 @@ void GSRendererDX11::EmulateBlending()
else
{
// Disable HW blending
// Only BLEND_NO_BAR should hit this code path for now.
m_om_bsel.abe = 0;
// Only BLEND_NO_BAR should hit this code path for now
ASSERT(no_barrier_blend);
}
// Require the fix alpha vlaue