Skip to content

Commit f0b9914

Browse files
authored
Enable WGSL tests that works for Metal related to Semantics (#5816)
* Enable WGSP tests that works for Metal related to Semantics This commit enables existing tests for WGSL that are enabled for Metal regarding the Semantics.
1 parent 4a63e33 commit f0b9914

7 files changed

+103
-66
lines changed

tests/metal/nested-struct-fragment-input.slang

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
2-
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
32
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain
3+
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
4+
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm -stage fragment -entry fragmentMain
45

56
// METAL: COARSEVERTEX_7
67
// METAL: COARSEVERTEX_6
@@ -21,7 +22,19 @@
2122
// METAL-NOT: [[ATTR3]]
2223
// METAL-DAG: [[ATTR4:COARSEVERTEX_(1|2|3|4)]]
2324

25+
// WGSL:struct FragmentStageInput
26+
// WGSL-DAG:@location(0) [[VAR0:[A-Za-z_0-9]+]]
27+
// WGSL-DAG:@location(1) [[VAR1:[A-Za-z_0-9]+]]
28+
// WGSL-DAG:@location(2) [[VAR2:[A-Za-z_0-9]+]]
29+
// WGSL-DAG:@location(3) [[VAR3:[A-Za-z_0-9]+]]
30+
// WGSL-DAG:@location(4) [[VAR4:[A-Za-z_0-9]+]]
31+
// WGSL-DAG:@location(6) [[VAR6:[A-Za-z_0-9]+]]
32+
// WGSL-DAG:@location(7) [[VAR7:[A-Za-z_0-9]+]]
33+
// WGSL-NOT:@location(8)
34+
// WGSL:}
35+
2436
// METALLIB: @fragmentMain
37+
// WGSLSPIRV: %fragmentMain = OpFunction %void None
2538

2639
RWStructuredBuffer<float> outputBuffer;
2740

@@ -52,6 +65,7 @@ struct FragmentStageInput
5265
TopFragment coarseVertex : CoarseVertex;
5366
};
5467

68+
// WGSL: fn fragmentMain{{[( ]*}}[[InputVar:[A-Za-z_0-9]+]]
5569
float4 fragmentMain(FragmentStageInput input)
5670
{
5771
// METAL-DAG: {{.*}}->p1{{.*}}=
@@ -64,15 +78,16 @@ float4 fragmentMain(FragmentStageInput input)
6478
// METAL-DAG: {{.*}}->p3{{.*}}->p2{{.*}}->p1{{.*}}=
6579
// METAL-DAG: {{.*}}->p3{{.*}}->p3{{.*}}->p1{{.*}}=
6680

67-
// WGSL-DAG: {{.*}}._S{{.*}}=
81+
// WGSL: var [[UnpackedInput:[A-Za-z_0-9]+]] : FragmentStageInput
82+
// WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR7]];
6883

69-
// WGSL-DAG: {{.*}}.p2{{.*}}._S{{.*}}=
70-
// WGSL-DAG: {{.*}}.p2{{.*}}.p2{{.*}}._S{{.*}}=
71-
// WGSL-DAG: {{.*}}.p2{{.*}}.p3{{.*}}._S{{.*}}=
84+
// WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR6]];
85+
// WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR1]];
86+
// WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR2]];
7287

73-
// WGSL-DAG: {{.*}}.p3{{.*}}._S{{.*}}=
74-
// WGSL-DAG: {{.*}}.p3{{.*}}.p2{{.*}}._S{{.*}}=
75-
// WGSL-DAG: {{.*}}.p3{{.*}}.p3{{.*}}._S{{.*}}=
88+
// WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR0]];
89+
// WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR3]];
90+
// WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR4]];
7691

7792
outputBuffer[0] = input.coarseVertex.p1 + input.coarseVertex.p2.p1 + +input.coarseVertex.p3.p1;
7893
return float4(0, 0, 0, 0);

tests/metal/nested-struct-fragment-output.slang

+24-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
2-
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
32
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain
3+
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
4+
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm -stage fragment -entry fragmentMain
45

56
//METAL-DAG: color(0)
67
//METAL-DAG: color(1)
@@ -11,16 +12,17 @@
1112
//METAL-DAG: color(6)
1213
//METAL-NOT: color(7)
1314

14-
//WGSL-DAG: location(0)
15-
//WGSL-DAG: location(1)
16-
//WGSL-DAG: location(2)
17-
//WGSL-DAG: location(3)
18-
//WGSL-DAG: location(4)
19-
//WGSL-DAG: location(5)
20-
//WGSL-DAG: location(6)
21-
//WGSL-NOT: location(7)
15+
//WGSL-DAG:@location(0) [[VAR0:[A-Za-z_0-9]+]]
16+
//WGSL-DAG:@location(1) [[VAR1:[A-Za-z_0-9]+]]
17+
//WGSL-DAG:@location(2) [[VAR2:[A-Za-z_0-9]+]]
18+
//WGSL-DAG:@location(3) [[VAR3:[A-Za-z_0-9]+]]
19+
//WGSL-DAG:@location(4) [[VAR4:[A-Za-z_0-9]+]]
20+
//WGSL-DAG:@location(5) [[VAR5:[A-Za-z_0-9]+]]
21+
//WGSL-DAG:@location(6) [[VAR6:[A-Za-z_0-9]+]]
22+
//WGSL-NOT:@location(7)
2223

2324
//METALLIB: @fragmentMain
25+
//WGSLSPIRV: %fragmentMain = OpFunction %void None
2426

2527
RWStructuredBuffer<float> outputBuffer;
2628

@@ -41,7 +43,7 @@ struct MiddleFragment1
4143
};
4244
struct TopFragment
4345
{
44-
float p1;
46+
float p1;
4547
MiddleFragment1 p2;
4648
MiddleFragment1 p3;
4749
};
@@ -56,6 +58,7 @@ struct FragmentStageOutput
5658
TopFragment fragment : SV_Target;
5759
};
5860

61+
//WGSL: fn fragmentMain{{.*}}-> [[ReturnType:FragmentStageOutput[_0-9]+]]
5962
FragmentStageOutput fragmentMain(FragmentStageInput input)
6063
{
6164
FragmentStageOutput output;
@@ -79,16 +82,15 @@ FragmentStageOutput fragmentMain(FragmentStageInput input)
7982
// METAL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}.p1
8083
// METAL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}.p1
8184

82-
// WGSL-DAG: ={{.*}}._S{{.*}}
83-
84-
// WGSL-DAG: ={{.*}}.p2{{.*}}._S{{.*}}
85-
// WGSL-DAG: ={{.*}}.p2{{.*}}.p2{{.*}}._S{{.*}}
86-
// WGSL-DAG: ={{.*}}.p2{{.*}}.p3{{.*}}._S{{.*}}
87-
88-
// WGSL-DAG: ={{.*}}.p3{{.*}}._S{{.*}}
89-
// WGSL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}._S{{.*}}
90-
// WGSL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}._S{{.*}}
91-
92-
outputBuffer[0] = 1;
93-
return output;
85+
// WGSL: var [[ReturnVar:[A-Za-z_0-9]+]] : [[ReturnType]]
86+
// WGSL-DAG: [[ReturnVar]].[[VAR0]]{{.*}} = {{.*}};
87+
// WGSL-DAG: [[ReturnVar]].[[VAR1]]{{.*}} = {{.*}};
88+
// WGSL-DAG: [[ReturnVar]].[[VAR2]]{{.*}} = {{.*}};
89+
// WGSL-DAG: [[ReturnVar]].[[VAR3]]{{.*}} = {{.*}};
90+
// WGSL-DAG: [[ReturnVar]].[[VAR4]]{{.*}} = {{.*}};
91+
// WGSL-DAG: [[ReturnVar]].[[VAR5]]{{.*}} = {{.*}};
92+
// WGSL-DAG: [[ReturnVar]].[[VAR6]]{{.*}} = {{.*}};
93+
94+
outputBuffer[0] = 1;
95+
return output;
9496
}

tests/metal/nested-struct-multi-entry-point-vertex.slang

+15-10
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,33 @@
22
//TEST:SIMPLE(filecheck=METALLIB1): -target metallib -stage vertex -entry vertexMain1
33
//TEST:SIMPLE(filecheck=METAL2): -target metal -stage vertex -entry vertexMain2
44
//TEST:SIMPLE(filecheck=METALLIB2): -target metallib -stage vertex -entry vertexMain2
5+
56
//TEST:SIMPLE(filecheck=WGSL1): -target wgsl -stage vertex -entry vertexMain1
67
//TEST:SIMPLE(filecheck=WGSL2): -target wgsl -stage vertex -entry vertexMain2
8+
//TEST:SIMPLE(filecheck=WGSLSPIRV1): -target wgsl-spirv-asm -stage vertex -entry vertexMain1
9+
//TEST:SIMPLE(filecheck=WGSLSPIRV2): -target wgsl-spirv-asm -stage vertex -entry vertexMain2
710

811
//METALLIB1: @vertexMain1
912
//METAL1-DAG: attribute(0)
1013
//METAL1-DAG: attribute(1)
1114
//METAL1-NOT: attribute(2)
1215

13-
//WGSL1-DAG: fn vertexMain1
14-
//WGSL1-DAG: location(0)
15-
//WGSL1-DAG: location(1)
16-
//WGSL1-NOT: location(2)
17-
1816
//METALLIB2: @vertexMain2
1917
//METAL2-DAG: attribute(0)
2018
//METAL2-DAG: attribute(1)
2119
//METAL2-DAG: attribute(2)
22-
23-
//WGSL2-DAG: fn vertexMain2
24-
//WGSL2-DAG: location(0)
25-
//WGSL2-DAG: location(1)
26-
//WGSL2-DAG: location(2)
20+
//METAL2-NOT: attribute(3)
21+
22+
//WGSLSPIRV1: %vertexMain1 = OpFunction %void None
23+
//WGSL1-DAG: @location(0) position
24+
//WGSL1-DAG: @location(1) color
25+
//WGSL1-NOT: @location(2)
26+
27+
//WGSLSPIRV2: %vertexMain2 = OpFunction %void None
28+
//WGSL2-DAG: @location(0) uv
29+
//WGSL2-DAG: @location(1) position
30+
//WGSL2-DAG: @location(2) color
31+
//WGSL2-NOT: @location(3)
2732

2833
struct SharedStruct
2934
{
+4-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
//TEST:SIMPLE(filecheck=METAL): -target metallib -stage vertex -entry vertexMain
22
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage vertex -entry vertexMain
33
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage vertex -entry vertexMain
4+
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm -stage vertex -entry vertexMain
45

56
//METAL-DAG: position
67
//METALLIB: @vertexMain
78

8-
//WGSL-DAG: @builtin(position)
9-
//WGSL-DAG: @vertex
9+
//WGSL: @builtin(position)
10+
//WGSLSPIRV: %vertexMain = OpFunction
1011

1112
// Vertex Shader
1213

1314
float4 vertexMain()
1415
{
15-
return float4(1,1,1,1);
16+
return float4(1,1,1,1);
1617
}

tests/metal/stage-in-2.slang

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
//TEST:SIMPLE(filecheck=CHECK): -target metal
2-
//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
1+
//TEST:SIMPLE(filecheck=METAL): -target metal
2+
//TEST:SIMPLE(filecheck=METAL_ASM): -target metallib
3+
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain
4+
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm
35

4-
// CHECK-ASM: define {{.*}} @vertexMain
5-
// CHECK-ASM: define {{.*}} @fragmentMain
6+
// METAL_ASM: define {{.*}} @vertexMain
7+
// METAL_ASM: define {{.*}} @fragmentMain
68

79
// Check that we don't flatten stage-input parameters that have user semantics.
810

9-
// CHECK: struct pixelInput
10-
// CHECK-NEXT: {
11-
// CHECK-NEXT: {{\[\[}}user(COARSEVERTEX){{\]\]}};
11+
// METAL: struct pixelInput
12+
// METAL-NEXT: {
13+
// METAL-NEXT: {{\[\[}}user(COARSEVERTEX){{\]\]}};
14+
15+
//WGSLSPIRV: %vertexMain = OpFunction %
16+
//WGSLSPIRV: %fragmentMain = OpFunction %
17+
18+
//WGSL: struct [[CoarseVertex:CoarseVertex[_0-9]*]]
19+
//WGSL-NEXT: {
20+
//WGSL-NEXT: @location(0) color
21+
//WGSL: fn fragmentMain({{.*}}[[CoarseVertex]]
1222

1323
// Uniform data to be passed from application -> shader.
1424
cbuffer Uniforms
@@ -67,4 +77,4 @@ float4 fragmentMain(
6777
float3 color = coarseVertex.color;
6878

6979
return float4(color, 1.0);
70-
}
80+
}

tests/metal/sv_target-complex-1.slang

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//TEST:SIMPLE(filecheck=METAL): -target metal
2-
//TEST:SIMPLE(filecheck=METAL-ASM): -target metallib
3-
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry fragmentMain -stage fragment
2+
//TEST:SIMPLE(filecheck=METAL_ASM): -target metallib
3+
//TEST:SIMPLE(filecheck=WGSL): -target wgsl
4+
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm
45

56
struct NestedReturn
67
{
@@ -21,18 +22,19 @@ struct Output
2122
NestedReturn2 debug2 : SV_TaRget3;
2223
}
2324

24-
// METAL-ASM: define {{.*}} @fragmentMain
25+
// METAL_ASM: define {{.*}} @fragmentMain
2526
// METAL: color(0)
2627
// METAL-DAG: color(1)
2728
// METAL-DAG: color(2)
2829
// METAL-DAG: color(3)
2930
// METAL-DAG: color(4)
3031

31-
// WGSL: location(0)
32-
// WGSL-DAG: location(1)
33-
// WGSL-DAG: location(2)
34-
// WGSL-DAG: location(3)
35-
// WGSL-DAG: location(4)
32+
// WGSLSPIRV: %fragmentMain = OpFunction
33+
// WGSL: @location(0) Diffuse
34+
// WGSL: @location(1) debug
35+
// WGSL: @location(2) Material
36+
// WGSL: @location(3) debugAux1
37+
// WGSL: @location(4) debugAux2
3638

3739
[shader("fragment")]
3840
Output fragmentMain()

tests/metal/sv_target-complex-2.slang

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//TEST:SIMPLE(filecheck=METAL): -target metal
2-
//TEST:SIMPLE(filecheck=METAL-ASM): -target metallib
3-
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry fragmentMain -stage fragment
2+
//TEST:SIMPLE(filecheck=METAL_ASM): -target metallib
3+
//TEST:SIMPLE(filecheck=WGSL): -target wgsl
4+
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm
45

56
struct NestedReturn
67
{
@@ -15,16 +16,17 @@ struct Output
1516
float4 Material : SV_Target2;
1617
}
1718

18-
// METAL-ASM: define {{.*}} @fragmentMain
19+
// METAL_ASM: define {{.*}} @fragmentMain
1920
// METAL: color(0)
2021
// METAL: color(1)
2122
// METAL-DAG: color(3)
2223
// METAL-DAG: color(2)
2324

24-
// WGSL-DAG: location(0)
25-
// WGSL-DAG: location(1)
26-
// WGSL-DAG: location(3)
27-
// WGSL-DAG: location(2)
25+
// WGSLSPIRV: %fragmentMain = OpFunction
26+
// WGSL: @location(0) Diffuse
27+
// WGSL: @location(1) debug1
28+
// WGSL-DAG: @location(3) debug2
29+
// WGSL-DAG: @location(2) Material
2830

2931
[shader("fragment")]
3032
Output fragmentMain()

0 commit comments

Comments
 (0)