From 1ccfccdcf0cd44ef17d862732ed4ae1b455861ef Mon Sep 17 00:00:00 2001 From: iwubcode Date: Tue, 5 Sep 2017 22:07:47 -0500 Subject: [PATCH] D3D: Properly handle dual source blending --- Source/Core/VideoBackends/D3D/D3DState.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/D3DState.cpp b/Source/Core/VideoBackends/D3D/D3DState.cpp index ab67fbf48a..b21af1f217 100644 --- a/Source/Core/VideoBackends/D3D/D3DState.cpp +++ b/Source/Core/VideoBackends/D3D/D3DState.cpp @@ -404,14 +404,17 @@ ID3D11BlendState* StateCache::Get(BlendingState state) if (state.alphaupdate) tdesc.RenderTargetWriteMask |= D3D11_COLOR_WRITE_ENABLE_ALPHA; - static constexpr std::array src_factors = { + const bool use_dual_source = state.usedualsrc; + const std::array src_factors = { {D3D11_BLEND_ZERO, D3D11_BLEND_ONE, D3D11_BLEND_DEST_COLOR, D3D11_BLEND_INV_DEST_COLOR, - D3D11_BLEND_SRC1_ALPHA, D3D11_BLEND_INV_SRC1_ALPHA, D3D11_BLEND_DEST_ALPHA, - D3D11_BLEND_INV_DEST_ALPHA}}; - static constexpr std::array dst_factors = { + use_dual_source ? D3D11_BLEND_SRC1_ALPHA : D3D11_BLEND_SRC_ALPHA, + use_dual_source ? D3D11_BLEND_INV_SRC1_ALPHA : D3D11_BLEND_INV_SRC_ALPHA, + D3D11_BLEND_DEST_ALPHA, D3D11_BLEND_INV_DEST_ALPHA}}; + const std::array dst_factors = { {D3D11_BLEND_ZERO, D3D11_BLEND_ONE, D3D11_BLEND_SRC_COLOR, D3D11_BLEND_INV_SRC_COLOR, - D3D11_BLEND_SRC1_ALPHA, D3D11_BLEND_INV_SRC1_ALPHA, D3D11_BLEND_DEST_ALPHA, - D3D11_BLEND_INV_DEST_ALPHA}}; + use_dual_source ? D3D11_BLEND_SRC1_ALPHA : D3D11_BLEND_SRC_ALPHA, + use_dual_source ? D3D11_BLEND_INV_SRC1_ALPHA : D3D11_BLEND_INV_SRC_ALPHA, + D3D11_BLEND_DEST_ALPHA, D3D11_BLEND_INV_DEST_ALPHA}}; tdesc.SrcBlend = src_factors[state.srcfactor]; tdesc.SrcBlendAlpha = src_factors[state.srcfactoralpha];