mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 12:35:27 +00:00
VideoBackends: Always enable dual-source blending if supported.
This commit is contained in:
parent
93109df654
commit
ab5054c34e
@ -380,7 +380,7 @@ ID3D11BlendState* StateCache::Get(BlendState state)
|
||||
blenddc.RenderTarget[0].BlendOpAlpha = state.blend_op;
|
||||
|
||||
if (blenddc.RenderTarget[0].SrcBlend == D3D11_BLEND_SRC_COLOR)
|
||||
blenddc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
|
||||
blenddc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC1_ALPHA;
|
||||
else if (blenddc.RenderTarget[0].SrcBlend == D3D11_BLEND_INV_SRC_COLOR)
|
||||
blenddc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
|
||||
else if (blenddc.RenderTarget[0].SrcBlend == D3D11_BLEND_DEST_COLOR)
|
||||
@ -391,7 +391,7 @@ ID3D11BlendState* StateCache::Get(BlendState state)
|
||||
blenddc.RenderTarget[0].SrcBlendAlpha = blenddc.RenderTarget[0].SrcBlend;
|
||||
|
||||
if (blenddc.RenderTarget[0].DestBlend == D3D11_BLEND_SRC_COLOR)
|
||||
blenddc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_SRC_ALPHA;
|
||||
blenddc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_SRC1_ALPHA;
|
||||
else if (blenddc.RenderTarget[0].DestBlend == D3D11_BLEND_INV_SRC_COLOR)
|
||||
blenddc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
|
||||
else if (blenddc.RenderTarget[0].DestBlend == D3D11_BLEND_DEST_COLOR)
|
||||
@ -403,18 +403,6 @@ ID3D11BlendState* StateCache::Get(BlendState state)
|
||||
|
||||
if (state.use_dst_alpha)
|
||||
{
|
||||
// Colors should blend against SRC1_ALPHA
|
||||
if (blenddc.RenderTarget[0].SrcBlend == D3D11_BLEND_SRC_ALPHA)
|
||||
blenddc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC1_ALPHA;
|
||||
else if (blenddc.RenderTarget[0].SrcBlend == D3D11_BLEND_INV_SRC_ALPHA)
|
||||
blenddc.RenderTarget[0].SrcBlend = D3D11_BLEND_INV_SRC1_ALPHA;
|
||||
|
||||
// Colors should blend against SRC1_ALPHA
|
||||
if (blenddc.RenderTarget[0].DestBlend == D3D11_BLEND_SRC_ALPHA)
|
||||
blenddc.RenderTarget[0].DestBlend = D3D11_BLEND_SRC1_ALPHA;
|
||||
else if (blenddc.RenderTarget[0].DestBlend == D3D11_BLEND_INV_SRC_ALPHA)
|
||||
blenddc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC1_ALPHA;
|
||||
|
||||
blenddc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
||||
blenddc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||
blenddc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||
|
@ -675,8 +675,8 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
D3D11_BLEND_ONE,
|
||||
D3D11_BLEND_DEST_COLOR,
|
||||
D3D11_BLEND_INV_DEST_COLOR,
|
||||
D3D11_BLEND_SRC_ALPHA,
|
||||
D3D11_BLEND_INV_SRC_ALPHA, // NOTE: Use SRC1_ALPHA if dst alpha is enabled!
|
||||
D3D11_BLEND_SRC1_ALPHA,
|
||||
D3D11_BLEND_INV_SRC1_ALPHA,
|
||||
(target_has_alpha) ? D3D11_BLEND_DEST_ALPHA : D3D11_BLEND_ONE,
|
||||
(target_has_alpha) ? D3D11_BLEND_INV_DEST_ALPHA : D3D11_BLEND_ZERO};
|
||||
const D3D11_BLEND d3dDestFactors[8] = {
|
||||
@ -684,8 +684,8 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
D3D11_BLEND_ONE,
|
||||
D3D11_BLEND_SRC_COLOR,
|
||||
D3D11_BLEND_INV_SRC_COLOR,
|
||||
D3D11_BLEND_SRC_ALPHA,
|
||||
D3D11_BLEND_INV_SRC_ALPHA, // NOTE: Use SRC1_ALPHA if dst alpha is enabled!
|
||||
D3D11_BLEND_SRC1_ALPHA,
|
||||
D3D11_BLEND_INV_SRC1_ALPHA,
|
||||
(target_has_alpha) ? D3D11_BLEND_DEST_ALPHA : D3D11_BLEND_ONE,
|
||||
(target_has_alpha) ? D3D11_BLEND_INV_DEST_ALPHA : D3D11_BLEND_ZERO};
|
||||
|
||||
|
@ -301,18 +301,6 @@ D3D12_BLEND_DESC StateCache::GetDesc12(BlendState state)
|
||||
|
||||
if (state.use_dst_alpha)
|
||||
{
|
||||
// Colors should blend against SRC1_ALPHA
|
||||
if (blenddc.RenderTarget[0].SrcBlend == D3D12_BLEND_SRC_ALPHA)
|
||||
blenddc.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC1_ALPHA;
|
||||
else if (blenddc.RenderTarget[0].SrcBlend == D3D12_BLEND_INV_SRC_ALPHA)
|
||||
blenddc.RenderTarget[0].SrcBlend = D3D12_BLEND_INV_SRC1_ALPHA;
|
||||
|
||||
// Colors should blend against SRC1_ALPHA
|
||||
if (blenddc.RenderTarget[0].DestBlend == D3D12_BLEND_SRC_ALPHA)
|
||||
blenddc.RenderTarget[0].DestBlend = D3D12_BLEND_SRC1_ALPHA;
|
||||
else if (blenddc.RenderTarget[0].DestBlend == D3D12_BLEND_INV_SRC_ALPHA)
|
||||
blenddc.RenderTarget[0].DestBlend = D3D12_BLEND_INV_SRC1_ALPHA;
|
||||
|
||||
blenddc.RenderTarget[0].SrcBlendAlpha = D3D12_BLEND_ONE;
|
||||
blenddc.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_ZERO;
|
||||
blenddc.RenderTarget[0].BlendOpAlpha = D3D12_BLEND_OP_ADD;
|
||||
|
@ -592,8 +592,8 @@ void Renderer::SetBlendMode(bool force_update)
|
||||
D3D12_BLEND_ONE,
|
||||
D3D12_BLEND_DEST_COLOR,
|
||||
D3D12_BLEND_INV_DEST_COLOR,
|
||||
D3D12_BLEND_SRC_ALPHA,
|
||||
D3D12_BLEND_INV_SRC_ALPHA, // NOTE: Use SRC1_ALPHA if dst alpha is enabled!
|
||||
D3D12_BLEND_SRC1_ALPHA,
|
||||
D3D12_BLEND_INV_SRC1_ALPHA,
|
||||
(target_has_alpha) ? D3D12_BLEND_DEST_ALPHA : D3D12_BLEND_ONE,
|
||||
(target_has_alpha) ? D3D12_BLEND_INV_DEST_ALPHA : D3D12_BLEND_ZERO};
|
||||
const D3D12_BLEND d3d_dst_factors[8] = {
|
||||
@ -601,8 +601,8 @@ void Renderer::SetBlendMode(bool force_update)
|
||||
D3D12_BLEND_ONE,
|
||||
D3D12_BLEND_SRC_COLOR,
|
||||
D3D12_BLEND_INV_SRC_COLOR,
|
||||
D3D12_BLEND_SRC_ALPHA,
|
||||
D3D12_BLEND_INV_SRC_ALPHA, // NOTE: Use SRC1_ALPHA if dst alpha is enabled!
|
||||
D3D12_BLEND_SRC1_ALPHA,
|
||||
D3D12_BLEND_INV_SRC1_ALPHA,
|
||||
(target_has_alpha) ? D3D12_BLEND_DEST_ALPHA : D3D12_BLEND_ONE,
|
||||
(target_has_alpha) ? D3D12_BLEND_INV_DEST_ALPHA : D3D12_BLEND_ZERO};
|
||||
|
||||
|
@ -1241,7 +1241,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
bool target_has_alpha = bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
|
||||
|
||||
bool useDstAlpha = bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && target_has_alpha;
|
||||
bool useDualSource = useDstAlpha && g_ActiveConfig.backend_info.bSupportsDualSourceBlend;
|
||||
bool useDualSource = g_ActiveConfig.backend_info.bSupportsDualSourceBlend;
|
||||
|
||||
const GLenum glSrcFactors[8] = {
|
||||
GL_ZERO,
|
||||
@ -1269,7 +1269,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
// 3-5 - srcRGB function
|
||||
// 6-8 - dstRGB function
|
||||
|
||||
u32 newval = useDualSource << 1;
|
||||
u32 newval = useDstAlpha << 1;
|
||||
newval |= bpmem.blendmode.subtract << 2;
|
||||
|
||||
if (bpmem.blendmode.subtract)
|
||||
@ -1295,7 +1295,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
{
|
||||
// subtract enable change
|
||||
GLenum equation = newval & 4 ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD;
|
||||
GLenum equationAlpha = useDualSource ? GL_FUNC_ADD : equation;
|
||||
GLenum equationAlpha = useDstAlpha ? GL_FUNC_ADD : equation;
|
||||
|
||||
glBlendEquationSeparate(equation, equationAlpha);
|
||||
}
|
||||
@ -1308,7 +1308,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
GLenum dstFactor = glDestFactors[dstidx];
|
||||
|
||||
// adjust alpha factors
|
||||
if (useDualSource)
|
||||
if (useDstAlpha)
|
||||
{
|
||||
srcidx = BlendMode::ONE;
|
||||
dstidx = BlendMode::ZERO;
|
||||
|
@ -1107,8 +1107,8 @@ void Renderer::SetBlendMode(bool force_update)
|
||||
// Our render target always uses an alpha channel, so we need to override the blend functions to
|
||||
// assume a destination alpha of 1 if the render target isn't supposed to have an alpha channel.
|
||||
bool target_has_alpha = bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
|
||||
bool use_dst_alpha = bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && target_has_alpha &&
|
||||
g_vulkan_context->SupportsDualSourceBlend();
|
||||
bool use_dst_alpha = bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && target_has_alpha;
|
||||
bool use_dual_src = g_vulkan_context->SupportsDualSourceBlend();
|
||||
|
||||
new_blend_state.blend_enable = VK_TRUE;
|
||||
new_blend_state.blend_op = VK_BLEND_OP_ADD;
|
||||
@ -1129,11 +1129,11 @@ void Renderer::SetBlendMode(bool force_update)
|
||||
break;
|
||||
case BlendMode::SRCALPHA:
|
||||
new_blend_state.src_blend =
|
||||
use_dst_alpha ? VK_BLEND_FACTOR_SRC1_ALPHA : VK_BLEND_FACTOR_SRC_ALPHA;
|
||||
use_dual_src ? VK_BLEND_FACTOR_SRC1_ALPHA : VK_BLEND_FACTOR_SRC_ALPHA;
|
||||
break;
|
||||
case BlendMode::INVSRCALPHA:
|
||||
new_blend_state.src_blend =
|
||||
use_dst_alpha ? VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA : VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
use_dual_src ? VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA : VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
break;
|
||||
case BlendMode::DSTALPHA:
|
||||
new_blend_state.src_blend = target_has_alpha ? VK_BLEND_FACTOR_DST_ALPHA : VK_BLEND_FACTOR_ONE;
|
||||
@ -1163,11 +1163,11 @@ void Renderer::SetBlendMode(bool force_update)
|
||||
break;
|
||||
case BlendMode::SRCALPHA:
|
||||
new_blend_state.dst_blend =
|
||||
use_dst_alpha ? VK_BLEND_FACTOR_SRC1_ALPHA : VK_BLEND_FACTOR_SRC_ALPHA;
|
||||
use_dual_src ? VK_BLEND_FACTOR_SRC1_ALPHA : VK_BLEND_FACTOR_SRC_ALPHA;
|
||||
break;
|
||||
case BlendMode::INVSRCALPHA:
|
||||
new_blend_state.dst_blend =
|
||||
use_dst_alpha ? VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA : VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
use_dual_src ? VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA : VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
break;
|
||||
case BlendMode::DSTALPHA:
|
||||
new_blend_state.dst_blend = target_has_alpha ? VK_BLEND_FACTOR_DST_ALPHA : VK_BLEND_FACTOR_ONE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user