yum-mirror/slang

Making it easier to work with shaders

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

kaizhangNVFeature/initialize list side branch (#6058)9ec6b9168

master
1.3 KiB56 linesraw
1#version 450
2#extension GL_EXT_mesh_shader : require
3layout(row_major) uniform;
4layout(row_major) buffer;
5
6out gl_MeshPerVertexEXT
7{
8    vec4 gl_Position;
9} gl_MeshVerticesEXT[3];
10
11const vec3  colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) };
12const vec2  positions_0[3] = { vec2(0.0, -0.5), vec2(0.5, 0.5), vec2(-0.5, 0.5) };
13
14struct Vertex_0
15{
16    vec4 pos_0;
17    vec3 color_0;
18};
19
20Vertex_0 Vertex_x24init_0(vec4 pos_1, vec3 color_1)
21{
22    Vertex_0 _S1;
23
24    _S1.pos_0 = pos_1;
25    _S1.color_0 = color_1;
26    return _S1;
27}
28
29layout(location = 0)
30out vec3  verts_color_0[3];
31out uvec3  gl_PrimitiveTriangleIndicesEXT[1];
32void foo_0(uint _S2)
33{
34    if(_S2 < 3U)
35    {
36        Vertex_0 _S3 = Vertex_x24init_0(vec4(positions_0[_S2], 0.0, 1.0), colors_0[_S2]);
37        gl_MeshVerticesEXT[_S2].gl_Position = _S3.pos_0;
38        verts_color_0[_S2] = _S3.color_0;
39    }
40    return;
41}
42
43layout(local_size_x = 3, local_size_y = 1, local_size_z = 1) in;
44layout(max_vertices = 3) out;
45layout(max_primitives = 1) out;
46layout(triangles) out;
47void main()
48{
49    SetMeshOutputsEXT(3U, 1U);
50    foo_0(gl_LocalInvocationIndex);
51    if(gl_LocalInvocationIndex < 1U)
52    {
53        gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(0U, 1U, 2U);
54    }
55    return;
56}