From ffc1fa646c3dab52e45411341a72757126f24a5b Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Thu, 19 Nov 2020 11:28:51 +0100 Subject: [PATCH] vkd3d: Mask out attachments which cannot safely be written to. Signed-off-by: Hans-Kristian Arntzen --- libs/vkd3d/state.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index a8afeee4..8a1b177d 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -2464,6 +2464,9 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s } blend_attachment_from_d3d12(&graphics->blend_attachments[i], rt_desc); + + if (graphics->null_attachment_mask & (1u << i)) + memset(&graphics->blend_attachments[i], 0, sizeof(graphics->blend_attachments[i])); } for (i = rt_count; i < ARRAY_SIZE(graphics->rtv_formats); ++i) @@ -2539,6 +2542,14 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s ps_compile_args.output_swizzles = ps_output_swizzle; ps_compile_args.output_swizzle_count = rt_count; + if (ps_compile_args.dual_source_blending) + { + /* If we're using dual source blending, we can only safely write to MRT 0. + * Be defensive about programs which do not do this for us. */ + memset(graphics->blend_attachments + 1, 0, + sizeof(graphics->blend_attachments[0]) * (ARRAY_SIZE(graphics->blend_attachments) - 1)); + } + if (compile_args.dual_source_blending && rt_count > 1) { WARN("Only one render target is allowed when dual source blending is used.\n");