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
2.0 KiB91 linesraw
1#version 450
2// geometry-shader.slang.glsl
3//TEST_IGNORE_FILE:
4
5#define RasterVertex RasterVertex_0
6#define CoarseVertex CoarseVertex_0
7
8#define input_position  coarseVertices_position_0
9#define input_color     coarseVertices_color_0
10#define input_id        coarseVertices_id_0
11#define output_position outputStream_position_0
12#define output_color    outputStream_color_0
13
14layout(row_major) uniform;
15layout(row_major) buffer;
16
17layout(location = 0)
18in vec4  input_position[3];
19
20layout(location = 1)
21in vec3  input_color[3];
22
23layout(location = 2)
24in uint  input_id[3];
25
26layout(location = 0)
27out vec4 output_position;
28
29layout(location = 1)
30out vec3 output_color;
31
32struct RasterVertex
33{
34    vec4 position_0;
35    vec3 color_0;
36    uint id_0;
37};
38
39struct CoarseVertex
40{
41    vec4 position_1;
42    vec3 color_1;
43    uint id_1;
44};
45
46
47layout(max_vertices = 3) out;
48layout(triangles) in;
49layout(triangle_strip) out;
50
51void main()
52{
53    uint _S6 = uint(gl_PrimitiveIDIn);
54
55    // TODO: Having to make this copy to transpose things is unfortunate.
56    //
57    // The front-end should be able to generate code using aggregate
58    // types for the input, and/or eliminate the redundant temporary
59    // by indexing directly into the sub-arrays.
60    //
61    CoarseVertex_0 _S7 = { _S1[0], _S2[0], _S3[0] };
62    CoarseVertex_0 _S8 = { _S1[1], _S2[1], _S3[1] };
63    CoarseVertex_0 _S9 = { _S1[2], _S2[2], _S3[2] };
64
65    CoarseVertex_0  _S10[3] = { _S7, _S8, _S9 };
66
67    int ii_0 = 0;
68
69    for(;;)
70    {
71        RasterVertex_0 rasterVertex_0;
72        rasterVertex_0.position_0 = _S10[ii_0].position_1;
73        rasterVertex_0.color_0 = _S10[ii_0].color_1;
74        rasterVertex_0.id_0 = _S10[ii_0].id_1 + _S6;
75        RasterVertex_0 _S11 = rasterVertex_0;
76        _S4 = rasterVertex_0.position_0;
77        _S5 = _S11.color_0;
78        gl_Layer = int(_S11.id_0);
79        EmitVertex();
80        int ii_1 = ii_0 + 1;
81        if(ii_1 < 3)
82        {
83        }
84        else
85        {
86            break;
87        }
88        ii_0 = ii_1;
89    }
90    return;
91}