Skip to content
Snippets Groups Projects
Verified Commit 796b521d authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Fix issue with blend state and multiple color attachments

parent 393809b4
No related branches found
No related tags found
No related merge requests found
...@@ -317,19 +317,48 @@ namespace vkcv { ...@@ -317,19 +317,48 @@ namespace vkcv {
* @return * @return
*/ */
vk::PipelineColorBlendStateCreateInfo vk::PipelineColorBlendStateCreateInfo
createPipelineColorBlendStateCreateInfo(const GraphicsPipelineConfig &config) { createPipelineColorBlendStateCreateInfo(const GraphicsPipelineConfig &config,
// currently set to additive, if not disabled const PassConfig &passConfig) {
// BlendFactors must be set as soon as additional BlendModes are added static std::vector<vk::PipelineColorBlendAttachmentState> colorBlendAttachmentStates;
static vk::PipelineColorBlendAttachmentState colorBlendAttachmentState(
config.getBlendMode() != BlendMode::None, vk::BlendFactor::eOne, vk::BlendFactor::eOne, colorBlendAttachmentStates.clear();
vk::BlendOp::eAdd, vk::BlendFactor::eOne, vk::BlendFactor::eOne, vk::BlendOp::eAdd, colorBlendAttachmentStates.reserve(passConfig.getAttachments().size());
vk::ColorComponentFlags(VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT
| VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT)); for (const auto& attachment : passConfig.getAttachments()) {
if ((isDepthFormat(attachment.getFormat())) ||
(isStencilFormat(attachment.getFormat()))) {
continue;
}
// currently set to additive, if not disabled
// BlendFactors must be set as soon as additional BlendModes are added
vk::PipelineColorBlendAttachmentState colorBlendAttachmentState (
config.getBlendMode() != BlendMode::None,
vk::BlendFactor::eOne,
vk::BlendFactor::eOne,
vk::BlendOp::eAdd,
vk::BlendFactor::eOne,
vk::BlendFactor::eOne,
vk::BlendOp::eAdd,
vk::ColorComponentFlags(
VK_COLOR_COMPONENT_R_BIT |
VK_COLOR_COMPONENT_G_BIT |
VK_COLOR_COMPONENT_B_BIT |
VK_COLOR_COMPONENT_A_BIT
)
);
colorBlendAttachmentStates.push_back(colorBlendAttachmentState);
}
vk::PipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo( vk::PipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo(
{}, false, vk::LogicOp::eClear, {},
1, // TODO: hardcoded to one false,
&colorBlendAttachmentState, { 1.f, 1.f, 1.f, 1.f }); vk::LogicOp::eClear,
colorBlendAttachmentStates.size(),
colorBlendAttachmentStates.data(),
{ 1.f, 1.f, 1.f, 1.f }
);
return pipelineColorBlendStateCreateInfo; return pipelineColorBlendStateCreateInfo;
} }
...@@ -568,7 +597,7 @@ namespace vkcv { ...@@ -568,7 +597,7 @@ namespace vkcv {
// color blend state // color blend state
vk::PipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo = vk::PipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo =
createPipelineColorBlendStateCreateInfo(config); createPipelineColorBlendStateCreateInfo(config, passConfig);
// Dynamic State // Dynamic State
vk::PipelineDynamicStateCreateInfo dynamicStateCreateInfo = vk::PipelineDynamicStateCreateInfo dynamicStateCreateInfo =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment