arb_program_interface_query: set vs_input2[1][0] as valid name
[piglit.git] / tests / spec / arb_tessellation_shader / execution / tes-tes-levels-out-of-bounds-read.shader_test
blob00233e3815a399cd222a0194c70616b72324a24a
1 /* From section 5.7 "Structure and Array Operations" of the GLSL 1.50 spec:
2  *
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."
5  *
6  * The behaviour becomes defined only in robustness extensions, however even
7  * if driver is technically allowed to crash or hang, it most likely
8  * doesn't want to.
9  *
10  * gl_TessLevel* may be handled differently in a driver than ordinary arrays.
11  */
13 [require]
14 GLSL >= 1.50
15 GL_ARB_tessellation_shader
17 [vertex shader]
18 #version 150
20 const vec2 verts[] = vec2[](vec2(-1, 1),
21                             vec2(-1, -1),
22                             vec2(1, -1),
23                             vec2(1, 1));
24 const int elts[] = int[](0, 1, 2,
25                          0, 2, 3);
27 void main()
29         gl_Position = vec4(verts[elts[gl_VertexID]], 0, 1);
32 [tessellation control shader]
33 #version 150
34 #extension GL_ARB_tessellation_shader : require
36 layout(vertices = 3) out;
38 void main()
40         gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
43 [tessellation evaluation shader]
44 #version 150
45 #extension GL_ARB_tessellation_shader : require
47 layout(triangles, equal_spacing) in;
49 out float x;
51 void main()
53         int index = int(gl_TessCoord.y + (2 * gl_TessCoord.z));
54         gl_Position = gl_in[index].gl_Position;
56         x = 0.0;
58         int idx1 = -1;
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];
70         int idx4 = -1;
71         x += gl_TessLevelInner[idx4 * idx4 * idx4];
72         x += gl_TessLevelOuter[idx4 * idx4 * idx4];
75 [fragment shader]
76 #version 150
78 in float x;
80 void main()
82         gl_FragColor = vec4(x);
85 [test]
86 patch parameter vertices 3
87 draw arrays GL_PATCHES 0 6