summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-06-10 12:32:17 -0700
committerGitHub <noreply@github.com>2024-06-10 12:32:17 -0700
commit38c0baccac70ca36a2c90218d6a92b8c036b1a5e (patch)
tree0bc29bad69dc988777e1275b707c1d92737dcd7f /tests
parentb5cdd8322bd51603c217dfb7662306628b144c78 (diff)
Fix SPIRV emit for `Flat` decoration and TessLevel builtin. (#4318)
Diffstat (limited to 'tests')
-rw-r--r--tests/spirv/flat.slang27
-rw-r--r--tests/spirv/tess-factor.slang32
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/spirv/flat.slang b/tests/spirv/flat.slang
new file mode 100644
index 000000000..660f61216
--- /dev/null
+++ b/tests/spirv/flat.slang
@@ -0,0 +1,27 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// Check that we don't emit duplicate Flat decorations for the same variable.
+
+// CHECK: OpDecorate %vo_a Flat
+// CHECK-NOT: OpDecorate %vo_a Flat
+
+struct VertexOutput
+{
+ nointerpolation int a : SOME_VALUE;
+ float4 b : SV_Position;
+};
+
+[shader("vertex")]
+VertexOutput Vertex()
+{
+ VertexOutput out;
+ out.a = 0;
+ out.b = float4(0, 0, 0, 1);
+ return out;
+}
+
+[shader("fragment")]
+float4 Fragment(in VertexOutput vo)
+{
+ return float4(float(vo.a), 0, 0, 1);
+} \ No newline at end of file
diff --git a/tests/spirv/tess-factor.slang b/tests/spirv/tess-factor.slang
new file mode 100644
index 000000000..ce6c6acea
--- /dev/null
+++ b/tests/spirv/tess-factor.slang
@@ -0,0 +1,32 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage domain
+
+// CHECK: TessLevelInner
+
+struct HS_CONTROL_POINT_OUTPUT
+{
+ float4 Position : POSITION;
+ float2 TexCoord : TEXCOORD;
+};
+
+struct HS_CONSTANT_DATA_OUTPUT
+{
+ float EdgeTessFactor[4] : SV_TessFactor;
+ float InsideTessFactor[2] : SV_InsideTessFactor;
+};
+
+
+struct DS_OUTPUT
+{
+ float4 Position : SV_Position;
+ float2 TexCoord : TEXCOORD;
+};
+
+// Domain Shader (DS)
+[domain("quad")]
+DS_OUTPUT main(HS_CONSTANT_DATA_OUTPUT input, const OutputPatch<HS_CONTROL_POINT_OUTPUT, 4> patch, float2 uv : SV_DomainLocation)
+{
+ DS_OUTPUT output;
+ output.Position = input.EdgeTessFactor[0];
+ output.TexCoord = input.InsideTessFactor[0];
+ return output;
+} \ No newline at end of file