yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

ArielG-NVCapability System: Implicit capability upgrade warning/error (#4241)8813c6105

master
1.1 KiB49 linesraw
1// component-write.slang
2
3// This tests that writing to individual components of the output struct works
4
5//TEST:CROSS_COMPILE:-target spirv -profile glsl_450+GL_EXT_mesh_shader -entry main -stage mesh
6
7const static float2 positions[3] = {
8  float2(0.0, -0.5),
9  float2(0.5, 0.5),
10  float2(-0.5, 0.5)
11};
12
13const static float3 colors[3] = {
14  float3(1.0, 1.0, 0.0),
15  float3(0.0, 1.0, 1.0),
16  float3(1.0, 0.0, 1.0)
17};
18
19struct Vertex
20{
21  float4 pos : SV_Position;
22  float3 color : Color;
23};
24
25const static uint MAX_VERTS = 3;
26const static uint MAX_PRIMS = 1;
27
28[outputtopology("triangle")]
29[numthreads(3, 1, 1)]
30void main(
31    in uint tig : SV_GroupIndex,
32    OutputVertices<Vertex, MAX_VERTS> verts,
33    OutputIndices<uint3, MAX_PRIMS> triangles
34    )
35{
36    const uint numVertices = 3;
37    const uint numPrimitives = 1;
38    SetMeshOutputCounts(numVertices, numPrimitives);
39
40    if(tig < numVertices) {
41        verts[tig].pos = float4(positions[tig], 0, 1);
42        verts[tig].color = colors[tig];
43    }
44
45    if(tig < numPrimitives) {
46        triangles[tig] = uint3(0,1,2);
47    }
48}
49