Skip to content

Commit 8c3a215

Browse files
committed
Fix Vulkan Backend Input of BlendParams
1 parent f4c72f3 commit 8c3a215

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/nbl/video/CVulkanLogicalDevice.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -573,33 +573,33 @@ bool CVulkanLogicalDevice::createGPUGraphicsPipelines_impl(
573573

574574
uint32_t offset = colorBlendAttachmentCount_total;
575575

576-
uint32_t colorBlendAttachmentCount = 0u;
577-
for (uint32_t as = 0u; as < asset::SBlendParams::MAX_COLOR_ATTACHMENT_COUNT; ++as)
576+
assert(creationParams[i].subpassIx < creationParams[i].renderpass->getCreationParameters().subpassCount);
577+
auto subpassDescription = creationParams[i].renderpass->getCreationParameters().subpasses[creationParams[i].subpassIx];
578+
uint32_t colorBlendAttachmentCount = subpassDescription.colorAttachmentCount;
579+
580+
for (uint32_t as = 0u; as < colorBlendAttachmentCount; ++as)
578581
{
579-
const auto& attBlendParams = blendParams.blendParams[as];
580-
if (attBlendParams.attachmentEnabled)
581-
{
582-
auto& attBlendState = vk_colorBlendAttachmentStates[offset + colorBlendAttachmentCount++];
583-
584-
attBlendState.blendEnable = attBlendParams.blendEnable;
585-
attBlendState.srcColorBlendFactor = static_cast<VkBlendFactor>(attBlendParams.srcColorFactor);
586-
attBlendState.dstColorBlendFactor = static_cast<VkBlendFactor>(attBlendParams.dstColorFactor);
587-
assert(attBlendParams.colorBlendOp <= asset::EBO_MAX);
588-
attBlendState.colorBlendOp = static_cast<VkBlendOp>(attBlendParams.colorBlendOp);
589-
attBlendState.srcAlphaBlendFactor = static_cast<VkBlendFactor>(attBlendParams.srcAlphaFactor);
590-
attBlendState.dstAlphaBlendFactor = static_cast<VkBlendFactor>(attBlendParams.dstAlphaFactor);
591-
assert(attBlendParams.alphaBlendOp <= asset::EBO_MAX);
592-
attBlendState.alphaBlendOp = static_cast<VkBlendOp>(attBlendParams.alphaBlendOp);
593-
attBlendState.colorWriteMask = static_cast<VkColorComponentFlags>(attBlendParams.colorWriteMask);
594-
}
582+
const auto& inBlendParams = blendParams.blendParams[as];
583+
auto& outBlendState = vk_colorBlendAttachmentStates[offset + as];
584+
585+
outBlendState.blendEnable = inBlendParams.blendEnable;
586+
outBlendState.srcColorBlendFactor = getVkBlendFactorFromBlendFactor(static_cast<asset::E_BLEND_FACTOR>(inBlendParams.srcColorFactor));
587+
outBlendState.dstColorBlendFactor = getVkBlendFactorFromBlendFactor(static_cast<asset::E_BLEND_FACTOR>(inBlendParams.dstColorFactor));
588+
assert(inBlendParams.colorBlendOp <= asset::EBO_MAX);
589+
outBlendState.colorBlendOp = getVkBlendOpFromBlendOp(static_cast<asset::E_BLEND_OP>(inBlendParams.colorBlendOp));
590+
outBlendState.srcAlphaBlendFactor = getVkBlendFactorFromBlendFactor(static_cast<asset::E_BLEND_FACTOR>(inBlendParams.srcAlphaFactor));
591+
outBlendState.dstAlphaBlendFactor = getVkBlendFactorFromBlendFactor(static_cast<asset::E_BLEND_FACTOR>(inBlendParams.dstAlphaFactor));
592+
assert(inBlendParams.alphaBlendOp <= asset::EBO_MAX);
593+
outBlendState.alphaBlendOp = getVkBlendOpFromBlendOp(static_cast<asset::E_BLEND_OP>(inBlendParams.alphaBlendOp));
594+
outBlendState.colorWriteMask = getVkColorComponentFlagsFromColorWriteMask(inBlendParams.colorWriteMask);
595595
}
596596
colorBlendAttachmentCount_total += colorBlendAttachmentCount;
597597

598598
vk_colorBlendStates[i].sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
599599
vk_colorBlendStates[i].pNext = nullptr;
600600
vk_colorBlendStates[i].flags = 0u;
601601
vk_colorBlendStates[i].logicOpEnable = blendParams.logicOpEnable;
602-
vk_colorBlendStates[i].logicOp = static_cast<VkLogicOp>(blendParams.logicOp);
602+
vk_colorBlendStates[i].logicOp = getVkLogicOpFromLogicOp(static_cast<asset::E_LOGIC_OP>(blendParams.logicOp));
603603
vk_colorBlendStates[i].attachmentCount = colorBlendAttachmentCount;
604604
vk_colorBlendStates[i].pAttachments = vk_colorBlendAttachmentStates.data() + offset;
605605
vk_colorBlendStates[i].blendConstants[0] = 0.0f;

0 commit comments

Comments
 (0)