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 KiB54 linesraw
1// hlsl-syntax.slang
2
3// Test that we can ingest hlsl mesh output syntax
4
5//TEST:CROSS_COMPILE:-target spirv -profile sm_6_5 -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// Test that we can convert the HLSL Syntax to the typed syntax
29void foo(uint tig, OutputVertices<Vertex, MAX_VERTS> verts)
30{
31    if(tig < 3) {
32        verts[tig] = {float4(positions[tig], 0, 1), colors[tig]};
33    }
34}
35
36[outputtopology("triangle")]
37[numthreads(3, 1, 1)]
38void main(
39    in uint tig : SV_GroupIndex,
40    out vertices Vertex verts[MAX_VERTS],
41    out indices uint3 triangles[MAX_PRIMS]
42    )
43{
44    const uint numVertices = 3;
45    const uint numPrimitives = 1;
46    SetMeshOutputCounts(numVertices, numPrimitives);
47
48    foo(tig, verts);
49
50    if(tig < numPrimitives) {
51        triangles[tig] = uint3(0,1,2);
52    }
53}
54