summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/compile-time-loop.slang2
-rw-r--r--tests/compute/constexpr.slang2
-rw-r--r--tests/compute/discard-stmt.slang2
-rw-r--r--tests/compute/texture-sampling.slang4
-rw-r--r--tests/metal/atomic-intrinsics.slang1
-rw-r--r--tests/metal/nested-struct-fragment-input.slang68
-rw-r--r--tests/metal/nested-struct-fragment-output.slang74
-rw-r--r--tests/metal/nested-struct-multi-entry-point-vertex.slang45
-rw-r--r--tests/metal/no-struct-vertex-output.slang12
-rw-r--r--tests/metal/stage-in-2.slang2
-rw-r--r--tests/metal/sv_target-complex-1.slang34
-rw-r--r--tests/metal/sv_target-complex-2.slang27
12 files changed, 267 insertions, 6 deletions
diff --git a/tests/compute/compile-time-loop.slang b/tests/compute/compile-time-loop.slang
index f69708e0c..9035bde2a 100644
--- a/tests/compute/compile-time-loop.slang
+++ b/tests/compute/compile-time-loop.slang
@@ -1,5 +1,5 @@
//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
+//TEST(compute):COMPARE_RENDER_COMPUTE: -mtl -shaderobj
//TEST_INPUT: Texture2D(size=4, content = one):name t
//TEST_INPUT: Sampler:name s
diff --git a/tests/compute/constexpr.slang b/tests/compute/constexpr.slang
index 9aa5c1d56..9c7c9d131 100644
--- a/tests/compute/constexpr.slang
+++ b/tests/compute/constexpr.slang
@@ -1,7 +1,7 @@
// constexpr.slang
//TEST(compute):COMPARE_COMPUTE_EX:-slang -gcompute -shaderobj
//DISABLED://TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -gcompute -shaderobj
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
+//TEST(compute):COMPARE_COMPUTE_EX:-mtl -gcompute -shaderobj
//TEST_INPUT: Texture2D(size=4, content = one):name tex
//TEST_INPUT: Sampler:name samp
diff --git a/tests/compute/discard-stmt.slang b/tests/compute/discard-stmt.slang
index 90a81c0ff..fa00c9ec3 100644
--- a/tests/compute/discard-stmt.slang
+++ b/tests/compute/discard-stmt.slang
@@ -1,5 +1,5 @@
//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
+//TEST(compute):COMPARE_RENDER_COMPUTE: -mtl -shaderobj
//TEST_INPUT: Texture2D(size=4, content = one):name tex
//TEST_INPUT: Sampler:name samp
//TEST_INPUT: ubuffer(data=[0 0], stride=4):out,name outputBuffer
diff --git a/tests/compute/texture-sampling.slang b/tests/compute/texture-sampling.slang
index 89041dafb..0e319680a 100644
--- a/tests/compute/texture-sampling.slang
+++ b/tests/compute/texture-sampling.slang
@@ -1,6 +1,6 @@
//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj -output-using-type
//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj -output-using-type -vk
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
+//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj -output-using-type -mtl
//TEST_INPUT: Texture1D(size=4, content = one):name=t1D
@@ -104,7 +104,7 @@ FragmentStageOutput fragmentMain(FragmentStageInput input)
val += tCubeArray.Sample(samplerState, float4(uv, 0.5, 0.0));
val += tCube.Sample(samplerState, float3(uv, 0.5));
- val += t2D.Load(int3(0), int2(0));
+ val += t2D.Load(int3(0));
val += t2dArray.Load(int4(0));
val += t3D[int3(0)];
diff --git a/tests/metal/atomic-intrinsics.slang b/tests/metal/atomic-intrinsics.slang
index 3533ea2aa..5d47db913 100644
--- a/tests/metal/atomic-intrinsics.slang
+++ b/tests/metal/atomic-intrinsics.slang
@@ -2,6 +2,7 @@
//TEST:SIMPLE(filecheck=LIB):-target metallib -entry computeMain -stage compute -DMETAL
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -dx12 -profile cs_6_0 -use-dxil -shaderobj -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-vk -emit-spirv-directly -compute -shaderobj -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-vk -emit-spirv-via-glsl -compute -shaderobj -output-using-type
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj -output-using-type
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type
diff --git a/tests/metal/nested-struct-fragment-input.slang b/tests/metal/nested-struct-fragment-input.slang
new file mode 100644
index 000000000..727b5b1e5
--- /dev/null
+++ b/tests/metal/nested-struct-fragment-input.slang
@@ -0,0 +1,68 @@
+//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
+
+// METAL: COARSEVERTEX_7
+// METAL: COARSEVERTEX_6
+
+// Ensure each attribute which may vary only appears once.
+// Ensure 1, 2, 3, 4 all appear
+
+// METAL-DAG: [[ATTR1:COARSEVERTEX_(1|2|3|4)]]
+
+// METAL-NOT: [[ATTR1]]
+// METAL-DAG: [[ATTR2:COARSEVERTEX_(1|2|3|4)]]
+
+// METAL: COARSEVERTEX{{(_0|())}}
+
+// METAL-NOT: [[ATTR2]]
+// METAL-DAG: [[ATTR3:COARSEVERTEX_(1|2|3|4)]]
+
+// METAL-NOT: [[ATTR3]]
+// METAL-DAG: [[ATTR4:COARSEVERTEX_(1|2|3|4)]]
+
+// METALLIB: @fragmentMain
+
+RWStructuredBuffer<float> outputBuffer;
+
+struct BottomFragment1
+{
+ float p1;
+};
+struct BottomFragment2
+{
+ float p1;
+};
+
+struct MiddleFragment1
+{
+ float p1;
+ BottomFragment1 p2;
+ BottomFragment2 p3;
+};
+struct TopFragment
+{
+ float p1 : CoarseVertex7;
+ MiddleFragment1 p2 : CoarseVertex6;
+ MiddleFragment1 p3 : CoarseVertex0;
+};
+
+struct FragmentStageInput
+{
+ TopFragment coarseVertex : CoarseVertex;
+};
+
+float4 fragmentMain(FragmentStageInput input)
+{
+ // METAL-DAG: {{.*}}->p1{{.*}}=
+
+ // METAL-DAG: {{.*}}->p2{{.*}}->p1{{.*}}=
+ // METAL-DAG: {{.*}}->p2{{.*}}->p2{{.*}}->p1{{.*}}=
+ // METAL-DAG: {{.*}}->p2{{.*}}->p3{{.*}}->p1{{.*}}=
+
+ // METAL-DAG: {{.*}}->p3{{.*}}->p1{{.*}}=
+ // METAL-DAG: {{.*}}->p3{{.*}}->p2{{.*}}->p1{{.*}}=
+ // METAL-DAG: {{.*}}->p3{{.*}}->p3{{.*}}->p1{{.*}}=
+
+ 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
new file mode 100644
index 000000000..1d002c124
--- /dev/null
+++ b/tests/metal/nested-struct-fragment-output.slang
@@ -0,0 +1,74 @@
+//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
+
+//METAL-DAG: color(0)
+//METAL-DAG: color(1)
+//METAL-DAG: color(2)
+//METAL-DAG: color(3)
+//METAL-DAG: color(4)
+//METAL-DAG: color(5)
+//METAL-DAG: color(6)
+//METAL-NOT: color(7)
+
+//METALLIB: @fragmentMain
+
+RWStructuredBuffer<float> outputBuffer;
+
+struct BottomFragment1
+{
+ float p1;
+};
+struct BottomFragment2
+{
+ float p1;
+};
+
+struct MiddleFragment1
+{
+ float p1;
+ BottomFragment1 p2;
+ BottomFragment2 p3;
+};
+struct TopFragment
+{
+ float p1;
+ MiddleFragment1 p2;
+ MiddleFragment1 p3;
+};
+
+struct FragmentStageInput
+{
+ float4 coarseVertex : CoarseVertex;
+};
+
+struct FragmentStageOutput
+{
+ TopFragment fragment : SV_Target;
+};
+
+FragmentStageOutput fragmentMain(FragmentStageInput input)
+{
+ FragmentStageOutput output;
+ output.fragment.p1 = 1;
+
+ output.fragment.p2.p1 = 3;
+ output.fragment.p2.p2.p1 = 4;
+ output.fragment.p2.p3.p1 = 5;
+
+ output.fragment.p3.p1 = 8;
+ output.fragment.p3.p2.p1 = 9;
+ output.fragment.p3.p3.p1 = 10;
+
+ // METAL-DAG: ={{.*}}.p1
+
+ // METAL-DAG: ={{.*}}.p2{{.*}}.p1
+ // METAL-DAG: ={{.*}}.p2{{.*}}.p2{{.*}}.p1
+ // METAL-DAG: ={{.*}}.p2{{.*}}.p3{{.*}}.p1
+
+ // METAL-DAG: ={{.*}}.p3{{.*}}.p1
+ // METAL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}.p1
+ // METAL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}.p1
+
+ 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
new file mode 100644
index 000000000..779b66704
--- /dev/null
+++ b/tests/metal/nested-struct-multi-entry-point-vertex.slang
@@ -0,0 +1,45 @@
+//TEST:SIMPLE(filecheck=METAL1): -target metal -stage vertex -entry vertexMain1
+//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
+
+//METALLIB1: @vertexMain1
+//METAL1-DAG: attribute(0)
+//METAL1-DAG: attribute(1)
+//METAL1-NOT: attribute(2)
+
+//METALLIB2: @vertexMain2
+//METAL2-DAG: attribute(0)
+//METAL2-DAG: attribute(1)
+//METAL2-DAG: attribute(2)
+
+struct SharedStruct
+{
+ float4 position;
+ float4 color;
+};
+
+struct VertexStageInput
+{
+ SharedStruct assembledVertex : CoarseVertex;
+};
+
+float4 vertexMain1(VertexStageInput vertex)
+{
+ return vertex.assembledVertex.position;
+}
+
+struct sharedStructWrapper
+{
+ float2 uv;
+ SharedStruct sharedData;
+};
+struct VertexStageInput2
+{
+ sharedStructWrapper assembledVertex : CoarseVertex;
+};
+
+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
new file mode 100644
index 000000000..f4988b685
--- /dev/null
+++ b/tests/metal/no-struct-vertex-output.slang
@@ -0,0 +1,12 @@
+//TEST:SIMPLE(filecheck=METAL): -target metallib -stage vertex -entry vertexMain
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage vertex -entry vertexMain
+
+//METAL-DAG: position
+//METALLIB: @vertexMain
+
+// Vertex Shader
+
+float4 vertexMain()
+{
+ return float4(1,1,1,1);
+} \ No newline at end of file
diff --git a/tests/metal/stage-in-2.slang b/tests/metal/stage-in-2.slang
index 2b1e61306..5bdf3f3eb 100644
--- a/tests/metal/stage-in-2.slang
+++ b/tests/metal/stage-in-2.slang
@@ -8,7 +8,7 @@
// CHECK: struct pixelInput
// CHECK-NEXT: {
-// CHECK-NEXT: CoarseVertex{{.*}} coarseVertex{{.*}} {{\[\[}}user(COARSEVERTEX){{\]\]}};
+// CHECK-NEXT: {{\[\[}}user(COARSEVERTEX){{\]\]}};
// Uniform data to be passed from application -> shader.
cbuffer Uniforms
diff --git a/tests/metal/sv_target-complex-1.slang b/tests/metal/sv_target-complex-1.slang
new file mode 100644
index 000000000..a830ff3d2
--- /dev/null
+++ b/tests/metal/sv_target-complex-1.slang
@@ -0,0 +1,34 @@
+//TEST:SIMPLE(filecheck=CHECK): -target metal
+//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+
+struct NestedReturn
+{
+ float4 debug;
+};
+struct NestedReturn2
+{
+ float4 debugAux1;
+ float4 debugAux2;
+};
+
+// Semantics are supposed to ignore uppercase/lowercase differences
+struct Output
+{
+ float4 Diffuse : SV_TarGet0;
+ NestedReturn debug1 : SV_Target1;
+ float4 Material : SV_TArgeT2;
+ 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)
+
+[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
new file mode 100644
index 000000000..9cc59cc5f
--- /dev/null
+++ b/tests/metal/sv_target-complex-2.slang
@@ -0,0 +1,27 @@
+//TEST:SIMPLE(filecheck=CHECK): -target metal
+//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+
+struct NestedReturn
+{
+ float4 debug1;
+ float4 debug2;
+};
+
+struct Output
+{
+ float4 Diffuse : SV_Target0;
+ NestedReturn val : SV_Target1;
+ float4 Material : SV_Target2;
+}
+
+// CHECK-ASM: define {{.*}} @fragmentMain
+// CHECK: color(0)
+// CHECK: color(1)
+// CHECK-DAG: color(3)
+// CHECK-DAG: color(2)
+
+[shader("fragment")]
+Output fragmentMain()
+{
+ return { float4(1), {float4(2), float4(2)}, float4(3) };
+} \ No newline at end of file