1 # This test sets up 6 clipping planes using gl_ClipVertex, which clip
2 # a rectangle to a hexagon shape. Then it tests various combinations
3 # of enables for the 6 clipping planes, and verifies that they all
4 # create the correct shape.
6 # To verify that each enable works, the combinations of enables were
8 # - Every plane is enabled at least once and disabled at least once.
9 # - Every plane is enabled and disabled in a different pattern.
11 # Note: Some implementations have bugs related to improper coordinate
12 # transformations of clip planes (which are already adequately tested
13 # by the clip-plane-transformation test), so to avoid those bugs
14 # contaminating the results of this test, we don't do any coordinate
15 # transformation in this test.
20 GL_ARB_tessellation_shader
23 #version 150 compatibility
25 in vec4 piglit_vertex;
29 gl_Position = piglit_vertex;
31 gl_ClipVertex = gl_Position;
34 [tessellation control shader]
35 #version 150 compatibility
36 #extension GL_ARB_tessellation_shader: require
38 layout(vertices = 3) out;
41 gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
42 gl_out[gl_InvocationID].gl_ClipVertex = gl_in[gl_InvocationID].gl_ClipVertex;
43 gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 0.0);
44 gl_TessLevelInner = float[2](0.0, 0.0);
47 [tessellation evaluation shader]
48 #version 150 compatibility
49 #extension GL_ARB_tessellation_shader: require
54 gl_Position = gl_in[0].gl_Position * gl_TessCoord[0]
55 + gl_in[1].gl_Position * gl_TessCoord[1]
56 + gl_in[2].gl_Position * gl_TessCoord[2];
58 gl_ClipVertex = gl_in[0].gl_ClipVertex * gl_TessCoord[0]
59 + gl_in[1].gl_ClipVertex * gl_TessCoord[1]
60 + gl_in[2].gl_ClipVertex * gl_TessCoord[2];
67 gl_FragColor = vec4(1, 1, 1, 1);
80 clip plane 0 0 1 0 0.5
81 clip plane 1 -1 1 0 0.8
82 clip plane 2 -1 -1 0 0.8
83 clip plane 3 0 -1 0 0.5
84 clip plane 4 1 -1 0 0.8
85 clip plane 5 1 1 0 0.8
86 clear color 0.0 0.0 0.0 0.0
88 # Test with planes 0, 2, and 4 enabled.
90 disable GL_CLIP_PLANE1
92 disable GL_CLIP_PLANE3
94 disable GL_CLIP_PLANE5
96 patch parameter vertices 3
97 draw arrays GL_PATCHES 0 6
99 # Test points inside each hexagon edge
100 relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0)
101 relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0)
102 relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0)
103 relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0)
104 relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0)
105 relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0)
107 # Test points outside each hexagon edge
108 relative probe rgba (0.5, 0.2) (0.0, 0.0, 0.0, 0.0) # clipped by plane 0
109 relative probe rgba (0.8, 0.3) (1.0, 1.0, 1.0, 1.0) # clipped by plane 1
110 relative probe rgba (0.8, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 2
111 relative probe rgba (0.5, 0.8) (1.0, 1.0, 1.0, 1.0) # clipped by plane 3
112 relative probe rgba (0.2, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 4
113 relative probe rgba (0.2, 0.3) (1.0, 1.0, 1.0, 1.0) # clipped by plane 5
115 # Test with planes 0, 1, 4, and 5 enabled.
116 enable GL_CLIP_PLANE0
117 enable GL_CLIP_PLANE1
118 disable GL_CLIP_PLANE2
119 disable GL_CLIP_PLANE3
120 enable GL_CLIP_PLANE4
121 enable GL_CLIP_PLANE5
123 patch parameter vertices 3
124 draw arrays GL_PATCHES 0 6
126 # Test points inside each hexagon edge
127 relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0)
128 relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0)
129 relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0)
130 relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0)
131 relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0)
132 relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0)
134 # Test points outside each hexagon edge
135 relative probe rgba (0.5, 0.2) (0.0, 0.0, 0.0, 0.0) # clipped by plane 0
136 relative probe rgba (0.8, 0.3) (0.0, 0.0, 0.0, 0.0) # clipped by plane 1
137 relative probe rgba (0.8, 0.7) (1.0, 1.0, 1.0, 1.0) # clipped by plane 2
138 relative probe rgba (0.5, 0.8) (1.0, 1.0, 1.0, 1.0) # clipped by plane 3
139 relative probe rgba (0.2, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 4
140 relative probe rgba (0.2, 0.3) (0.0, 0.0, 0.0, 0.0) # clipped by plane 5
142 # Test with planes 0, 1, 2, and 3 enabled.
143 enable GL_CLIP_PLANE0
144 enable GL_CLIP_PLANE1
145 enable GL_CLIP_PLANE2
146 enable GL_CLIP_PLANE3
147 disable GL_CLIP_PLANE4
148 disable GL_CLIP_PLANE5
150 patch parameter vertices 3
151 draw arrays GL_PATCHES 0 6
153 # Test points inside each hexagon edge
154 relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0)
155 relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0)
156 relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0)
157 relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0)
158 relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0)
159 relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0)
161 # Test points outside each hexagon edge
162 relative probe rgba (0.5, 0.2) (0.0, 0.0, 0.0, 0.0) # clipped by plane 0
163 relative probe rgba (0.8, 0.3) (0.0, 0.0, 0.0, 0.0) # clipped by plane 1
164 relative probe rgba (0.8, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 2
165 relative probe rgba (0.5, 0.8) (0.0, 0.0, 0.0, 0.0) # clipped by plane 3
166 relative probe rgba (0.2, 0.7) (1.0, 1.0, 1.0, 1.0) # clipped by plane 4
167 relative probe rgba (0.2, 0.3) (1.0, 1.0, 1.0, 1.0) # clipped by plane 5
169 # Test with planes 4 and 5 enabled.
170 disable GL_CLIP_PLANE0
171 disable GL_CLIP_PLANE1
172 disable GL_CLIP_PLANE2
173 disable GL_CLIP_PLANE3
174 enable GL_CLIP_PLANE4
175 enable GL_CLIP_PLANE5
177 patch parameter vertices 3
178 draw arrays GL_PATCHES 0 6
180 # Test points inside each hexagon edge
181 relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0)
182 relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0)
183 relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0)
184 relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0)
185 relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0)
186 relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0)
188 # Test points outside each hexagon edge
189 relative probe rgba (0.5, 0.2) (1.0, 1.0, 1.0, 1.0) # clipped by plane 0
190 relative probe rgba (0.8, 0.3) (1.0, 1.0, 1.0, 1.0) # clipped by plane 1
191 relative probe rgba (0.8, 0.7) (1.0, 1.0, 1.0, 1.0) # clipped by plane 2
192 relative probe rgba (0.5, 0.8) (1.0, 1.0, 1.0, 1.0) # clipped by plane 3
193 relative probe rgba (0.2, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 4
194 relative probe rgba (0.2, 0.3) (0.0, 0.0, 0.0, 0.0) # clipped by plane 5