Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable WGSL tests that works for Metal related to Semantics #5816

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions tests/metal/nested-struct-fragment-input.slang
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//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
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm -stage fragment -entry fragmentMain

// METAL: COARSEVERTEX_7
// METAL: COARSEVERTEX_6
Expand All @@ -21,7 +22,19 @@
// METAL-NOT: [[ATTR3]]
// METAL-DAG: [[ATTR4:COARSEVERTEX_(1|2|3|4)]]

// WGSL:struct FragmentStageInput
// WGSL-DAG:@location(0) [[VAR0:[A-Za-z_0-9]+]]
// WGSL-DAG:@location(1) [[VAR1:[A-Za-z_0-9]+]]
// WGSL-DAG:@location(2) [[VAR2:[A-Za-z_0-9]+]]
// WGSL-DAG:@location(3) [[VAR3:[A-Za-z_0-9]+]]
// WGSL-DAG:@location(4) [[VAR4:[A-Za-z_0-9]+]]
// WGSL-DAG:@location(6) [[VAR6:[A-Za-z_0-9]+]]
// WGSL-DAG:@location(7) [[VAR7:[A-Za-z_0-9]+]]
// WGSL-NOT:@location(8)
// WGSL:}

// METALLIB: @fragmentMain
// WGSLSPIRV: %fragmentMain = OpFunction %void None

RWStructuredBuffer<float> outputBuffer;

Expand Down Expand Up @@ -52,6 +65,7 @@ struct FragmentStageInput
TopFragment coarseVertex : CoarseVertex;
};

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

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

// WGSL-DAG: {{.*}}.p2{{.*}}._S{{.*}}=
// WGSL-DAG: {{.*}}.p2{{.*}}.p2{{.*}}._S{{.*}}=
// WGSL-DAG: {{.*}}.p2{{.*}}.p3{{.*}}._S{{.*}}=
// WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR6]];
// 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]];
// 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]];

// WGSL-DAG: {{.*}}.p3{{.*}}._S{{.*}}=
// WGSL-DAG: {{.*}}.p3{{.*}}.p2{{.*}}._S{{.*}}=
// WGSL-DAG: {{.*}}.p3{{.*}}.p3{{.*}}._S{{.*}}=
// WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR0]];
// 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]];
// 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]];

outputBuffer[0] = input.coarseVertex.p1 + input.coarseVertex.p2.p1 + +input.coarseVertex.p3.p1;
return float4(0, 0, 0, 0);
Expand Down
46 changes: 24 additions & 22 deletions tests/metal/nested-struct-fragment-output.slang
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//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
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm -stage fragment -entry fragmentMain

//METAL-DAG: color(0)
//METAL-DAG: color(1)
Expand All @@ -11,16 +12,17 @@
//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)
//WGSL-DAG:@location(0) [[VAR0:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(1) [[VAR1:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(2) [[VAR2:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(3) [[VAR3:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(4) [[VAR4:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(5) [[VAR5:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(6) [[VAR6:[A-Za-z_0-9]+]]
//WGSL-NOT:@location(7)

//METALLIB: @fragmentMain
//WGSLSPIRV: %fragmentMain = OpFunction %void None

RWStructuredBuffer<float> outputBuffer;

Expand All @@ -41,7 +43,7 @@ struct MiddleFragment1
};
struct TopFragment
{
float p1;
float p1;
MiddleFragment1 p2;
MiddleFragment1 p3;
};
Expand All @@ -56,6 +58,7 @@ struct FragmentStageOutput
TopFragment fragment : SV_Target;
};

//WGSL: fn fragmentMain{{.*}}-> [[ReturnType:FragmentStageOutput[_0-9]+]]
FragmentStageOutput fragmentMain(FragmentStageInput input)
{
FragmentStageOutput output;
Expand All @@ -79,16 +82,15 @@ 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;
// WGSL: var [[ReturnVar:[A-Za-z_0-9]+]] : [[ReturnType]]
// WGSL-DAG: [[ReturnVar]].[[VAR0]]{{.*}} = {{.*}};
// WGSL-DAG: [[ReturnVar]].[[VAR1]]{{.*}} = {{.*}};
// WGSL-DAG: [[ReturnVar]].[[VAR2]]{{.*}} = {{.*}};
// WGSL-DAG: [[ReturnVar]].[[VAR3]]{{.*}} = {{.*}};
// WGSL-DAG: [[ReturnVar]].[[VAR4]]{{.*}} = {{.*}};
// WGSL-DAG: [[ReturnVar]].[[VAR5]]{{.*}} = {{.*}};
// WGSL-DAG: [[ReturnVar]].[[VAR6]]{{.*}} = {{.*}};

outputBuffer[0] = 1;
return output;
}
25 changes: 15 additions & 10 deletions tests/metal/nested-struct-multi-entry-point-vertex.slang
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,33 @@
//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
//TEST:SIMPLE(filecheck=WGSLSPIRV1): -target wgsl-spirv-asm -stage vertex -entry vertexMain1
//TEST:SIMPLE(filecheck=WGSLSPIRV2): -target wgsl-spirv-asm -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)
//METAL2-NOT: attribute(3)

//WGSLSPIRV1: %vertexMain1 = OpFunction %void None
//WGSL1-DAG: @location(0) position
//WGSL1-DAG: @location(1) color
//WGSL1-NOT: @location(2)

//WGSLSPIRV2: %vertexMain2 = OpFunction %void None
//WGSL2-DAG: @location(0) uv
//WGSL2-DAG: @location(1) position
//WGSL2-DAG: @location(2) color
//WGSL2-NOT: @location(3)

struct SharedStruct
{
Expand Down
7 changes: 4 additions & 3 deletions tests/metal/no-struct-vertex-output.slang
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
//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
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm -stage vertex -entry vertexMain

//METAL-DAG: position
//METALLIB: @vertexMain

//WGSL-DAG: @builtin(position)
//WGSL-DAG: @vertex
//WGSL: @builtin(position)
//WGSLSPIRV: %vertexMain = OpFunction

// Vertex Shader

float4 vertexMain()
{
return float4(1,1,1,1);
return float4(1,1,1,1);
}
26 changes: 18 additions & 8 deletions tests/metal/stage-in-2.slang
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
//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 -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm

// CHECK-ASM: define {{.*}} @vertexMain
// CHECK-ASM: define {{.*}} @fragmentMain
// METAL_ASM: define {{.*}} @vertexMain
// METAL_ASM: define {{.*}} @fragmentMain

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

// CHECK: struct pixelInput
// CHECK-NEXT: {
// CHECK-NEXT: {{\[\[}}user(COARSEVERTEX){{\]\]}};
// METAL: struct pixelInput
// METAL-NEXT: {
// METAL-NEXT: {{\[\[}}user(COARSEVERTEX){{\]\]}};

//WGSLSPIRV: %vertexMain = OpFunction %
//WGSLSPIRV: %fragmentMain = OpFunction %

//WGSL: struct [[CoarseVertex:CoarseVertex[_0-9]*]]
//WGSL-NEXT: {
//WGSL-NEXT: @location(0) color
//WGSL: fn fragmentMain({{.*}}[[CoarseVertex]]

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

return float4(color, 1.0);
}
}
18 changes: 10 additions & 8 deletions tests/metal/sv_target-complex-1.slang
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//TEST:SIMPLE(filecheck=METAL): -target metal
//TEST:SIMPLE(filecheck=METAL-ASM): -target metallib
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry fragmentMain -stage fragment
//TEST:SIMPLE(filecheck=METAL_ASM): -target metallib
//TEST:SIMPLE(filecheck=WGSL): -target wgsl
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm

struct NestedReturn
{
Expand All @@ -21,18 +22,19 @@ struct Output
NestedReturn2 debug2 : SV_TaRget3;
}

// METAL-ASM: define {{.*}} @fragmentMain
// 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)
// WGSLSPIRV: %fragmentMain = OpFunction
// WGSL: @location(0) Diffuse
// WGSL: @location(1) debug
// WGSL: @location(2) Material
// WGSL: @location(3) debugAux1
// WGSL: @location(4) debugAux2

[shader("fragment")]
Output fragmentMain()
Expand Down
16 changes: 9 additions & 7 deletions tests/metal/sv_target-complex-2.slang
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//TEST:SIMPLE(filecheck=METAL): -target metal
//TEST:SIMPLE(filecheck=METAL-ASM): -target metallib
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry fragmentMain -stage fragment
//TEST:SIMPLE(filecheck=METAL_ASM): -target metallib
//TEST:SIMPLE(filecheck=WGSL): -target wgsl
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm

struct NestedReturn
{
Expand All @@ -15,16 +16,17 @@ struct Output
float4 Material : SV_Target2;
}

// METAL-ASM: define {{.*}} @fragmentMain
// 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)
// WGSLSPIRV: %fragmentMain = OpFunction
// WGSL: @location(0) Diffuse
// WGSL: @location(1) debug1
// WGSL-DAG: @location(3) debug2
// WGSL-DAG: @location(2) Material

[shader("fragment")]
Output fragmentMain()
Expand Down
Loading