summaryrefslogtreecommitdiff
path: root/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-implicitly-sized.shader_test
blob: 185fb22e5c4c3d7a88237f453f21e0b85933aea6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# From the GLSL 1.30 spec section 7.1 (Vertex Shader Special
# Variables):
#
#   The gl_ClipDistance array is predeclared as unsized and must be
#   sized by the shader either redeclaring it with a size or indexing
#   it only with integral constant expressions. This needs to size the
#   array to include all the clip planes that are enabled via the
#   OpenGL API; if the size does not include all enabled planes,
#   results are undefined. The size can be at most
#   gl_MaxClipDistances. The number of varying components (see
#   gl_MaxVaryingComponents) consumed by gl_ClipDistance will match
#   the size of the array, no matter how many planes are enabled. The
#   shader must also set all values in gl_ClipDistance that have been
#   enabled via the OpenGL API, or results are undefined. Values
#   written into gl_ClipDistance for planes that are not enabled have
#   no effect.
#
# This test checks that the GLSL compiler respects the size of
# gl_ClipDistance when it is implicitly sized in the vertex shader by
# indexing into it with integral constant expressions.
#
# The spec isn't clear about whether it's necessary for the GLSL
# compiler to size gl_ClipDistance to the minimum size possible.  In
# other words, if only gl_ClipDistance[2] is accessed, must the
# compiler infer that the size of gl_ClipDistance is 3, or is any size
# greater than or equal to 3 acceptable?  This test assumes any size
# greater than or equal to 3 is acceptable.

[require]
GLSL >= 1.30

[vertex shader]
#version 130

void main()
{
  gl_Position = gl_Vertex;
  gl_FrontColor = (gl_ClipDistance.length() >= 3) ? vec4(0.0, 1.0, 0.0, 1.0)
                                                  : vec4(1.0, 0.0, 0.0, 1.0);
  gl_ClipDistance[2] = 1.0;
}

[fragment shader]
#version 130
void main()
{
  gl_FragColor = gl_Color;
}

[test]
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0