summaryrefslogtreecommitdiffstats
path: root/tests/metal
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-12-03 03:45:04 +0800
committerGitHub <noreply@github.com>2024-12-02 11:45:04 -0800
commit7aaf7009e2c6055a714ba4a93ab3dd73d2d2cdb7 (patch)
tree17fbc14b5d032951c0c5af0b444ff08dc389d77d /tests/metal
parent0586e5ab478f7cfb1763d019eb014f2578106240 (diff)
Varying inputs and outputs for wgsl (#5669)
Closes https://github.com/shader-slang/slang/issues/5067 New tests, covering what's declared supported in the WGSL support docs - tests/wgsl/semantic-coverage.slang - tests/wgsl/semantic-depth.slang - tests/wgsl/semantic-dispatch-thread-id.slang - tests/wgsl/semantic-group-id.slang - tests/wgsl/semantic-group-index.slang - tests/wgsl/semantic-group-thread-id.slang - tests/wgsl/semantic-instance-id.slang - tests/wgsl/semantic-is-front-face.slang - tests/wgsl/semantic-position.slang - tests/wgsl/semantic-sample-index.slang - tests/wgsl/semantic-vertex-id.slang WGSL enabled existing tests: - tests/compute/compile-time-loop.slang - tests/compute/constexpr.slang - tests/compute/discard-stmt.slang - tests/metal/nested-struct-fragment-input.slang - tests/metal/nested-struct-fragment-output.slang - tests/metal/nested-struct-multi-entry-point-vertex.slang - tests/metal/no-struct-vertex-output.slang - tests/metal/sv_target-complex-1.slang - tests/metal/sv_target-complex-2.slang - tests/bugs/texture2d-gather.hlsl - tests/render/cross-compile-entry-point.slang - tests/render/nointerpolation.hlsl - tests/render/render0.hlsl - tests/render/cross-compile0.hlsl - tests/render/imported-parameters.hlsl - tests/render/unused-discard.hlsl Can't be enabled due to missing wgsl features - tests/compute/texture-sampling.slang Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/metal')
-rw-r--r--tests/metal/nested-struct-fragment-input.slang11
-rw-r--r--tests/metal/nested-struct-fragment-output.slang20
-rw-r--r--tests/metal/nested-struct-multi-entry-point-vertex.slang14
-rw-r--r--tests/metal/no-struct-vertex-output.slang6
-rw-r--r--tests/metal/sv_target-complex-1.slang25
-rw-r--r--tests/metal/sv_target-complex-2.slang22
6 files changed, 79 insertions, 19 deletions
diff --git a/tests/metal/nested-struct-fragment-input.slang b/tests/metal/nested-struct-fragment-input.slang
index 727b5b1e5..a8c94e888 100644
--- a/tests/metal/nested-struct-fragment-input.slang
+++ b/tests/metal/nested-struct-fragment-input.slang
@@ -1,5 +1,6 @@
//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
+//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain
// METAL: COARSEVERTEX_7
// METAL: COARSEVERTEX_6
@@ -63,6 +64,16 @@ float4 fragmentMain(FragmentStageInput input)
// METAL-DAG: {{.*}}->p3{{.*}}->p2{{.*}}->p1{{.*}}=
// METAL-DAG: {{.*}}->p3{{.*}}->p3{{.*}}->p1{{.*}}=
+ // WGSL-DAG: {{.*}}._S{{.*}}=
+
+ // WGSL-DAG: {{.*}}.p2{{.*}}._S{{.*}}=
+ // WGSL-DAG: {{.*}}.p2{{.*}}.p2{{.*}}._S{{.*}}=
+ // WGSL-DAG: {{.*}}.p2{{.*}}.p3{{.*}}._S{{.*}}=
+
+ // WGSL-DAG: {{.*}}.p3{{.*}}._S{{.*}}=
+ // WGSL-DAG: {{.*}}.p3{{.*}}.p2{{.*}}._S{{.*}}=
+ // WGSL-DAG: {{.*}}.p3{{.*}}.p3{{.*}}._S{{.*}}=
+
outputBuffer[0] = input.coarseVertex.p1 + input.coarseVertex.p2.p1 + +input.coarseVertex.p3.p1;
return float4(0, 0, 0, 0);
}
diff --git a/tests/metal/nested-struct-fragment-output.slang b/tests/metal/nested-struct-fragment-output.slang
index 1d002c124..4b29f8430 100644
--- a/tests/metal/nested-struct-fragment-output.slang
+++ b/tests/metal/nested-struct-fragment-output.slang
@@ -1,5 +1,6 @@
//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
+//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain
//METAL-DAG: color(0)
//METAL-DAG: color(1)
@@ -10,6 +11,15 @@
//METAL-DAG: color(6)
//METAL-NOT: color(7)
+//WGSL-DAG: location(0)
+//WGSL-DAG: location(1)
+//WGSL-DAG: location(2)
+//WGSL-DAG: location(3)
+//WGSL-DAG: location(4)
+//WGSL-DAG: location(5)
+//WGSL-DAG: location(6)
+//WGSL-NOT: location(7)
+
//METALLIB: @fragmentMain
RWStructuredBuffer<float> outputBuffer;
@@ -69,6 +79,16 @@ FragmentStageOutput fragmentMain(FragmentStageInput input)
// METAL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}.p1
// METAL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}.p1
+ // WGSL-DAG: ={{.*}}._S{{.*}}
+
+ // WGSL-DAG: ={{.*}}.p2{{.*}}._S{{.*}}
+ // WGSL-DAG: ={{.*}}.p2{{.*}}.p2{{.*}}._S{{.*}}
+ // WGSL-DAG: ={{.*}}.p2{{.*}}.p3{{.*}}._S{{.*}}
+
+ // WGSL-DAG: ={{.*}}.p3{{.*}}._S{{.*}}
+ // WGSL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}._S{{.*}}
+ // WGSL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}._S{{.*}}
+
outputBuffer[0] = 1;
return output;
}
diff --git a/tests/metal/nested-struct-multi-entry-point-vertex.slang b/tests/metal/nested-struct-multi-entry-point-vertex.slang
index 779b66704..5d2b3b1e0 100644
--- a/tests/metal/nested-struct-multi-entry-point-vertex.slang
+++ b/tests/metal/nested-struct-multi-entry-point-vertex.slang
@@ -2,17 +2,29 @@
//TEST:SIMPLE(filecheck=METALLIB1): -target metallib -stage vertex -entry vertexMain1
//TEST:SIMPLE(filecheck=METAL2): -target metal -stage vertex -entry vertexMain2
//TEST:SIMPLE(filecheck=METALLIB2): -target metallib -stage vertex -entry vertexMain2
+//TEST:SIMPLE(filecheck=WGSL1): -target wgsl -stage vertex -entry vertexMain1
+//TEST:SIMPLE(filecheck=WGSL2): -target wgsl -stage vertex -entry vertexMain2
//METALLIB1: @vertexMain1
//METAL1-DAG: attribute(0)
//METAL1-DAG: attribute(1)
//METAL1-NOT: attribute(2)
+//WGSL1-DAG: fn vertexMain1
+//WGSL1-DAG: location(0)
+//WGSL1-DAG: location(1)
+//WGSL1-NOT: location(2)
+
//METALLIB2: @vertexMain2
//METAL2-DAG: attribute(0)
//METAL2-DAG: attribute(1)
//METAL2-DAG: attribute(2)
+//WGSL2-DAG: fn vertexMain2
+//WGSL2-DAG: location(0)
+//WGSL2-DAG: location(1)
+//WGSL2-DAG: location(2)
+
struct SharedStruct
{
float4 position;
@@ -42,4 +54,4 @@ struct VertexStageInput2
float4 vertexMain2(VertexStageInput2 vertex)
{
return vertex.assembledVertex.sharedData.position;
-} \ No newline at end of file
+}
diff --git a/tests/metal/no-struct-vertex-output.slang b/tests/metal/no-struct-vertex-output.slang
index f4988b685..ae8b9f845 100644
--- a/tests/metal/no-struct-vertex-output.slang
+++ b/tests/metal/no-struct-vertex-output.slang
@@ -1,12 +1,16 @@
//TEST:SIMPLE(filecheck=METAL): -target metallib -stage vertex -entry vertexMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage vertex -entry vertexMain
+//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage vertex -entry vertexMain
//METAL-DAG: position
//METALLIB: @vertexMain
+//WGSL-DAG: @builtin(position)
+//WGSL-DAG: @vertex
+
// Vertex Shader
float4 vertexMain()
{
return float4(1,1,1,1);
-} \ No newline at end of file
+}
diff --git a/tests/metal/sv_target-complex-1.slang b/tests/metal/sv_target-complex-1.slang
index a830ff3d2..1a479f4ff 100644
--- a/tests/metal/sv_target-complex-1.slang
+++ b/tests/metal/sv_target-complex-1.slang
@@ -1,5 +1,6 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METAL-ASM): -target metallib
+//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry fragmentMain -stage fragment
struct NestedReturn
{
@@ -20,15 +21,21 @@ struct Output
NestedReturn2 debug2 : SV_TaRget3;
}
-// CHECK-ASM: define {{.*}} @fragmentMain
-// CHECK: color(0)
-// CHECK-DAG: color(1)
-// CHECK-DAG: color(2)
-// CHECK-DAG: color(3)
-// CHECK-DAG: color(4)
+// METAL-ASM: define {{.*}} @fragmentMain
+// METAL: color(0)
+// METAL-DAG: color(1)
+// METAL-DAG: color(2)
+// METAL-DAG: color(3)
+// METAL-DAG: color(4)
+
+// WGSL: location(0)
+// WGSL-DAG: location(1)
+// WGSL-DAG: location(2)
+// WGSL-DAG: location(3)
+// WGSL-DAG: location(4)
[shader("fragment")]
Output fragmentMain()
{
return { float4(1), {float4(2)}, float4(3) };
-} \ No newline at end of file
+}
diff --git a/tests/metal/sv_target-complex-2.slang b/tests/metal/sv_target-complex-2.slang
index 9cc59cc5f..5f3d166d5 100644
--- a/tests/metal/sv_target-complex-2.slang
+++ b/tests/metal/sv_target-complex-2.slang
@@ -1,5 +1,6 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METAL-ASM): -target metallib
+//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry fragmentMain -stage fragment
struct NestedReturn
{
@@ -14,14 +15,19 @@ struct Output
float4 Material : SV_Target2;
}
-// CHECK-ASM: define {{.*}} @fragmentMain
-// CHECK: color(0)
-// CHECK: color(1)
-// CHECK-DAG: color(3)
-// CHECK-DAG: color(2)
+// METAL-ASM: define {{.*}} @fragmentMain
+// METAL: color(0)
+// METAL: color(1)
+// METAL-DAG: color(3)
+// METAL-DAG: color(2)
+
+// WGSL-DAG: location(0)
+// WGSL-DAG: location(1)
+// WGSL-DAG: location(3)
+// WGSL-DAG: location(2)
[shader("fragment")]
Output fragmentMain()
{
return { float4(1), {float4(2), float4(2)}, float4(3) };
-} \ No newline at end of file
+}