perf/pixel-rate: new pixel throughput microbenchmark
[piglit.git] / tests / spec / glsl-1.30 / execution / clipping / vs-clip-distance-uint-index.shader_test
blobb3da1f85f68d4bb2099f574d5b1fa8f06b46337f
1 # [description]
2 # Verify that gl_ClipDistance works properly when accessed with a
3 # uint index.
5 # This test uses all 8 gl_ClipDistance values to clip a rectangle to
6 # an octagon shape.
8 # The octagon is centered at (0.5, 0.5), and has a small radius
9 # (distance from center to perpendicular edge) of 0.4.
11 [require]
12 GLSL >= 1.30
14 [vertex shader]
15 #version 130
17 out float gl_ClipDistance[8];
19 void main(void)
21         gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
23         // Compute 2D coordinates relative to a center point of (0.5,
24         // 0.5).
25         vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5);
27         for (int i = 0; i < 8; ++i) {
28                 uint j = uint(i);
30                 // Compute a unit vector in the direction i*45deg from
31                 // the x axis.
32                 float angle = i*(3.141592653589793/4);
33                 vec2 u = vec2(cos(angle), sin(angle));
35                 // Reject points whose 2D coordinate, projected onto
36                 // that unit vector, is greater than 0.4.
37                 gl_ClipDistance[j] = 0.4 - dot(u, coord);
38         }
41 [fragment shader]
42 #version 130
43 void main(void)
45         gl_FragColor = vec4(1, 1, 1, 1);
48 [test]
49 clear color 0.0 0.0 0.0 0.0
50 clear
51 ortho 0 1 0 1
52 enable GL_CLIP_PLANE0
53 enable GL_CLIP_PLANE1
54 enable GL_CLIP_PLANE2
55 enable GL_CLIP_PLANE3
56 enable GL_CLIP_PLANE4
57 enable GL_CLIP_PLANE5
58 enable GL_CLIP_PLANE6
59 enable GL_CLIP_PLANE7
60 draw rect 0.0 0.0 1.0 1.0
62 # Test points inside each hexagon edge
63 relative probe rgba (0.850, 0.500) (1.0, 1.0, 1.0, 1.0)
64 relative probe rgba (0.747, 0.747) (1.0, 1.0, 1.0, 1.0)
65 relative probe rgba (0.500, 0.850) (1.0, 1.0, 1.0, 1.0)
66 relative probe rgba (0.253, 0.747) (1.0, 1.0, 1.0, 1.0)
67 relative probe rgba (0.150, 0.500) (1.0, 1.0, 1.0, 1.0)
68 relative probe rgba (0.253, 0.253) (1.0, 1.0, 1.0, 1.0)
69 relative probe rgba (0.500, 0.150) (1.0, 1.0, 1.0, 1.0)
70 relative probe rgba (0.747, 0.253) (1.0, 1.0, 1.0, 1.0)
72 # Test points outside each hexagon edge
73 relative probe rgba (0.950, 0.500) (0.0, 0.0, 0.0, 0.0)
74 relative probe rgba (0.818, 0.818) (0.0, 0.0, 0.0, 0.0)
75 relative probe rgba (0.500, 0.950) (0.0, 0.0, 0.0, 0.0)
76 relative probe rgba (0.182, 0.818) (0.0, 0.0, 0.0, 0.0)
77 relative probe rgba (0.050, 0.500) (0.0, 0.0, 0.0, 0.0)
78 relative probe rgba (0.182, 0.182) (0.0, 0.0, 0.0, 0.0)
79 relative probe rgba (0.500, 0.050) (0.0, 0.0, 0.0, 0.0)
80 relative probe rgba (0.818, 0.182) (0.0, 0.0, 0.0, 0.0)