[clang] [HLSL] Implement the SV_InstanceID semantic (PR #221091)

Gregory Roth via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 8 10:58:50 PDT 2026


================
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fnative-half-type -fnative-int16-type -triple dxil-pc-shadermodel6.3-library -finclude-default-header -x hlsl -verify=dxil,expected -o - %s
+// RUN: %clang_cc1 -fnative-half-type -fnative-int16-type -triple spirv-pc-vulkan1.3-library -finclude-default-header -x hlsl -verify=spirv,expected -o - %s
+
+float bad_type_float(float id : SV_InstanceID) : A {
+// expected-error at -1 {{attribute 'SV_InstanceID' only applies to a field or parameter of type 'uint'}}
+  return id;
+}
+
+uint3 bad_type_vector(uint3 id : SV_InstanceID) : A {
+// expected-error at -1 {{attribute 'SV_InstanceID' only applies to a field or parameter of type 'uint'}}
+  return id;
+}
+
+int bad_type_signed(int id : SV_InstanceID) : A {
+// expected-error at -1 {{attribute 'SV_InstanceID' only applies to a field or parameter of type 'uint'}}
+  return id;
+}
+
+uint64_t bad_type_u64(uint64_t id : SV_InstanceID) : A {
+// expected-error at -1 {{attribute 'SV_InstanceID' only applies to a field or parameter of type 'uint'}}
+  return id;
+}
+
+char bad_type_char(char id : SV_InstanceID) : A {
+// expected-error at -1 {{attribute 'SV_InstanceID' only applies to a field or parameter of type 'uint'}}
+  return id;
+}
+
+uint32_t ok_u32(uint32_t id : SV_InstanceID) : A {
+  return id;
+}
+
+// DXIL permits U16, SPIRV rejects it: VUID-InstanceIndex-InstanceIndex-04265
+// requires a scalar 32-bit integer.
----------------
pow2clk wrote:

disregard

https://github.com/llvm/llvm-project/pull/221091


More information about the cfe-commits mailing list