blob: 48feac7265a05929ce5e5e87c3f3ca4391c8afee (
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
|
[require]
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
/* This test requires version 1.20 because it depends on the new constant
* expression rules added in 1.20.
*/
/* All references to bad_constant_folding should be optimized away at compile
* time. If not, link errors will be generated, and the test will fail.
*/
void bad_constant_folding();
uniform float val;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);
if (false)
bad_constant_folding();
else if (degrees(0.0) != 0.0)
bad_constant_folding();
else if (radians(0.0) != 0.0)
bad_constant_folding();
else if (sqrt(0.0) != 0.0)
bad_constant_folding();
else if (sqrt(1.0) != 1.0)
bad_constant_folding();
else if (inversesqrt(1.0) != 1.0)
bad_constant_folding();
else if (exp(0.0) != 1.0)
bad_constant_folding();
else if (exp(1.0) <= 2.718)
bad_constant_folding();
else if (exp(1.0) >= 2.719)
bad_constant_folding();
else if (exp2(0.0) != 1.0)
bad_constant_folding();
else if (exp2(1.0) != 2.0)
bad_constant_folding();
else if (tan(0.0) != 0.0)
bad_constant_folding();
else if (log(1.0) != 0.0)
bad_constant_folding();
else if (log2(1.0) != 0.0)
bad_constant_folding();
else if (sin(0.0) != 0.0)
bad_constant_folding();
else if (cos(0.0) != 1.0)
bad_constant_folding();
else if (tan(0.0) != 0.0)
bad_constant_folding();
else if (asin(0.0) != 0.0)
bad_constant_folding();
else if (acos(1.0) != 0.0)
bad_constant_folding();
else if (atan(0.0) != 0.0)
bad_constant_folding();
else if (atan(1.0) <= (3.1415 / 4.0))
bad_constant_folding();
else if (atan(1.0) >= (3.1416 / 4.0))
bad_constant_folding();
else if (abs(1.0) != 1.0)
bad_constant_folding();
else if (abs(-1.0) != 1.0)
bad_constant_folding();
else if (sign(42.0) != 1.0)
bad_constant_folding();
else if (sign(-42.0) != -1.0)
bad_constant_folding();
else if (sign(0.0) != 0.0)
bad_constant_folding();
#if 0
/* The GLSL spec doesn't actually require that these be considered
* constant expressions, but any sensible implementation should
* evaluate them as constants and remove the calls to
* bad_constant_folding.
*/
else if (pow(val, 0.0) != 1.0)
bad_constant_folding();
else if (pow(1.0, val) != 1.0)
bad_constant_folding();
#endif
else
gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);
}
[test]
draw rect -1 -1 2 2
probe all rgb 0.0 1.0 0.0
|