yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
cbcb97a64
master
1// Test that a mesh shader generates PerPrimitiveNV decoration for OutputPrimitives 2//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry main -stage mesh -emit-spirv-directly -skip-spirv-validation 3 4// CHECK: OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId 5// CHECK: OpDecorate %gl_PrimitiveID PerPrimitive{{NV|EXT}} 6 7// CHECK: OpDecorate {{.*}} BuiltIn CullPrimitiveEXT 8// CHECK: OpDecorate {{.*}} PerPrimitive{{NV|EXT}} 9 10const static let color: float3[] = { 11 float3(1.0, 0.0, 0.0), 12 float3(0.0, 1.0, 0.0), 13 float3(0.0, 0.0, 1.0), 14}; 15 16const static let position: float3[] = { 17 float3( 0.5, 0.5, 0.0), 18 float3( 0.0, -0.5, 0.0), 19 float3(-0.5, 0.5, 0.0), 20}; 21 22struct SVertexOutput { 23 float4 Position: SV_Position; 24 float3 Color; 25}; 26 27struct SPrimitiveOutput { 28 uint PrimitiveId: SV_PrimitiveID; 29 bool cull : SV_CullPrimitive; 30}; 31 32[shader("mesh")] 33[numthreads(1, 1, 1)] 34[outputtopology("triangle")] 35func main( 36 OutputVertices<SVertexOutput, 3> outputVertices, 37 OutputPrimitives<SPrimitiveOutput, 1> outputPrimitives, 38 OutputIndices<uint3, 1> outputIndices, 39) -> void { 40 SetMeshOutputCounts(3, 1); 41 outputVertices[0] = { float4(position[0], 1.0), color[0] }; 42 outputVertices[1] = { float4(position[1], 1.0), color[1] }; 43 outputVertices[2] = { float4(position[2], 1.0), color[2] }; 44 outputIndices[0] = uint3(0, 1, 2); 45 46 outputPrimitives[0] = { 0, false }; 47} 48