1# Test accessing glTexCoordIn with redeclaration (with explicit size) and with 2# non-constant indices. 3# 4# From the ARB_geometry_shader4 spec (section ): 5# "Indices used to subscript gl_TexCoord must either be an integral constant 6# expressions, or this array must be re-declared by the shader with a size." 7# 8# And from the GLSL 1.1 spec page 99 (page 105 of the PDF): 9# "Multiple modules can declare it [gl_TexCoord] with different sizes, the 10# maximum will be used at link time." 11[require] 12GL >= 2.0 13GLSL >= 1.10 14GL_ARB_geometry_shader4 15 16[vertex shader] 17#version 110 18 19uniform int zero; 20uniform int one; 21uniform int two; 22 23attribute vec4 vertex; 24attribute float offset; 25 26varying float gs_offset; 27varying vec4 gl_TexCoord[3]; 28 29void main() 30{ 31 gl_TexCoord[zero] = vec4(offset + float(0)); 32 gl_TexCoord[one] = vec4(offset + float(1)); 33 gl_TexCoord[two] = vec4(offset + float(2)); 34 35 gs_offset = offset; 36 gl_Position = vertex; 37} 38 39[geometry shader] 40#version 110 41#extension GL_ARB_geometry_shader4: enable 42 43uniform int zero; 44uniform int one; 45 46varying in float gs_offset[]; 47varying in vec4 gl_TexCoordIn[][2]; 48 49varying out float fs_ok; 50 51void main() 52{ 53 bool ok = true; 54 55 if (gl_TexCoordIn[0][zero] != vec4(gs_offset[0] + float(0))) 56 ok = false; 57 if (gl_TexCoordIn[0][one] != vec4(gs_offset[0] + float(1))) 58 ok = false; 59 if (gl_TexCoordIn[1][zero] != vec4(gs_offset[1] + float(0))) 60 ok = false; 61 if (gl_TexCoordIn[1][one] != vec4(gs_offset[1] + float(1))) 62 ok = false; 63 if (gl_TexCoordIn[2][zero] != vec4(gs_offset[2] + float(0))) 64 ok = false; 65 if (gl_TexCoordIn[2][one] != vec4(gs_offset[2] + float(1))) 66 ok = false; 67 68 for (int i = 0; i < 3; ++i) { 69 fs_ok = float(ok); 70 gl_Position = gl_PositionIn[i]; 71 EmitVertex(); 72 } 73} 74 75[geometry layout] 76input type GL_TRIANGLES 77output type GL_TRIANGLE_STRIP 78vertices out 3 79 80[fragment shader] 81#version 110 82 83varying float fs_ok; 84 85void main() 86{ 87 if (distance(fs_ok, 1.0) < 1e-6) 88 gl_FragColor = vec4(0, 1, 0, 1); 89 else 90 gl_FragColor = vec4(1, 0, 0, 1); 91} 92 93[vertex data] 94vertex/float/2 offset/float/1 95-1.0 -1.0 1.0 96 1.0 -1.0 2.0 97 1.0 1.0 3.0 98-1.0 1.0 4.0 99 100[test] 101uniform int zero 0 102uniform int one 1 103uniform int two 2 104draw arrays GL_TRIANGLE_FAN 0 4 105probe all rgb 0 1 0 106