VKPipeline: Add shader blending support

This commit is contained in:
OatmealDome 2021-12-25 00:27:53 -05:00
parent 3ed9d5a3c7
commit bad0283ff7

View File

@ -132,16 +132,26 @@ static VkPipelineDepthStencilStateCreateInfo GetVulkanDepthStencilState(const De
};
}
static VkPipelineColorBlendAttachmentState GetVulkanAttachmentBlendState(const BlendingState& state)
static VkPipelineColorBlendAttachmentState
GetVulkanAttachmentBlendState(const BlendingState& state)
{
VkPipelineColorBlendAttachmentState vk_state = {};
vk_state.blendEnable = static_cast<VkBool32>(state.blendenable);
vk_state.colorBlendOp = state.subtract ? VK_BLEND_OP_REVERSE_SUBTRACT : VK_BLEND_OP_ADD;
vk_state.alphaBlendOp = state.subtractAlpha ? VK_BLEND_OP_REVERSE_SUBTRACT : VK_BLEND_OP_ADD;
bool use_dual_source =
state.usedualsrc && g_ActiveConfig.backend_info.bSupportsDualSourceBlend &&
(!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_DUAL_SOURCE_BLENDING) || state.dstalpha);
bool use_shader_blend = !use_dual_source && state.usedualsrc && state.dstalpha &&
g_ActiveConfig.backend_info.bSupportsFramebufferFetch;
if (use_shader_blend)
{
vk_state.blendEnable = VK_FALSE;
}
else
{
vk_state.blendEnable = static_cast<VkBool32>(state.blendenable);
vk_state.colorBlendOp = state.subtract ? VK_BLEND_OP_REVERSE_SUBTRACT : VK_BLEND_OP_ADD;
vk_state.alphaBlendOp = state.subtractAlpha ? VK_BLEND_OP_REVERSE_SUBTRACT : VK_BLEND_OP_ADD;
if (use_dual_source)
{
@ -180,6 +190,7 @@ static VkPipelineColorBlendAttachmentState GetVulkanAttachmentBlendState(const B
vk_state.dstColorBlendFactor = dst_factors[u32(state.dstfactor.Value())];
vk_state.dstAlphaBlendFactor = dst_factors[u32(state.dstfactoralpha.Value())];
}
}
if (state.colorupdate)
{