-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathabs_fp64.shader_test
57 lines (47 loc) · 1.08 KB
/
abs_fp64.shader_test
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
# Absolute value of a double
# IEEE 754 compliant
[require]
GLSL >= 1.30
[vertex shader]
#version 130
void main()
{
gl_Position = gl_Vertex;
}
[fragment shader]
#version 130
/* Absolute value of a Float64 :
* Clear the sign bit
*/
uvec2
abs_fp64( uvec2 a )
{
a.x &= 0x7FFFFFFFu;
return a;
}
uniform uvec2 a;
uniform uvec2 expected;
void main()
{
/* Generate green if the expected value is produced, red
* otherwise.
*/
gl_FragColor = abs_fp64(a) == expected
? vec4(0.0, 1.0, 0.0, 1.0)
: vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
# A bunch of tests to run. The 'uniform' lines set the uniforms. The
# 'draw rect' line draws a rectangle that covers the whole window.
# The 'probe all' line verifies that every pixel contains the expected
# color.
# Try +0.0
uniform uvec2 a 0x00000000 0x00000000
uniform uvec2 expected 0x00000000 0x00000000
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
# Try -0.0
uniform uvec2 a 0x80000000 0x00000000
uniform uvec2 expected 0x00000000 0x00000000
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0