summaryrefslogtreecommitdiff
path: root/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test
blob: 2cb0105b1bba62789cb9888179b054b25fcd322e (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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