From 7502b0890013020a0f2d599bde9a425b77aebd8b Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Mon, 3 Jan 2022 04:58:17 -0800 Subject: [PATCH] microsoft/compiler: Handle load_invocation_id for GS and HS Reviewed-by: Sil Vilerino Part-of: --- src/microsoft/compiler/dxil_function.c | 2 ++ src/microsoft/compiler/nir_to_dxil.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/microsoft/compiler/dxil_function.c b/src/microsoft/compiler/dxil_function.c index a6d192a1d7d..f5fe77e7d60 100644 --- a/src/microsoft/compiler/dxil_function.c +++ b/src/microsoft/compiler/dxil_function.c @@ -71,6 +71,8 @@ static struct predefined_func_descr predefined_funcs[] = { {"dx.op.atomicCompareExchange", "O", "i@iiiii", DXIL_ATTR_KIND_READ_NONE}, {"dx.op.textureStore", "v", "i@iiiOOOOc", DXIL_ATTR_KIND_NONE}, {"dx.op.primitiveID", "i", "i", DXIL_ATTR_KIND_READ_NONE}, +{"dx.op.outputControlPointID", "i", "i", DXIL_ATTR_KIND_READ_NONE}, +{"dx.op.gsInstanceID", "i", "i", DXIL_ATTR_KIND_READ_NONE}, {"dx.op.legacyF16ToF32", "f", "ii", DXIL_ATTR_KIND_READ_ONLY}, {"dx.op.legacyF32ToF16", "i", "if", DXIL_ATTR_KIND_READ_ONLY}, {"dx.op.makeDouble", "g", "iii", DXIL_ATTR_KIND_READ_NONE}, diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index c3a5c781bab..76dc0a72c8e 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -274,9 +274,12 @@ enum dxil_intr { DXIL_INTR_EMIT_STREAM = 97, DXIL_INTR_CUT_STREAM = 98, + DXIL_INTR_GS_INSTANCE_ID = 100, + DXIL_INTR_MAKE_DOUBLE = 101, DXIL_INTR_SPLIT_DOUBLE = 102, + DXIL_INTR_OUTPUT_CONTROL_POINT_ID = 107, DXIL_INTR_PRIMITIVE_ID = 108, DXIL_INTR_LEGACY_F32TOF16 = 130, @@ -3760,6 +3763,17 @@ emit_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr) case nir_intrinsic_load_sample_id: return emit_load_unary_external_function(ctx, intr, "dx.op.sampleIndex", DXIL_INTR_SAMPLE_INDEX); + case nir_intrinsic_load_invocation_id: + switch (ctx->mod.shader_kind) { + case DXIL_HULL_SHADER: + return emit_load_unary_external_function(ctx, intr, "dx.op.outputControlPointID", + DXIL_INTR_OUTPUT_CONTROL_POINT_ID); + case DXIL_GEOMETRY_SHADER: + return emit_load_unary_external_function(ctx, intr, "dx.op.gsInstanceID", + DXIL_INTR_GS_INSTANCE_ID); + default: + unreachable("Unexpected shader kind for invocation ID"); + } case nir_intrinsic_load_sample_mask_in: return emit_load_sample_mask_in(ctx, intr); case nir_intrinsic_load_shared_dxil: