From 077ff36bca5f3341ae5658fbfe7720bdf99cd919 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:09:36 -0800 Subject: [PATCH] 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. --- .../metal/nested-struct-fragment-input.slang | 31 +++++++++---- .../metal/nested-struct-fragment-output.slang | 46 ++++++++++--------- ...sted-struct-multi-entry-point-vertex.slang | 17 +++++++ tests/metal/no-struct-vertex-output.slang | 7 +-- tests/metal/stage-in-2.slang | 26 +++++++---- tests/metal/sv_target-complex-1.slang | 18 ++++---- tests/metal/sv_target-complex-2.slang | 16 ++++--- 7 files changed, 105 insertions(+), 56 deletions(-) diff --git a/tests/metal/nested-struct-fragment-input.slang b/tests/metal/nested-struct-fragment-input.slang index a8c94e8889..f70303306f 100644 --- a/tests/metal/nested-struct-fragment-input.slang +++ b/tests/metal/nested-struct-fragment-input.slang @@ -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 @@ -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 outputBuffer; @@ -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{{.*}}= @@ -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); diff --git a/tests/metal/nested-struct-fragment-output.slang b/tests/metal/nested-struct-fragment-output.slang index 4b29f84301..d13b3cdbf5 100644 --- a/tests/metal/nested-struct-fragment-output.slang +++ b/tests/metal/nested-struct-fragment-output.slang @@ -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) @@ -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 outputBuffer; @@ -41,7 +43,7 @@ struct MiddleFragment1 }; struct TopFragment { - float p1; + float p1; MiddleFragment1 p2; MiddleFragment1 p3; }; @@ -56,6 +58,7 @@ struct FragmentStageOutput TopFragment fragment : SV_Target; }; +//WGSL: fn fragmentMain{{.*}}-> [[ReturnType:FragmentStageOutput[_0-9]+]] FragmentStageOutput fragmentMain(FragmentStageInput input) { FragmentStageOutput output; @@ -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; } diff --git a/tests/metal/nested-struct-multi-entry-point-vertex.slang b/tests/metal/nested-struct-multi-entry-point-vertex.slang index 5d2b3b1e09..b9a8482f9a 100644 --- a/tests/metal/nested-struct-multi-entry-point-vertex.slang +++ b/tests/metal/nested-struct-multi-entry-point-vertex.slang @@ -5,6 +5,11 @@ //TEST:SIMPLE(filecheck=WGSL1): -target wgsl -stage vertex -entry vertexMain1 //TEST:SIMPLE(filecheck=WGSL2): -target wgsl -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) @@ -19,6 +24,18 @@ //METAL2-DAG: attribute(0) //METAL2-DAG: attribute(1) //METAL2-DAG: attribute(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) //WGSL2-DAG: fn vertexMain2 //WGSL2-DAG: location(0) diff --git a/tests/metal/no-struct-vertex-output.slang b/tests/metal/no-struct-vertex-output.slang index ae8b9f845f..7fd5860988 100644 --- a/tests/metal/no-struct-vertex-output.slang +++ b/tests/metal/no-struct-vertex-output.slang @@ -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); } diff --git a/tests/metal/stage-in-2.slang b/tests/metal/stage-in-2.slang index 5bdf3f3eb6..5b885af492 100644 --- a/tests/metal/stage-in-2.slang +++ b/tests/metal/stage-in-2.slang @@ -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 @@ -67,4 +77,4 @@ float4 fragmentMain( float3 color = coarseVertex.color; return float4(color, 1.0); -} \ 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 1a479f4ff0..ed145093bb 100644 --- a/tests/metal/sv_target-complex-1.slang +++ b/tests/metal/sv_target-complex-1.slang @@ -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 { @@ -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() diff --git a/tests/metal/sv_target-complex-2.slang b/tests/metal/sv_target-complex-2.slang index 5f3d166d50..70ee4002e7 100644 --- a/tests/metal/sv_target-complex-2.slang +++ b/tests/metal/sv_target-complex-2.slang @@ -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 { @@ -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()