summaryrefslogtreecommitdiffstats
path: root/tests/cross-compile/geometry-shader.slang
blob: 98e5fe661a9ca3722eee391d63c1a9ff4bc50334 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// geometry-shader.slang

//TEST:SIMPLE(filecheck=CHECK): -profile sm_5_0 -stage geometry -entry main -target glsl
//TEST:SIMPLE(filecheck=SPIRV): -profile sm_5_0 -stage geometry -entry main -target spirv

struct CoarseVertex
{
    float4 position     : POSITION;
    float3 color        : COLOR;
    uint   id           : ID;
}

struct RasterVertex
{
    float4 position : POSITION;
    float3 color    : COLOR;
    uint   id       : SV_RenderTargetArrayIndex;
}

// SPIRV: OpEntryPoint
// CHECK: void main()
// CHECK: gl_Layer =
// CHECK: EmitVertex();

[maxvertexcount(3)]
void main(
    triangle CoarseVertex coarseVertices[3],
    inout TriangleStream<RasterVertex> outputStream,
    uint primitiveID : SV_PrimitiveID)
{
    for(int ii = 0; ii < 3; ++ii)
    {
        CoarseVertex coarseVertex = coarseVertices[ii];
        RasterVertex rasterVertex;
        rasterVertex.position   = coarseVertex.position;
        rasterVertex.color      = coarseVertex.color;
        rasterVertex.id         = coarseVertex.id + primitiveID;
        outputStream.Append(rasterVertex);
    }
}