ntv: emit demote extension/capability when emitting demote

this is cleaner and more accurate

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39540>
(cherry picked from commit a842e641d9)
This commit is contained in:
Mike Blumenkrantz 2026-01-26 11:51:02 -05:00 committed by Eric Engestrom
parent 03c90bcd1f
commit e2bf4b9007
2 changed files with 4 additions and 14 deletions

View file

@ -1804,7 +1804,7 @@
"description": "ntv: emit demote extension/capability when emitting demote",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -3605,6 +3605,9 @@ emit_intrinsic(struct ntv_context *ctx, nir_intrinsic_instr *intr)
break;
case nir_intrinsic_demote:
if (!ctx->have_spirv16)
spirv_builder_emit_extension(&ctx->builder, "SPV_EXT_demote_to_helper_invocation");
spirv_builder_emit_cap(&ctx->builder, SpvCapabilityDemoteToHelperInvocation);
spirv_builder_emit_demote(&ctx->builder);
break;
@ -4807,19 +4810,6 @@ nir_to_spirv(struct nir_shader *s, const struct ntv_info *sinfo)
case MESA_SHADER_FRAGMENT:
if (s->info.fs.uses_sample_shading)
spirv_builder_emit_cap(&ctx.builder, SpvCapabilitySampleRateShading);
if (s->info.fs.uses_discard && sinfo->has_demote_to_helper) {
if (!ctx.have_spirv16)
spirv_builder_emit_extension(&ctx.builder, "SPV_EXT_demote_to_helper_invocation");
spirv_builder_emit_cap(&ctx.builder, SpvCapabilityDemoteToHelperInvocation);
}
if (BITSET_TEST(s->info.system_values_read, SYSTEM_VALUE_HELPER_INVOCATION) &&
sinfo->has_demote_to_helper && !ctx.have_spirv16) {
spirv_builder_emit_extension(&ctx.builder, "SPV_EXT_demote_to_helper_invocation");
spirv_builder_emit_cap(&ctx.builder, SpvCapabilityDemoteToHelperInvocation);
}
break;
case MESA_SHADER_VERTEX: