yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
cbcb97a64
master
1// hello.slang 2 3// Test that a simple mesh shader compiles 4 5//TEST:SIMPLE(filecheck=SPV_CHECK):-target spirv -profile glsl_450+spirv_1_4 -entry main -stage mesh -skip-spirv-validation 6 7//SPV_CHECK-NOT: SPV_NV_mesh_shader 8//SPV_CHECK: SPV_EXT_mesh_shader 9//SPV_CHECK: CullPrimitiveEXT 10 11const static float2 positions[3] = { 12 float2(0.0, -0.5), 13 float2(0.5, 0.5), 14 float2(-0.5, 0.5) 15}; 16 17const static float3 colors[3] = { 18 float3(1.0, 1.0, 0.0), 19 float3(0.0, 1.0, 1.0), 20 float3(1.0, 0.0, 1.0) 21}; 22 23struct Vertex 24{ 25 float4 pos : SV_Position; 26 float3 color : Color; 27}; 28 29struct Prim 30{ 31 float3 triangleNormal : Normal; 32 uint id : SV_PrimitiveID; 33 bool cull : SV_CullPrimitive; 34}; 35 36const static uint MAX_VERTS = 3; 37const static uint MAX_PRIMS = 1; 38 39[outputtopology("triangle")] 40[numthreads(3, 1, 1)] 41void main( 42 in uint tig : SV_GroupIndex, 43 OutputIndices<uint3, MAX_PRIMS> triangles, 44 OutputVertices<Vertex, MAX_VERTS> verts, 45 OutputPrimitives<Prim, MAX_PRIMS> primitives 46 ) 47{ 48 const uint numVertices = 3; 49 const uint numPrimitives = 1; 50 SetMeshOutputCounts(numVertices, numPrimitives); 51 52 if(tig < numVertices) { 53 verts[tig] = {float4(positions[tig], 0, 1), colors[tig]}; 54 } 55 56 if(tig < numPrimitives) { 57 triangles[tig] = uint3(0,1,2); 58 primitives[tig] = {float3(0,0,1), tig, false}; 59 } 60} 61