3 GL_MESA_shader_integer_functions
5 [vertex shader passthrough]
8 #extension GL_MESA_shader_integer_functions : enable
12 uniform bool test_signed;
14 uniform ivec4 iextract;
16 uniform uvec4 uextract;
19 uniform int offset, bits;
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);
35 # Corner case: bits == 0 -> result == 0
39 uniform int test_signed 1
40 uniform ivec4 iextract 0 0 0 0
41 uniform ivec4 iinput 2147483647 15 7 3
43 probe all rgba 0.0 1.0 0.0 1.0
45 uniform int test_signed 0
46 uniform uvec4 uextract 0 0 0 0
47 uniform uvec4 uinput 0xFFFFFFFF 15 7 3
49 probe all rgba 0.0 1.0 0.0 1.0
51 # Test that the most significant bits of the result get the sign extension of
52 # the bits extracted from <value>.
56 # Extract a single signed "1"-bit and sign-extend it, yielding 0xFFFFFFFF (-1).
57 uniform int test_signed 1
58 uniform ivec4 iextract -1 -1 -1 -1
59 uniform ivec4 iinput 1 1 1 1
61 probe all rgba 0.0 1.0 0.0 1.0
63 # Extract a single unsigned "1"-bit and sign-extend it, yielding 0x00000001 (1).
64 uniform int test_signed 0
65 uniform uvec4 uextract 1 1 1 1
66 uniform uvec4 uinput 1 1 1 1
68 probe all rgba 0.0 1.0 0.0 1.0
70 # Extract two signed bits (01) and sign-extend it, yielding 0x00000001 (1).
71 # Extract two signed bits (11) and sign-extend it, yielding 0xFFFFFFFF (1).
73 uniform int test_signed 1
74 uniform ivec4 iextract 1 -1 -1 1
75 uniform ivec4 iinput 1 3 3 1
77 probe all rgba 0.0 1.0 0.0 1.0
79 # Test some other various values.
83 uniform int test_signed 1
84 uniform ivec4 iextract -1 0 1 3
85 # 983040 is 0x000F0000.
86 # 61440 is 0x0000F000.
87 # 114688 is 0x0001C000.
88 # 229376 is 0x00038000.
89 uniform ivec4 iinput 983040 61440 114688 229376
91 probe all rgba 0.0 1.0 0.0 1.0
93 uniform int test_signed 0
94 uniform uvec4 uextract 0xF 0x0 0x1 0x3
95 uniform uvec4 uinput 0x000F0000 0x0000F000 0x0001C000 0x00038000
97 probe all rgba 0.0 1.0 0.0 1.0
99 # Copy the whole integer
103 uniform int test_signed 1
104 uniform ivec4 iextract 3203386110 3735928559 2343432205 3741239934
105 uniform ivec4 iinput 3203386110 3735928559 2343432205 3741239934
107 probe all rgba 0.0 1.0 0.0 1.0
109 uniform int test_signed 0
110 uniform uvec4 uextract 0xBEEFCAFE 0xDEADBEEF 0x8BADF00D 0xDEFECA7E
111 uniform uvec4 uinput 0xBEEFCAFE 0xDEADBEEF 0x8BADF00D 0xDEFECA7E
113 probe all rgba 0.0 1.0 0.0 1.0