From 3f467cae67830c6ba3732cc3f1065bd1f7182bee Mon Sep 17 00:00:00 2001 From: lightningterror Date: Sun, 23 Feb 2020 22:24:32 +0100 Subject: [PATCH] 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. --- .../GSdx/Renderers/DX11/GSRendererDX11.cpp | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp b/plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp index 1fd2673db0..ee8a974e75 100644 --- a/plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp +++ b/plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp @@ -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