3 GL_MESA_shader_integer_functions
6 #extension GL_MESA_shader_integer_functions : enable
11 uniform bool test_signed;
13 uniform ivec4 iextract;
15 uniform uvec4 uextract;
18 uniform int offset, bits;
21 gl_Position = piglit_vertex;
23 /* Green if both pass. */
24 color = vec4(0.0, 1.0, 0.0, 1.0);
26 if (test_signed && iextract != bitfieldExtract(iinput, offset, bits))
27 /* Red if bitfieldExtract(ivec4, ...) fails. */
28 color = vec4(1.0, 0.0, 0.0, 1.0);
29 else if (!test_signed && uextract != bitfieldExtract(uinput, offset, bits))
30 /* Blue if bitfieldExtract(uvec4, ...) fails. */
31 color = vec4(0.0, 0.0, 1.0, 1.0);
44 # Corner case: bits == 0 -> result == 0
48 uniform int test_signed 1
49 uniform ivec4 iextract 0 0 0 0
50 uniform ivec4 iinput 2147483647 15 7 3
52 probe all rgba 0.0 1.0 0.0 1.0
54 uniform int test_signed 0
55 uniform uvec4 uextract 0 0 0 0
56 uniform uvec4 uinput 0xFFFFFFFF 15 7 3
58 probe all rgba 0.0 1.0 0.0 1.0
60 # Test that the most significant bits of the result get the sign extension of
61 # the bits extracted from <value>.
65 # Extract a single signed "1"-bit and sign-extend it, yielding 0xFFFFFFFF (-1).
66 uniform int test_signed 1
67 uniform ivec4 iextract -1 -1 -1 -1
68 uniform ivec4 iinput 1 1 1 1
70 probe all rgba 0.0 1.0 0.0 1.0
72 # Extract a single unsigned "1"-bit and sign-extend it, yielding 0x00000001 (1).
73 uniform int test_signed 0
74 uniform uvec4 uextract 1 1 1 1
75 uniform uvec4 uinput 1 1 1 1
77 probe all rgba 0.0 1.0 0.0 1.0
79 # Extract two signed bits (01) and sign-extend it, yielding 0x00000001 (1).
80 # Extract two signed bits (11) and sign-extend it, yielding 0xFFFFFFFF (1).
82 uniform int test_signed 1
83 uniform ivec4 iextract 1 -1 -1 1
84 uniform ivec4 iinput 1 3 3 1
86 probe all rgba 0.0 1.0 0.0 1.0
88 # Test some other various values.
92 uniform int test_signed 1
93 uniform ivec4 iextract -1 0 1 3
94 # 983040 is 0x000F0000.
95 # 61440 is 0x0000F000.
96 # 114688 is 0x0001C000.
97 # 229376 is 0x00038000.
98 uniform ivec4 iinput 983040 61440 114688 229376
100 probe all rgba 0.0 1.0 0.0 1.0
102 uniform int test_signed 0
103 uniform uvec4 uextract 0xF 0x0 0x1 0x3
104 uniform uvec4 uinput 0x000F0000 0x0000F000 0x0001C000 0x00038000
106 probe all rgba 0.0 1.0 0.0 1.0
108 # Copy the whole integer
112 uniform int test_signed 1
113 uniform ivec4 iextract 3203386110 3735928559 2343432205 3741239934
114 uniform ivec4 iinput 3203386110 3735928559 2343432205 3741239934
116 probe all rgba 0.0 1.0 0.0 1.0
118 uniform int test_signed 0
119 uniform uvec4 uextract 0xBEEFCAFE 0xDEADBEEF 0x8BADF00D 0xDEFECA7E
120 uniform uvec4 uinput 0xBEEFCAFE 0xDEADBEEF 0x8BADF00D 0xDEFECA7E
122 probe all rgba 0.0 1.0 0.0 1.0