diff options
Diffstat (limited to 'tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test')
-rw-r--r-- | tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test new file mode 100644 index 00000000..2cb0105b --- /dev/null +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test @@ -0,0 +1,147 @@ +# From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special +# Variables): +# +# Values written into gl_ClipDistance for planes that are not +# enabled have no effect. +# +# This test sets up 6 clipping planes using gl_ClipDistance, which +# clip a rectangle to a hexagon shape. Then it tests various +# combinations of enables for the 6 clipping planes, and verifies that +# they all create the correct shape. +# +# To verify that each enable works, the combinations of enables were +# chosen such that: +# - Every plane is enabled at least once and disbled at least once. +# - Every plane is enabled and disabled in a different pattern. + +[require] +GLSL >= 1.30 + +[vertex shader] +#version 130 +void main(void) +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + gl_ClipDistance[0] = gl_Vertex.y - 0.25; + gl_ClipDistance[1] = gl_Vertex.y - gl_Vertex.x + 0.4; + gl_ClipDistance[2] = 1.4 - gl_Vertex.x - gl_Vertex.y; + gl_ClipDistance[3] = 0.75 - gl_Vertex.y; + gl_ClipDistance[4] = gl_Vertex.x - gl_Vertex.y + 0.4; + gl_ClipDistance[5] = gl_Vertex.x + gl_Vertex.y - 0.6; +} + +[fragment shader] +#version 130 +void main(void) +{ + gl_FragColor = vec4(1, 1, 1, 1); +} + +[test] +ortho 0 1 0 1 +clear color 0.0 0.0 0.0 0.0 + +# Test with planes 0, 2, and 4 enabled. +enable GL_CLIP_PLANE0 +disable GL_CLIP_PLANE1 +enable GL_CLIP_PLANE2 +disable GL_CLIP_PLANE3 +enable GL_CLIP_PLANE4 +disable GL_CLIP_PLANE5 +clear +draw rect 0.1 0.1 0.8 0.8 + +# Test points inside each hexagon edge +relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0) + +# Test points outside each hexagon edge +relative probe rgba (0.5, 0.2) (0.0, 0.0, 0.0, 0.0) # clipped by plane 0 +relative probe rgba (0.8, 0.3) (1.0, 1.0, 1.0, 1.0) # clipped by plane 1 +relative probe rgba (0.8, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 2 +relative probe rgba (0.5, 0.8) (1.0, 1.0, 1.0, 1.0) # clipped by plane 3 +relative probe rgba (0.2, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 4 +relative probe rgba (0.2, 0.3) (1.0, 1.0, 1.0, 1.0) # clipped by plane 5 + +# Test with planes 0, 1, 4, and 5 enabled. +enable GL_CLIP_PLANE0 +enable GL_CLIP_PLANE1 +disable GL_CLIP_PLANE2 +disable GL_CLIP_PLANE3 +enable GL_CLIP_PLANE4 +enable GL_CLIP_PLANE5 +clear +draw rect 0.1 0.1 0.8 0.8 + +# Test points inside each hexagon edge +relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0) + +# Test points outside each hexagon edge +relative probe rgba (0.5, 0.2) (0.0, 0.0, 0.0, 0.0) # clipped by plane 0 +relative probe rgba (0.8, 0.3) (0.0, 0.0, 0.0, 0.0) # clipped by plane 1 +relative probe rgba (0.8, 0.7) (1.0, 1.0, 1.0, 1.0) # clipped by plane 2 +relative probe rgba (0.5, 0.8) (1.0, 1.0, 1.0, 1.0) # clipped by plane 3 +relative probe rgba (0.2, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 4 +relative probe rgba (0.2, 0.3) (0.0, 0.0, 0.0, 0.0) # clipped by plane 5 + +# Test with planes 0, 1, 2, and 3 enabled. +enable GL_CLIP_PLANE0 +enable GL_CLIP_PLANE1 +enable GL_CLIP_PLANE2 +enable GL_CLIP_PLANE3 +disable GL_CLIP_PLANE4 +disable GL_CLIP_PLANE5 +clear +draw rect 0.1 0.1 0.8 0.8 + +# Test points inside each hexagon edge +relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0) + +# Test points outside each hexagon edge +relative probe rgba (0.5, 0.2) (0.0, 0.0, 0.0, 0.0) # clipped by plane 0 +relative probe rgba (0.8, 0.3) (0.0, 0.0, 0.0, 0.0) # clipped by plane 1 +relative probe rgba (0.8, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 2 +relative probe rgba (0.5, 0.8) (0.0, 0.0, 0.0, 0.0) # clipped by plane 3 +relative probe rgba (0.2, 0.7) (1.0, 1.0, 1.0, 1.0) # clipped by plane 4 +relative probe rgba (0.2, 0.3) (1.0, 1.0, 1.0, 1.0) # clipped by plane 5 + +# Test with planes 4 and 5 enabled. +disable GL_CLIP_PLANE0 +disable GL_CLIP_PLANE1 +disable GL_CLIP_PLANE2 +disable GL_CLIP_PLANE3 +enable GL_CLIP_PLANE4 +enable GL_CLIP_PLANE5 +clear +draw rect 0.1 0.1 0.8 0.8 + +# Test points inside each hexagon edge +relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0) + +# Test points outside each hexagon edge +relative probe rgba (0.5, 0.2) (1.0, 1.0, 1.0, 1.0) # clipped by plane 0 +relative probe rgba (0.8, 0.3) (1.0, 1.0, 1.0, 1.0) # clipped by plane 1 +relative probe rgba (0.8, 0.7) (1.0, 1.0, 1.0, 1.0) # clipped by plane 2 +relative probe rgba (0.5, 0.8) (1.0, 1.0, 1.0, 1.0) # clipped by plane 3 +relative probe rgba (0.2, 0.7) (0.0, 0.0, 0.0, 0.0) # clipped by plane 4 +relative probe rgba (0.2, 0.3) (0.0, 0.0, 0.0, 0.0) # clipped by plane 5 |