From e9066ff2be33c5cb147185374f4c92a2902c2f77 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 14 Jun 2022 22:27:32 +0200 Subject: [PATCH] dzn: Disable rasterization if the last geometry stage doesn't write the position If we don't do that, and we get passed a dummy geometry shader (one that has no EmitVertex() calls) we get a DXIL validation error. Reviewed-by: Jesse Natalie Part-of: --- src/microsoft/vulkan/dzn_pipeline.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/microsoft/vulkan/dzn_pipeline.c b/src/microsoft/vulkan/dzn_pipeline.c index a66a3eeb243..6eab6abe13f 100644 --- a/src/microsoft/vulkan/dzn_pipeline.c +++ b/src/microsoft/vulkan/dzn_pipeline.c @@ -422,6 +422,17 @@ dzn_graphics_pipeline_compile_shaders(struct dzn_device *device, /* Last step: translate NIR shaders into DXIL modules */ u_foreach_bit(stage, active_stage_mask) { + if (stage == MESA_SHADER_FRAGMENT) { + gl_shader_stage prev_stage = + util_last_bit(active_stage_mask & BITFIELD_MASK(MESA_SHADER_FRAGMENT)) - 1; + /* Disable rasterization if the last geometry stage doesn't + * write the position. + */ + if (prev_stage == MESA_SHADER_NONE || + !(stages[prev_stage].nir->info.outputs_written & VARYING_BIT_POS)) + continue; + } + D3D12_SHADER_BYTECODE *slot = dzn_pipeline_get_gfx_shader_slot(out, stage);