From 4da51aa88fa54f41321a2bb5054569e216d5b4c3 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Mon, 3 Jan 2022 14:47:35 -0800 Subject: [PATCH] microsoft/compiler: Primitive ID should only be added as a sysval in geometry shaders Docs say that its presence in signatures as a "shadow" element (meaning it's not accessed via load/store, but with a dedicated opcode) is legacy. It seems it wasn't carried forward when HS/DS were added in D3D11. Reviewed-by: Boris Brezillon Reviewed-by: Bill Kristiansen Part-of: --- src/microsoft/compiler/nir_to_dxil.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index 16c4eced4e8..893c190913c 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -5462,12 +5462,13 @@ struct sysvalue_name { gl_system_value value; int slot; char *name; + gl_shader_stage only_in_shader; } possible_sysvalues[] = { - {SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, -1, "SV_VertexID"}, - {SYSTEM_VALUE_INSTANCE_ID, -1, "SV_InstanceID"}, - {SYSTEM_VALUE_FRONT_FACE, VARYING_SLOT_FACE, "SV_IsFrontFace"}, - {SYSTEM_VALUE_PRIMITIVE_ID, VARYING_SLOT_PRIMITIVE_ID, "SV_PrimitiveID"}, - {SYSTEM_VALUE_SAMPLE_ID, -1, "SV_SampleIndex"}, + {SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, -1, "SV_VertexID", MESA_SHADER_NONE}, + {SYSTEM_VALUE_INSTANCE_ID, -1, "SV_InstanceID", MESA_SHADER_NONE}, + {SYSTEM_VALUE_FRONT_FACE, VARYING_SLOT_FACE, "SV_IsFrontFace", MESA_SHADER_NONE}, + {SYSTEM_VALUE_PRIMITIVE_ID, VARYING_SLOT_PRIMITIVE_ID, "SV_PrimitiveID", MESA_SHADER_GEOMETRY}, + {SYSTEM_VALUE_SAMPLE_ID, -1, "SV_SampleIndex", MESA_SHADER_NONE}, }; static bool @@ -5481,6 +5482,9 @@ allocate_sysvalues(struct ntd_context *ctx) for (unsigned i = 0; i < ARRAY_SIZE(possible_sysvalues); ++i) { struct sysvalue_name *info = &possible_sysvalues[i]; + if (info->only_in_shader != MESA_SHADER_NONE && + info->only_in_shader != ctx->shader->info.stage) + continue; if (BITSET_TEST(ctx->shader->info.system_values_read, info->value)) { if (!append_input_or_sysvalue(ctx, info->slot, info->value, info->name,