From f1847462a9115bd57a3cf14681eecd64ff4852ee Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 24 Mar 2024 21:01:03 +1000 Subject: [PATCH] VulkanDevice: Fix rendering to multiple targets --- src/util/vulkan_pipeline.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/util/vulkan_pipeline.cpp b/src/util/vulkan_pipeline.cpp index 38c34c847..657e50a8a 100644 --- a/src/util/vulkan_pipeline.cpp +++ b/src/util/vulkan_pipeline.cpp @@ -184,12 +184,19 @@ std::unique_ptr VulkanDevice::CreatePipeline(const GPUPipeline::Gra config.depth.depth_write, compare_mapping[static_cast(config.depth.depth_test.GetValue())]); gpb.SetNoStencilState(); - gpb.SetBlendAttachment(0, config.blend.enable, blend_mapping[static_cast(config.blend.src_blend.GetValue())], - blend_mapping[static_cast(config.blend.dst_blend.GetValue())], - op_mapping[static_cast(config.blend.blend_op.GetValue())], - blend_mapping[static_cast(config.blend.src_alpha_blend.GetValue())], - blend_mapping[static_cast(config.blend.dst_alpha_blend.GetValue())], - op_mapping[static_cast(config.blend.alpha_blend_op.GetValue())], config.blend.write_mask); + for (u32 i = 0; i < MAX_RENDER_TARGETS; i++) + { + if (config.color_formats[i] == GPUTexture::Format::Unknown) + break; + + gpb.SetBlendAttachment(i, config.blend.enable, blend_mapping[static_cast(config.blend.src_blend.GetValue())], + blend_mapping[static_cast(config.blend.dst_blend.GetValue())], + op_mapping[static_cast(config.blend.blend_op.GetValue())], + blend_mapping[static_cast(config.blend.src_alpha_blend.GetValue())], + blend_mapping[static_cast(config.blend.dst_alpha_blend.GetValue())], + op_mapping[static_cast(config.blend.alpha_blend_op.GetValue())], + config.blend.write_mask); + } const auto blend_constants = config.blend.GetConstantFloatColor(); gpb.SetBlendConstants(blend_constants[0], blend_constants[1], blend_constants[2], blend_constants[3]);