zink: fix stencil-export cap emission
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 15 Apr 2021 08:17:55 +0000 (10:17 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 19 Apr 2021 10:48:43 +0000 (10:48 +0000)
This cap should only ever be emitted for fragment-shaders, but we
accidentally emit it for all shaders. Let's tighten the check to avoid a
validator warning when emitting non-fragment shaders without support for
VK_EXT_shader_stencil_export.

Fixes: 8724d4fb361 ("zink: check shader stencil output")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10249>

src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c

index 3a78b51..969f718 100644 (file)
@@ -3532,7 +3532,8 @@ nir_to_spirv(struct nir_shader *s, const struct zink_so_info *so_info)
       spirv_builder_emit_mem_model(&ctx.builder, SpvAddressingModelLogical,
                                    SpvMemoryModelGLSL450);
 
-   if (s->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_STENCIL)) {
+   if (s->info.stage == MESA_SHADER_FRAGMENT &&
+       s->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_STENCIL)) {
       spirv_builder_emit_extension(&ctx.builder, "SPV_EXT_shader_stencil_export");
       spirv_builder_emit_cap(&ctx.builder, SpvCapabilityStencilExportEXT);
    }