From d61f81374272c2abc34eecab19e916b979b08a55 Mon Sep 17 00:00:00 2001 From: Pankaj Mistry <63069047+pmistryNV@users.noreply.github.com> Date: Fri, 5 Apr 2024 14:52:50 -0700 Subject: Add decoration PerPrimitiveEXT when a mesh output variable is decorated with PrimitiveID (#3895) Fixes bug 3872 --- .../rasterization/mesh/mesh-PerPrimitiveEXT.slang | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/pipeline/rasterization/mesh/mesh-PerPrimitiveEXT.slang (limited to 'tests') diff --git a/tests/pipeline/rasterization/mesh/mesh-PerPrimitiveEXT.slang b/tests/pipeline/rasterization/mesh/mesh-PerPrimitiveEXT.slang new file mode 100644 index 000000000..bf46cce63 --- /dev/null +++ b/tests/pipeline/rasterization/mesh/mesh-PerPrimitiveEXT.slang @@ -0,0 +1,44 @@ +// Test that a mesh shader generates PerPrimitiveNV decoration for OutputPrimitives +//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry main -stage mesh -emit-spirv-directly + +// CHECK: OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId +// CHECK: OpDecorate %gl_PrimitiveID PerPrimitiveNV + +const static let color: float3[] = { + float3(1.0, 0.0, 0.0), + float3(0.0, 1.0, 0.0), + float3(0.0, 0.0, 1.0), +}; + +const static let position: float3[] = { + float3( 0.5, 0.5, 0.0), + float3( 0.0, -0.5, 0.0), + float3(-0.5, 0.5, 0.0), +}; + +struct SVertexOutput { + float4 Position: SV_Position; + float3 Color; +}; + +struct SPrimitiveOutput { + uint PrimitiveId: SV_PrimitiveID; +}; + +[shader("mesh")] +[numthreads(1, 1, 1)] +[outputtopology("triangle")] +func main( + OutputVertices outputVertices, + OutputPrimitives outputPrimitives, + OutputIndices outputIndices, +) -> void { + SetMeshOutputCounts(3, 1); + outputVertices[0] = { float4(position[0], 1.0), color[0] }; + outputVertices[1] = { float4(position[1], 1.0), color[1] }; + outputVertices[2] = { float4(position[2], 1.0), color[2] }; + outputIndices[0] = uint3(0, 1, 2); + + outputPrimitives[0] = { 0 }; +} + -- cgit v1.2.3