summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-06-11 00:01:12 -0700
committerGitHub <noreply@github.com>2024-06-11 00:01:12 -0700
commit6d5ef9b650a9db35f7774ca09d9225d0c30849e4 (patch)
treed8f812a52d937709efa23b17c1e36c51ee1b66f4 /tests
parent21bbebb19dfdbbee107b9fd9830e18d5fb6a573a (diff)
Fix `GetAttributeAtVertex` for spirv and glsl targets. (#4334)
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/get-vertex-attribute.slang13
-rw-r--r--tests/spirv/get-vertex-attribute.slang15
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/diagnostics/get-vertex-attribute.slang b/tests/diagnostics/get-vertex-attribute.slang
new file mode 100644
index 000000000..613a5a7c8
--- /dev/null
+++ b/tests/diagnostics/get-vertex-attribute.slang
@@ -0,0 +1,13 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+struct VertexOutput
+{
+ float color;
+}
+
+[shader("fragment")]
+float4 fsmain(VertexOutput vout) : SV_Target
+{
+ // CHECK: ([[# @LINE+1]]): error 39027
+ return GetAttributeAtVertex(vout.color, 0); // error: color must be decorated with `nointerpolation`.
+}
diff --git a/tests/spirv/get-vertex-attribute.slang b/tests/spirv/get-vertex-attribute.slang
new file mode 100644
index 000000000..655b7ad03
--- /dev/null
+++ b/tests/spirv/get-vertex-attribute.slang
@@ -0,0 +1,15 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-via-glsl
+
+// CHECK: OpDecorate %vout_vertexID{{.*}} PerVertexKHR
+
+struct VertexOutput
+{
+ nointerpolation int vertexID;
+}
+
+[shader("fragment")]
+float4 fsmain(VertexOutput vout) : SV_Target
+{
+ return GetAttributeAtVertex(vout.vertexID, 0);
+}