diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-03-15 08:48:41 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-14 17:48:41 -0700 |
| commit | d40931cc8bde13520ea45769cf94e7cc6cc9065f (patch) | |
| tree | ecde6ebbfbc1445c587b0339332814837ff43229 /tests/pipeline | |
| parent | c7d7a965c14318c07bd5b8ec60b960c2e95dfebd (diff) | |
Mesh shader refactoring and bugfixes (#3702)
Diffstat (limited to 'tests/pipeline')
11 files changed, 108 insertions, 26 deletions
diff --git a/tests/pipeline/rasterization/mesh/component-write.slang b/tests/pipeline/rasterization/mesh/component-write.slang index a34f6ee31..afa5cd291 100644 --- a/tests/pipeline/rasterization/mesh/component-write.slang +++ b/tests/pipeline/rasterization/mesh/component-write.slang @@ -29,8 +29,8 @@ const static uint MAX_PRIMS = 1; [numthreads(3, 1, 1)] void main( in uint tig : SV_GroupIndex, - out Vertices<Vertex, MAX_VERTS> verts, - out Indices<uint3, MAX_PRIMS> triangles + OutputVertices<Vertex, MAX_VERTS> verts, + OutputIndices<uint3, MAX_PRIMS> triangles ) { const uint numVertices = 3; diff --git a/tests/pipeline/rasterization/mesh/dead-loop.slang b/tests/pipeline/rasterization/mesh/dead-loop.slang new file mode 100644 index 000000000..875a12db5 --- /dev/null +++ b/tests/pipeline/rasterization/mesh/dead-loop.slang @@ -0,0 +1,82 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -dx12 -use-dxil -profile sm_6_6 -render-features mesh-shader +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -vk -profile glsl_450+spirv_1_4 -render-features mesh-shader + +// See https://github.com/shader-slang/slang/issues/3401 + +// CHECK: 0 +// CHECK-NEXT: 1 +// CHECK-NEXT: 4 +// CHECK-NEXT: 9 + +//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer + +RWStructuredBuffer<float> outputBuffer; + +cbuffer Uniforms +{ + float4x4 modelViewProjection; +} + +const static float2 positions[3] = { + float2(0.0, -0.5), + float2(0.5, 0.5), + float2(-0.5, 0.5) +}; + +const static float3 colors[3] = { + float3(1.0, 1.0, 0.0), + float3(0.0, 1.0, 1.0), + float3(1.0, 0.0, 1.0) +}; +struct Vertex +{ + float4 pos : SV_Position; + float3 color : Color; + int index : Index; + int value : Value; +}; + +const static uint MAX_VERTS = 12; +const static uint MAX_PRIMS = 4; + +[outputtopology("triangle")] +[shader("mesh")] +[numthreads(3, 1, 1)] +void meshMain( + in uint tig : SV_GroupIndex, + OutputVertices<Vertex, MAX_VERTS> verts, + OutputIndices<uint3, MAX_PRIMS> triangles) +{ + const uint numVertices = 12; + const uint numPrimitives = 4; + SetMeshOutputCounts(numVertices, numPrimitives); + + for(uint i = tig; i < numVertices; ++i) + { + const int tri = i / 3; + verts[i] = {float4(positions[i % 3], 0, 1), colors[i % 3], tri, tri*tri}; + } + + for(uint i = tig; i < numPrimitives; ++i) + { + triangles[i] = i * 3 + uint3(0,1,2); + } +} + +// +// Fragment Shader +// + +struct Fragment +{ + float4 color : SV_Target; +}; + +Fragment fragmentMain(Vertex input) +{ + outputBuffer[input.index] = input.value; + + Fragment output; + output.color = float4(input.color, 1.0); + return output; +} diff --git a/tests/pipeline/rasterization/mesh/hello.slang b/tests/pipeline/rasterization/mesh/hello.slang index 54754c42e..54a50079d 100644 --- a/tests/pipeline/rasterization/mesh/hello.slang +++ b/tests/pipeline/rasterization/mesh/hello.slang @@ -39,8 +39,8 @@ const static uint MAX_PRIMS = 1; [numthreads(3, 1, 1)] void main( in uint tig : SV_GroupIndex, - out Vertices<Vertex, MAX_VERTS> verts, - out Indices<uint3, MAX_PRIMS> triangles + OutputVertices<Vertex, MAX_VERTS> verts, + OutputIndices<uint3, MAX_PRIMS> triangles ) { const uint numVertices = 3; diff --git a/tests/pipeline/rasterization/mesh/hlsl-syntax.slang b/tests/pipeline/rasterization/mesh/hlsl-syntax.slang index a0b397ca2..eaa853a04 100644 --- a/tests/pipeline/rasterization/mesh/hlsl-syntax.slang +++ b/tests/pipeline/rasterization/mesh/hlsl-syntax.slang @@ -26,7 +26,7 @@ const static uint MAX_VERTS = 3; const static uint MAX_PRIMS = 1; // Test that we can convert the HLSL Syntax to the typed syntax -void foo(uint tig, out Vertices<Vertex, MAX_VERTS> verts) +void foo(uint tig, OutputVertices<Vertex, MAX_VERTS> verts) { if(tig < 3) { verts[tig] = {float4(positions[tig], 0, 1), colors[tig]}; diff --git a/tests/pipeline/rasterization/mesh/nested-component-write.slang b/tests/pipeline/rasterization/mesh/nested-component-write.slang index 68bb6dfb9..f55d5365e 100644 --- a/tests/pipeline/rasterization/mesh/nested-component-write.slang +++ b/tests/pipeline/rasterization/mesh/nested-component-write.slang @@ -33,8 +33,8 @@ const static uint MAX_PRIMS = 1; [numthreads(3, 1, 1)] void main( in uint tig : SV_GroupIndex, - out Vertices<Vertex, MAX_VERTS> verts, - out Indices<uint3, MAX_PRIMS> triangles + OutputVertices<Vertex, MAX_VERTS> verts, + OutputIndices<uint3, MAX_PRIMS> triangles ) { SetMeshOutputCounts(3, 1); diff --git a/tests/pipeline/rasterization/mesh/passing-outputs.slang b/tests/pipeline/rasterization/mesh/passing-outputs.slang index 20e6abe0b..3fd6fc4a0 100644 --- a/tests/pipeline/rasterization/mesh/passing-outputs.slang +++ b/tests/pipeline/rasterization/mesh/passing-outputs.slang @@ -28,7 +28,7 @@ struct Vertex Texes ts : Coord; }; -void everything<let N : uint>(out Vertices<Vertex, N> vs) +void everything<let N : uint>(OutputVertices<Vertex, N> vs) { vs[0] = {float4(0), float3(1)}; } @@ -56,32 +56,32 @@ void write_struct(out Texes t) } // Split out the things to test to avoid main becoming an unreadable jumble -void a<let N : uint>(out Vertices<Vertex, N> vs) +void a<let N : uint>(OutputVertices<Vertex, N> vs) { // Test passing a reference to the entire array everything(vs); } -void b<let N : uint>(out Vertices<Vertex, N> vs) +void b<let N : uint>(OutputVertices<Vertex, N> vs) { // test passing two references to the same element just_two(vs[0], vs[0]); } -void c<let N : uint>(out Vertices<Vertex, N> vs, uint tig) +void c<let N : uint>(OutputVertices<Vertex, N> vs, uint tig) { // Test passing a reference to an element just_one(vs[tig]); } -void d<let N : uint>(out Vertices<Vertex, N> vs, uint tig) +void d<let N : uint>(OutputVertices<Vertex, N> vs, uint tig) { // Test passing references to different elements (to check that the operand // rewriting doesn't mess the order) just_two(vs[tig], vs[0]); } -void e<let N : uint>(out Vertices<Vertex, N> vs, uint tig) +void e<let N : uint>(OutputVertices<Vertex, N> vs, uint tig) { // Test passing a scalar member and a struct member and a struct member's member part_of_one(vs[tig].pos); @@ -93,8 +93,8 @@ void e<let N : uint>(out Vertices<Vertex, N> vs, uint tig) [numthreads(3, 1, 1)] void main( in uint tig : SV_GroupIndex, - out Vertices<Vertex, MAX_VERTS> verts, - out Indices<uint3, MAX_PRIMS> triangles + OutputVertices<Vertex, MAX_VERTS> verts, + OutputIndices<uint3, MAX_PRIMS> triangles ) { const uint numVertices = 3; diff --git a/tests/pipeline/rasterization/mesh/primitive-output.slang b/tests/pipeline/rasterization/mesh/primitive-output.slang index fdbcf6912..99d4f63b9 100644 --- a/tests/pipeline/rasterization/mesh/primitive-output.slang +++ b/tests/pipeline/rasterization/mesh/primitive-output.slang @@ -36,9 +36,9 @@ const static uint MAX_PRIMS = 1; [numthreads(3, 1, 1)] void main( in uint tig : SV_GroupIndex, - out Indices<uint3, MAX_PRIMS> triangles, - out Vertices<Vertex, MAX_VERTS> verts, - out Primitives<Prim, MAX_PRIMS> primitives + OutputIndices<uint3, MAX_PRIMS> triangles, + OutputVertices<Vertex, MAX_VERTS> verts, + OutputPrimitives<Prim, MAX_PRIMS> primitives ) { const uint numVertices = 3; diff --git a/tests/pipeline/rasterization/mesh/simple.slang b/tests/pipeline/rasterization/mesh/simple.slang index 00047aaad..de1195d71 100644 --- a/tests/pipeline/rasterization/mesh/simple.slang +++ b/tests/pipeline/rasterization/mesh/simple.slang @@ -50,8 +50,8 @@ const static uint MAX_PRIMS = 4; [numthreads(12, 1, 1)] void meshMain( in uint tig : SV_GroupIndex, - out Vertices<Vertex, MAX_VERTS> verts, - out Indices<uint3, MAX_PRIMS> triangles) + OutputVertices<Vertex, MAX_VERTS> verts, + OutputIndices<uint3, MAX_PRIMS> triangles) { const uint numVertices = 12; const uint numPrimitives = 4; diff --git a/tests/pipeline/rasterization/mesh/swizzled-store.slang b/tests/pipeline/rasterization/mesh/swizzled-store.slang index f85f9ed62..713416430 100644 --- a/tests/pipeline/rasterization/mesh/swizzled-store.slang +++ b/tests/pipeline/rasterization/mesh/swizzled-store.slang @@ -11,8 +11,8 @@ const static uint MAX_PRIMS = 1; [numthreads(3, 1, 1)] void main( in uint tig : SV_GroupIndex, - out Vertices<float4, MAX_VERTS> verts : SV_Position, - out Indices<uint3, MAX_PRIMS> triangles + OutputVertices<float4, MAX_VERTS> verts : SV_Position, + OutputIndices<uint3, MAX_PRIMS> triangles ) { const uint numVertices = 3; diff --git a/tests/pipeline/rasterization/mesh/task-groupshared.slang b/tests/pipeline/rasterization/mesh/task-groupshared.slang index c633aeeb1..518d94bfb 100644 --- a/tests/pipeline/rasterization/mesh/task-groupshared.slang +++ b/tests/pipeline/rasterization/mesh/task-groupshared.slang @@ -71,8 +71,8 @@ const static uint MAX_PRIMS = 4; void meshMain( in uint tig : SV_GroupIndex, in payload MeshPayload meshPayload, - out Vertices<Vertex, MAX_VERTS> verts, - out Indices<uint3, MAX_PRIMS> triangles) + OutputVertices<Vertex, MAX_VERTS> verts, + OutputIndices<uint3, MAX_PRIMS> triangles) { const uint numVertices = 12; const uint numPrimitives = 4; diff --git a/tests/pipeline/rasterization/mesh/task-simple.slang b/tests/pipeline/rasterization/mesh/task-simple.slang index 58ec9a527..dc3de82c0 100644 --- a/tests/pipeline/rasterization/mesh/task-simple.slang +++ b/tests/pipeline/rasterization/mesh/task-simple.slang @@ -73,8 +73,8 @@ void meshMain( // Check that we correctly generate the specific 'in payload' that HLSL // requires: // HLSL: , in payload MeshPayload - out Vertices<Vertex, MAX_VERTS> verts, - out Indices<uint3, MAX_PRIMS> triangles) + OutputVertices<Vertex, MAX_VERTS> verts, + OutputIndices<uint3, MAX_PRIMS> triangles) { const uint numVertices = 12; const uint numPrimitives = 4; |
