fix the spelling in whole piglit
[piglit.git] / tests / spec / glsl-1.30 / execution / clipping / vs-clip-distance-out-param.shader_test
blob07e623cad1bf5c01d28df754867fb12516c6396c
1 # [description]
2 # Verify that gl_ClipDistance works properly when used as a function
3 # "out" parameter.
5 # This test initializes an array of 8 floats to represent clip
6 # distances, then passes them to a function which copies the values
7 # into gl_ClipDistance.
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 foo(in float clip_distance_pre_copy[8], out float clip_distance[8])
29         for (int i = 0; i < 8; ++i) {
30                 clip_distance[i] = clip_distance_pre_copy[i];
31         }
34 void main(void)
36         gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
38         // Compute 2D coordinates relative to a center point of (0.5,
39         // 0.5).
40         vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5);
42         float pre_copy[8];
44         for (int i = 0; i < 8; ++i) {
45                 // Compute a unit vector in the direction i*45deg from
46                 // the x axis.
47                 float angle = i*(3.141592653589793/4);
48                 vec2 u = vec2(cos(angle), sin(angle));
50                 // Reject points whose 2D coordinate, projected onto
51                 // that unit vector, is greater than 0.4.
52                 pre_copy[i] = 0.4 - dot(u, coord);
53         }
55         foo(pre_copy, gl_ClipDistance);
57         for (int i = 0; i < 8; ++i) {
58                 if (pre_copy[i] != gl_ClipDistance[i]) {
59                         gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
60                         return;
61                 }
62         }
63         gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);
66 [fragment shader]
67 #version 130
68 void main(void)
70         gl_FragColor = gl_Color;
73 [test]
74 clear color 0.0 0.0 0.0 0.0
75 clear
76 ortho 0 1 0 1
77 enable GL_CLIP_PLANE0
78 enable GL_CLIP_PLANE1
79 enable GL_CLIP_PLANE2
80 enable GL_CLIP_PLANE3
81 enable GL_CLIP_PLANE4
82 enable GL_CLIP_PLANE5
83 enable GL_CLIP_PLANE6
84 enable GL_CLIP_PLANE7
85 draw rect 0.0 0.0 1.0 1.0
87 # Test points inside each octagon edge
88 relative probe rgba (0.850, 0.500) (0.0, 1.0, 0.0, 1.0)
89 relative probe rgba (0.747, 0.747) (0.0, 1.0, 0.0, 1.0)
90 relative probe rgba (0.500, 0.850) (0.0, 1.0, 0.0, 1.0)
91 relative probe rgba (0.253, 0.747) (0.0, 1.0, 0.0, 1.0)
92 relative probe rgba (0.150, 0.500) (0.0, 1.0, 0.0, 1.0)
93 relative probe rgba (0.253, 0.253) (0.0, 1.0, 0.0, 1.0)
94 relative probe rgba (0.500, 0.150) (0.0, 1.0, 0.0, 1.0)
95 relative probe rgba (0.747, 0.253) (0.0, 1.0, 0.0, 1.0)
97 # Test points outside each octagon edge
98 relative probe rgba (0.950, 0.500) (0.0, 0.0, 0.0, 0.0)
99 relative probe rgba (0.818, 0.818) (0.0, 0.0, 0.0, 0.0)
100 relative probe rgba (0.500, 0.950) (0.0, 0.0, 0.0, 0.0)
101 relative probe rgba (0.182, 0.818) (0.0, 0.0, 0.0, 0.0)
102 relative probe rgba (0.050, 0.500) (0.0, 0.0, 0.0, 0.0)
103 relative probe rgba (0.182, 0.182) (0.0, 0.0, 0.0, 0.0)
104 relative probe rgba (0.500, 0.050) (0.0, 0.0, 0.0, 0.0)
105 relative probe rgba (0.818, 0.182) (0.0, 0.0, 0.0, 0.0)