yum-mirror/slang

Making it easier to work with shaders

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

Yong He[SPIRV] Support `globallycoherent` and `[vk::index()]`. (#3488)e7b6de334

master
1.1 KiB40 linesraw
1// geometry-shader.slang
2
3//TEST:SIMPLE(filecheck=CHECK): -profile sm_5_0 -stage geometry -entry main -target glsl
4//TEST:SIMPLE(filecheck=SPIRV): -profile sm_5_0 -stage geometry -entry main -target spirv
5
6struct CoarseVertex
7{
8    float4 position     : POSITION;
9    float3 color        : COLOR;
10    uint   id           : ID;
11}
12
13struct RasterVertex
14{
15    float4 position : POSITION;
16    float3 color    : COLOR;
17    uint   id       : SV_RenderTargetArrayIndex;
18}
19
20// SPIRV: OpEntryPoint
21// CHECK: void main()
22// CHECK: gl_Layer =
23// CHECK: EmitVertex();
24
25[maxvertexcount(3)]
26void main(
27    triangle CoarseVertex coarseVertices[3],
28    inout TriangleStream<RasterVertex> outputStream,
29    uint primitiveID : SV_PrimitiveID)
30{
31    for(int ii = 0; ii < 3; ++ii)
32    {
33        CoarseVertex coarseVertex = coarseVertices[ii];
34        RasterVertex rasterVertex;
35        rasterVertex.position   = coarseVertex.position;
36        rasterVertex.color      = coarseVertex.color;
37        rasterVertex.id         = coarseVertex.id + primitiveID;
38        outputStream.Append(rasterVertex);
39    }
40}