arb_program_interface_query: set vs_input2[1][0] as valid name
[piglit.git] / tests / spec / glsl-1.30 / execution / clipping / vs-clip-distance-bulk-assign.shader_test
blob542bf6dad8c91d5a46daeb4714abc534b799cca5
1 # [description]
2 # Verify that gl_ClipDistance works properly under bulk array assignment.
4 # This test initializes an array of 8 floats to represent clip
5 # distances, then copies the values into gl_ClipDistance using bulk
6 # array assignment, then copies the values back to an array of 8
7 # floats using bulk array assignment.
9 # Then it checks two things:
10 # - That no data was corrupted when copying the array
11 # - That clipping occurred as expected
13 # To check that clipping occurred as expected, the 8 gl_ClipDistance
14 # values are used to clip a rectangle to an octagon shape.
16 # The octagon is centered at (0.5, 0.5), and has a small radius
17 # (distance from center to perpendicular edge) of 0.4.
19 [require]
20 GLSL >= 1.30
22 [vertex shader]
23 #version 130
25 out float gl_ClipDistance[8];
27 void main(void)
29         gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
31         // Compute 2D coordinates relative to a center point of (0.5,
32         // 0.5).
33         vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5);
35         float pre_copy[8];
37         for (int i = 0; i < 8; ++i) {
38                 // Compute a unit vector in the direction i*45deg from
39                 // the x axis.
40                 float angle = i*(3.141592653589793/4);
41                 vec2 u = vec2(cos(angle), sin(angle));
43                 // Reject points whose 2D coordinate, projected onto
44                 // that unit vector, is greater than 0.4.
45                 pre_copy[i] = 0.4 - dot(u, coord);
46         }
48         gl_ClipDistance = pre_copy;
50         float post_copy[8];
51         post_copy = gl_ClipDistance;
53         for (int i = 0; i < 8; ++i) {
54                 if (pre_copy[i] != gl_ClipDistance[i]) {
55                         gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
56                         return;
57                 } else if (post_copy[i] != gl_ClipDistance[i]) {
58                         gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
59                         return;
60                 }
61         }
62         gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);
65 [fragment shader]
66 #version 130
67 void main(void)
69         gl_FragColor = gl_Color;
72 [test]
73 clear color 0.0 0.0 0.0 0.0
74 clear
75 ortho 0 1 0 1
76 enable GL_CLIP_PLANE0
77 enable GL_CLIP_PLANE1
78 enable GL_CLIP_PLANE2
79 enable GL_CLIP_PLANE3
80 enable GL_CLIP_PLANE4
81 enable GL_CLIP_PLANE5
82 enable GL_CLIP_PLANE6
83 enable GL_CLIP_PLANE7
84 draw rect 0.0 0.0 1.0 1.0
86 # Test points inside each octagon edge
87 relative probe rgba (0.850, 0.500) (0.0, 1.0, 0.0, 1.0)
88 relative probe rgba (0.747, 0.747) (0.0, 1.0, 0.0, 1.0)
89 relative probe rgba (0.500, 0.850) (0.0, 1.0, 0.0, 1.0)
90 relative probe rgba (0.253, 0.747) (0.0, 1.0, 0.0, 1.0)
91 relative probe rgba (0.150, 0.500) (0.0, 1.0, 0.0, 1.0)
92 relative probe rgba (0.253, 0.253) (0.0, 1.0, 0.0, 1.0)
93 relative probe rgba (0.500, 0.150) (0.0, 1.0, 0.0, 1.0)
94 relative probe rgba (0.747, 0.253) (0.0, 1.0, 0.0, 1.0)
96 # Test points outside each octagon edge
97 relative probe rgba (0.950, 0.500) (0.0, 0.0, 0.0, 0.0)
98 relative probe rgba (0.818, 0.818) (0.0, 0.0, 0.0, 0.0)
99 relative probe rgba (0.500, 0.950) (0.0, 0.0, 0.0, 0.0)
100 relative probe rgba (0.182, 0.818) (0.0, 0.0, 0.0, 0.0)
101 relative probe rgba (0.050, 0.500) (0.0, 0.0, 0.0, 0.0)
102 relative probe rgba (0.182, 0.182) (0.0, 0.0, 0.0, 0.0)
103 relative probe rgba (0.500, 0.050) (0.0, 0.0, 0.0, 0.0)
104 relative probe rgba (0.818, 0.182) (0.0, 0.0, 0.0, 0.0)