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

Test varying inputs and outputs for wgsl #5669

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions tests/compute/constexpr.slang
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//TEST(compute):COMPARE_COMPUTE_EX:-slang -gcompute -shaderobj
//DISABLED://TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -gcompute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-mtl -gcompute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-wgpu -gcompute -shaderobj

//TEST_INPUT: Texture2D(size=4, content = one):name tex
//TEST_INPUT: Sampler:name samp
Expand Down
1 change: 1 addition & 0 deletions tests/compute/discard-stmt.slang
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj
//TEST(compute):COMPARE_RENDER_COMPUTE: -mtl -shaderobj
//TEST(compute):COMPARE_RENDER_COMPUTE: -wgsl -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
Expand Down
2 changes: 1 addition & 1 deletion tests/compute/texture-sampling.slang
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
// There is no texture_1d_array type in WGSL https://github.com/shader-slang/slang/issues/5223
// Not supported in WGSL: 1D array texture not supported in WGSL
//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -wgpu
DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -wgpu

Texture1D t1D;
Texture2D t2D;
Expand Down
1 change: 0 additions & 1 deletion tests/expected-failure-github.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ tests/language-feature/generics/variadic-0.slang.4 syn (wgpu)
tests/language-feature/shader-params/interface-shader-param-ordinary.slang.4 syn (wgpu)
tests/language-feature/swizzles/matrix-swizzle-write-array.slang.3 syn (wgpu)
tests/language-feature/swizzles/matrix-swizzle-write-swizzle.slang.3 syn (wgpu)
tests/render/nointerpolation.hlsl (wgpu)
1 change: 1 addition & 0 deletions tests/metal/atomic-intrinsics.slang
Original file line number Diff line number Diff line change
Expand Up @@ -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 -compute -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-wgsl -compute -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
Expand Down
11 changes: 11 additions & 0 deletions tests/metal/nested-struct-fragment-input.slang
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -63,6 +64,16 @@ float4 fragmentMain(FragmentStageInput input)
// METAL-DAG: {{.*}}->p3{{.*}}->p2{{.*}}->p1{{.*}}=
// METAL-DAG: {{.*}}->p3{{.*}}->p3{{.*}}->p1{{.*}}=

// WGSL-DAG: {{.*}}.p1{{.*}}=

// WGSL-DAG: {{.*}}.p2{{.*}}.p1{{.*}}=
// WGSL-DAG: {{.*}}.p2{{.*}}.p2{{.*}}.p1{{.*}}=
// WGSL-DAG: {{.*}}.p2{{.*}}.p3{{.*}}.p1{{.*}}=

// WGSL-DAG: {{.*}}.p3{{.*}}.p1{{.*}}=
// WGSL-DAG: {{.*}}.p3{{.*}}.p2{{.*}}.p1{{.*}}=
// WGSL-DAG: {{.*}}.p3{{.*}}.p3{{.*}}.p1{{.*}}=

outputBuffer[0] = input.coarseVertex.p1 + input.coarseVertex.p2.p1 + +input.coarseVertex.p3.p1;
return float4(0, 0, 0, 0);
}
20 changes: 20 additions & 0 deletions tests/metal/nested-struct-fragment-output.slang
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -69,6 +79,16 @@ FragmentStageOutput fragmentMain(FragmentStageInput input)
// METAL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}.p1
// METAL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}.p1

// WGSL-DAG: ={{.*}}.p1

// WGSL-DAG: ={{.*}}.p2{{.*}}.p1
// WGSL-DAG: ={{.*}}.p2{{.*}}.p2{{.*}}.p1
// WGSL-DAG: ={{.*}}.p2{{.*}}.p3{{.*}}.p1

// WGSL-DAG: ={{.*}}.p3{{.*}}.p1
// WGSL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}.p1
// WGSL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}.p1

outputBuffer[0] = 1;
return output;
}
14 changes: 13 additions & 1 deletion tests/metal/nested-struct-multi-entry-point-vertex.slang
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,4 +54,4 @@ struct VertexStageInput2
float4 vertexMain2(VertexStageInput2 vertex)
{
return vertex.assembledVertex.sharedData.position;
}
}
6 changes: 5 additions & 1 deletion tests/metal/no-struct-vertex-output.slang
Original file line number Diff line number Diff line change
@@ -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);
}
}
25 changes: 16 additions & 9 deletions tests/metal/sv_target-complex-1.slang
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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) };
}
}
22 changes: 14 additions & 8 deletions tests/metal/sv_target-complex-2.slang
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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) };
}
}
16 changes: 16 additions & 0 deletions tests/wgsl/semantic-coverage.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry main

//WGSL-DAG: @builtin(sample_mask)
//WGSL-DAG: @fragment

struct Out
{
uint coverage : SV_Coverage;
};

Out main()
{
Out output;
output.coverage = 1;
return output;
}
16 changes: 16 additions & 0 deletions tests/wgsl/semantic-depth.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry main

//WGSL-DAG: @builtin(frag_depth)
//WGSL-DAG: @fragment

struct Out
{
float depth : SV_Depth;
};

Out main()
{
Out output;
output.depth = 1.0;
return output;
}
9 changes: 9 additions & 0 deletions tests/wgsl/semantic-dispatch-thread-id.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage compute -entry main

//WGSL-DAG: @builtin(global_invocation_id)
//WGSL-DAG: @compute

void main(uint3 dtid : SV_DispatchThreadID)
{
// Empty compute shader
}
9 changes: 9 additions & 0 deletions tests/wgsl/semantic-group-id.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage compute -entry main

//WGSL-DAG: @builtin(workgroup_id)
//WGSL-DAG: @compute

void main(uint3 gid : SV_GroupID)
{
// Empty compute shader
}
9 changes: 9 additions & 0 deletions tests/wgsl/semantic-group-index.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage compute -entry main

//WGSL-DAG: @builtin(local_invocation_index)
//WGSL-DAG: @compute

void main(uint idx : SV_GroupIndex)
{
// Empty compute shader
}
9 changes: 9 additions & 0 deletions tests/wgsl/semantic-group-thread-id.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage compute -entry main

//WGSL-DAG: @builtin(local_invocation_id)
//WGSL-DAG: @compute

void main(uint3 gtid : SV_GroupThreadID)
{
// Empty compute shader
}
9 changes: 9 additions & 0 deletions tests/wgsl/semantic-instance-id.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage vertex -entry main

//WGSL-DAG: @builtin(instance_index)
//WGSL-DAG: @vertex

float4 main(uint instanceID : SV_InstanceID) : SV_Position
{
return float4(1,1,1,1);
}
9 changes: 9 additions & 0 deletions tests/wgsl/semantic-is-front-face.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry main

//WGSL-DAG: @builtin(front_facing)
//WGSL-DAG: @fragment

float4 main(bool isFront : SV_IsFrontFace) : SV_Target
{
return float4(1,1,1,1);
}
16 changes: 16 additions & 0 deletions tests/wgsl/semantic-position.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage vertex -entry main

//WGSL-DAG: @builtin(position)
//WGSL-DAG: @vertex

struct S
{
float4 position : SV_Position;
};

S main()
{
S output;
output.position = float4(0,0,0,1);
return output;
}
9 changes: 9 additions & 0 deletions tests/wgsl/semantic-sample-index.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry main

//WGSL-DAG: @builtin(sample_index)
//WGSL-DAG: @fragment

float4 main(uint sampleIndex : SV_SampleIndex) : SV_Target
{
return float4(1,1,1,1);
}
9 changes: 9 additions & 0 deletions tests/wgsl/semantic-vertex-id.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage vertex -entry main

//WGSL-DAG: @builtin(vertex_index)
//WGSL-DAG: @vertex

float4 main(uint vertexID : SV_VertexID) : SV_Position
{
return float4(1,1,1,1);
}
Loading