1 /* From section 5.7 "Structure and Array Operations" of the GLSL 1.50 spec:
3 * "Behavior is undefined if a shader subscripts an array with an index less
4 * than 0 or greater than or equal to the size the array was declared with."
6 * The behaviour becomes defined only in robustness extensions, however even
7 * if driver is technically allowed to crash or hang, it most likely
10 * gl_TessLevel* may be handled differently in a driver than ordinary arrays.
15 GL_ARB_tessellation_shader
20 const vec2 verts[] = vec2[](vec2(-1, 1),
24 const int elts[] = int[](0, 1, 2,
29 gl_Position = vec4(verts[elts[gl_VertexID]], 0, 1);
32 [tessellation control shader]
34 #extension GL_ARB_tessellation_shader : require
36 layout(vertices = 3) out;
40 gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
43 [tessellation evaluation shader]
45 #extension GL_ARB_tessellation_shader : require
47 layout(triangles, equal_spacing) in;
53 int index = int(gl_TessCoord.y + (2 * gl_TessCoord.z));
54 gl_Position = gl_in[index].gl_Position;
59 x += gl_TessLevelInner[idx1];
60 x += gl_TessLevelOuter[idx1];
62 int idx2 = 2147483647;
63 x += gl_TessLevelInner[idx2];
64 x += gl_TessLevelOuter[idx2];
66 int idx3 = 2147483647;
67 x += gl_TessLevelInner[idx3 > 0 ? idx3 : -1];
68 x += gl_TessLevelOuter[idx3 > 0 ? idx3 : -1];
71 x += gl_TessLevelInner[idx4 * idx4 * idx4];
72 x += gl_TessLevelOuter[idx4 * idx4 * idx4];
82 gl_FragColor = vec4(x);
86 patch parameter vertices 3
87 draw arrays GL_PATCHES 0 6