diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-12-03 03:45:04 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-02 11:45:04 -0800 |
| commit | 7aaf7009e2c6055a714ba4a93ab3dd73d2d2cdb7 (patch) | |
| tree | 17fbc14b5d032951c0c5af0b444ff08dc389d77d /tests/wgsl | |
| parent | 0586e5ab478f7cfb1763d019eb014f2578106240 (diff) | |
Varying inputs and outputs for wgsl (#5669)
Closes https://github.com/shader-slang/slang/issues/5067
New tests, covering what's declared supported in the WGSL support docs
- tests/wgsl/semantic-coverage.slang
- tests/wgsl/semantic-depth.slang
- tests/wgsl/semantic-dispatch-thread-id.slang
- tests/wgsl/semantic-group-id.slang
- tests/wgsl/semantic-group-index.slang
- tests/wgsl/semantic-group-thread-id.slang
- tests/wgsl/semantic-instance-id.slang
- tests/wgsl/semantic-is-front-face.slang
- tests/wgsl/semantic-position.slang
- tests/wgsl/semantic-sample-index.slang
- tests/wgsl/semantic-vertex-id.slang
WGSL enabled existing tests:
- tests/compute/compile-time-loop.slang
- tests/compute/constexpr.slang
- tests/compute/discard-stmt.slang
- tests/metal/nested-struct-fragment-input.slang
- tests/metal/nested-struct-fragment-output.slang
- tests/metal/nested-struct-multi-entry-point-vertex.slang
- tests/metal/no-struct-vertex-output.slang
- tests/metal/sv_target-complex-1.slang
- tests/metal/sv_target-complex-2.slang
- tests/bugs/texture2d-gather.hlsl
- tests/render/cross-compile-entry-point.slang
- tests/render/nointerpolation.hlsl
- tests/render/render0.hlsl
- tests/render/cross-compile0.hlsl
- tests/render/imported-parameters.hlsl
- tests/render/unused-discard.hlsl
Can't be enabled due to missing wgsl features
- tests/compute/texture-sampling.slang
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/wgsl')
| -rw-r--r-- | tests/wgsl/semantic-coverage.slang | 16 | ||||
| -rw-r--r-- | tests/wgsl/semantic-depth.slang | 16 | ||||
| -rw-r--r-- | tests/wgsl/semantic-dispatch-thread-id.slang | 9 | ||||
| -rw-r--r-- | tests/wgsl/semantic-group-id.slang | 9 | ||||
| -rw-r--r-- | tests/wgsl/semantic-group-index.slang | 9 | ||||
| -rw-r--r-- | tests/wgsl/semantic-group-thread-id.slang | 9 | ||||
| -rw-r--r-- | tests/wgsl/semantic-instance-id.slang | 9 | ||||
| -rw-r--r-- | tests/wgsl/semantic-is-front-face.slang | 9 | ||||
| -rw-r--r-- | tests/wgsl/semantic-position.slang | 16 | ||||
| -rw-r--r-- | tests/wgsl/semantic-sample-index.slang | 9 | ||||
| -rw-r--r-- | tests/wgsl/semantic-vertex-id.slang | 9 |
11 files changed, 120 insertions, 0 deletions
diff --git a/tests/wgsl/semantic-coverage.slang b/tests/wgsl/semantic-coverage.slang new file mode 100644 index 000000000..722f7180c --- /dev/null +++ b/tests/wgsl/semantic-coverage.slang @@ -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; +} diff --git a/tests/wgsl/semantic-depth.slang b/tests/wgsl/semantic-depth.slang new file mode 100644 index 000000000..65b29600a --- /dev/null +++ b/tests/wgsl/semantic-depth.slang @@ -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; +} diff --git a/tests/wgsl/semantic-dispatch-thread-id.slang b/tests/wgsl/semantic-dispatch-thread-id.slang new file mode 100644 index 000000000..9216c02da --- /dev/null +++ b/tests/wgsl/semantic-dispatch-thread-id.slang @@ -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 +} diff --git a/tests/wgsl/semantic-group-id.slang b/tests/wgsl/semantic-group-id.slang new file mode 100644 index 000000000..d83f85d8e --- /dev/null +++ b/tests/wgsl/semantic-group-id.slang @@ -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 +} diff --git a/tests/wgsl/semantic-group-index.slang b/tests/wgsl/semantic-group-index.slang new file mode 100644 index 000000000..06429ff39 --- /dev/null +++ b/tests/wgsl/semantic-group-index.slang @@ -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 +} diff --git a/tests/wgsl/semantic-group-thread-id.slang b/tests/wgsl/semantic-group-thread-id.slang new file mode 100644 index 000000000..7646397d0 --- /dev/null +++ b/tests/wgsl/semantic-group-thread-id.slang @@ -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 +} diff --git a/tests/wgsl/semantic-instance-id.slang b/tests/wgsl/semantic-instance-id.slang new file mode 100644 index 000000000..868d9149d --- /dev/null +++ b/tests/wgsl/semantic-instance-id.slang @@ -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); +} diff --git a/tests/wgsl/semantic-is-front-face.slang b/tests/wgsl/semantic-is-front-face.slang new file mode 100644 index 000000000..d79ab672b --- /dev/null +++ b/tests/wgsl/semantic-is-front-face.slang @@ -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); +} diff --git a/tests/wgsl/semantic-position.slang b/tests/wgsl/semantic-position.slang new file mode 100644 index 000000000..28c047a04 --- /dev/null +++ b/tests/wgsl/semantic-position.slang @@ -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; +} diff --git a/tests/wgsl/semantic-sample-index.slang b/tests/wgsl/semantic-sample-index.slang new file mode 100644 index 000000000..bd347d94f --- /dev/null +++ b/tests/wgsl/semantic-sample-index.slang @@ -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); +} diff --git a/tests/wgsl/semantic-vertex-id.slang b/tests/wgsl/semantic-vertex-id.slang new file mode 100644 index 000000000..4120dc098 --- /dev/null +++ b/tests/wgsl/semantic-vertex-id.slang @@ -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); +} |
