mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 07:45:33 +01:00
VKPipeline: Add shader blending support
This commit is contained in:
parent
3ed9d5a3c7
commit
bad0283ff7
@ -132,53 +132,64 @@ static VkPipelineDepthStencilStateCreateInfo GetVulkanDepthStencilState(const De
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static VkPipelineColorBlendAttachmentState GetVulkanAttachmentBlendState(const BlendingState& state)
|
static VkPipelineColorBlendAttachmentState
|
||||||
|
GetVulkanAttachmentBlendState(const BlendingState& state)
|
||||||
{
|
{
|
||||||
VkPipelineColorBlendAttachmentState vk_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 =
|
bool use_dual_source =
|
||||||
state.usedualsrc && g_ActiveConfig.backend_info.bSupportsDualSourceBlend &&
|
state.usedualsrc && g_ActiveConfig.backend_info.bSupportsDualSourceBlend &&
|
||||||
(!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_DUAL_SOURCE_BLENDING) || state.dstalpha);
|
(!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_dual_source)
|
if (use_shader_blend)
|
||||||
{
|
{
|
||||||
static constexpr std::array<VkBlendFactor, 8> src_factors = {
|
vk_state.blendEnable = VK_FALSE;
|
||||||
{VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_DST_COLOR,
|
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR, VK_BLEND_FACTOR_SRC1_ALPHA,
|
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
|
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
|
|
||||||
static constexpr std::array<VkBlendFactor, 8> dst_factors = {
|
|
||||||
{VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_SRC_COLOR,
|
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR, VK_BLEND_FACTOR_SRC1_ALPHA,
|
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
|
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
|
|
||||||
|
|
||||||
vk_state.srcColorBlendFactor = src_factors[u32(state.srcfactor.Value())];
|
|
||||||
vk_state.srcAlphaBlendFactor = src_factors[u32(state.srcfactoralpha.Value())];
|
|
||||||
vk_state.dstColorBlendFactor = dst_factors[u32(state.dstfactor.Value())];
|
|
||||||
vk_state.dstAlphaBlendFactor = dst_factors[u32(state.dstfactoralpha.Value())];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
static constexpr std::array<VkBlendFactor, 8> src_factors = {
|
vk_state.blendEnable = static_cast<VkBool32>(state.blendenable);
|
||||||
{VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_DST_COLOR,
|
vk_state.colorBlendOp = state.subtract ? VK_BLEND_OP_REVERSE_SUBTRACT : VK_BLEND_OP_ADD;
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR, VK_BLEND_FACTOR_SRC_ALPHA,
|
vk_state.alphaBlendOp = state.subtractAlpha ? VK_BLEND_OP_REVERSE_SUBTRACT : VK_BLEND_OP_ADD;
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
|
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
|
|
||||||
|
|
||||||
static constexpr std::array<VkBlendFactor, 8> dst_factors = {
|
if (use_dual_source)
|
||||||
{VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_SRC_COLOR,
|
{
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR, VK_BLEND_FACTOR_SRC_ALPHA,
|
static constexpr std::array<VkBlendFactor, 8> src_factors = {
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
|
{VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_DST_COLOR,
|
||||||
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
|
VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR, VK_BLEND_FACTOR_SRC1_ALPHA,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
|
||||||
|
static constexpr std::array<VkBlendFactor, 8> dst_factors = {
|
||||||
|
{VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_SRC_COLOR,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR, VK_BLEND_FACTOR_SRC1_ALPHA,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
|
||||||
|
|
||||||
vk_state.srcColorBlendFactor = src_factors[u32(state.srcfactor.Value())];
|
vk_state.srcColorBlendFactor = src_factors[u32(state.srcfactor.Value())];
|
||||||
vk_state.srcAlphaBlendFactor = src_factors[u32(state.srcfactoralpha.Value())];
|
vk_state.srcAlphaBlendFactor = src_factors[u32(state.srcfactoralpha.Value())];
|
||||||
vk_state.dstColorBlendFactor = dst_factors[u32(state.dstfactor.Value())];
|
vk_state.dstColorBlendFactor = dst_factors[u32(state.dstfactor.Value())];
|
||||||
vk_state.dstAlphaBlendFactor = dst_factors[u32(state.dstfactoralpha.Value())];
|
vk_state.dstAlphaBlendFactor = dst_factors[u32(state.dstfactoralpha.Value())];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
static constexpr std::array<VkBlendFactor, 8> src_factors = {
|
||||||
|
{VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_DST_COLOR,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR, VK_BLEND_FACTOR_SRC_ALPHA,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
|
||||||
|
|
||||||
|
static constexpr std::array<VkBlendFactor, 8> dst_factors = {
|
||||||
|
{VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_SRC_COLOR,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR, VK_BLEND_FACTOR_SRC_ALPHA,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
|
||||||
|
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
|
||||||
|
|
||||||
|
vk_state.srcColorBlendFactor = src_factors[u32(state.srcfactor.Value())];
|
||||||
|
vk_state.srcAlphaBlendFactor = src_factors[u32(state.srcfactoralpha.Value())];
|
||||||
|
vk_state.dstColorBlendFactor = dst_factors[u32(state.dstfactor.Value())];
|
||||||
|
vk_state.dstAlphaBlendFactor = dst_factors[u32(state.dstfactoralpha.Value())];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.colorupdate)
|
if (state.colorupdate)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user