yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
dd275dd95
master
1//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly 2 3// CHECK: OpEntryPoint 4 5const static float2 positions[3] = { 6 float2(0.0, -0.5), 7 float2(0.5, 0.5), 8 float2(-0.5, 0.5) 9}; 10 11const static float3 colors[3] = { 12 float3(1.0, 1.0, 0.0), 13 float3(0.0, 1.0, 1.0), 14 float3(1.0, 0.0, 1.0) 15}; 16 17struct Vertex 18{ 19 float4 pos : SV_Position; 20 float3 color; 21}; 22 23const static uint MAX_VERTS = 3; 24const static uint MAX_PRIMS = 1; 25 26[outputtopology("triangle")] 27[numthreads(3, 1, 1)] 28[shader("mesh")] 29void entry_mesh( 30 in uint tig : SV_GroupIndex, 31 out vertices Vertex verts[MAX_VERTS], 32 out indices uint3 triangles[MAX_PRIMS]) 33{ 34 const uint numVertices = 3; 35 const uint numPrimitives = 1; 36 SetMeshOutputCounts(numVertices, numPrimitives); 37 38 if(tig < numVertices) { 39 verts[tig] = {float4(positions[tig], 0, 1), colors[tig]}; 40 } 41 42 if(tig < numPrimitives) { 43 triangles[tig] = uint3(0,1,2); 44 } 45} 46 47struct FragmentOut 48{ 49 [[vk::location(0)]] float3 color; 50}; 51 52[shader("fragment")] 53FragmentOut entry_fragment(in Vertex vertex) 54{ 55 FragmentOut frag_out; 56 frag_out.color = float3(1,1,1); 57 return frag_out; 58}