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
|
[require]
GLSL >= 1.50
GL_ARB_gpu_shader5
[vertex shader]
#extension GL_ARB_gpu_shader5 : enable
in vec4 piglit_vertex;
out vec4 color;
uniform bool test_signed;
uniform ivec4 iextract;
uniform ivec4 iinput;
uniform uvec4 uextract;
uniform uvec4 uinput;
uniform int offset, bits;
void main() {
gl_Position = piglit_vertex;
/* Green if both pass. */
color = vec4(0.0, 1.0, 0.0, 1.0);
if (test_signed && iextract != bitfieldExtract(iinput, offset, bits))
/* Red if bitfieldExtract(ivec4, ...) fails. */
color = vec4(1.0, 0.0, 0.0, 1.0);
else if (!test_signed && uextract != bitfieldExtract(uinput, offset, bits))
/* Blue if bitfieldExtract(uvec4, ...) fails. */
color = vec4(0.0, 0.0, 1.0, 1.0);
}
[fragment shader]
in vec4 color;
out vec4 frag_color;
void main()
{
frag_color = color;
}
[test]
# Corner case: bits == 0 -> result == 0
uniform int bits 0
uniform int offset 32
uniform int test_signed 1
uniform ivec4 iextract 0 0 0 0
uniform ivec4 iinput 2147483647 15 7 3
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
uniform int test_signed 0
uniform uvec4 uextract 0 0 0 0
uniform uvec4 uinput 0xFFFFFFFF 15 7 3
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
# Test that the most significant bits of the result get the sign extension of
# the bits extracted from <value>.
uniform int bits 1
uniform int offset 0
# Extract a single signed "1"-bit and sign-extend it, yielding 0xFFFFFFFF (-1).
uniform int test_signed 1
uniform ivec4 iextract -1 -1 -1 -1
uniform ivec4 iinput 1 1 1 1
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
# Extract a single unsigned "1"-bit and sign-extend it, yielding 0x00000001 (1).
uniform int test_signed 0
uniform uvec4 uextract 1 1 1 1
uniform uvec4 uinput 1 1 1 1
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
# Extract two signed bits (01) and sign-extend it, yielding 0x00000001 (1).
# Extract two signed bits (11) and sign-extend it, yielding 0xFFFFFFFF (1).
uniform int bits 2
uniform int test_signed 1
uniform ivec4 iextract 1 -1 -1 1
uniform ivec4 iinput 1 3 3 1
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
# Test some other various values.
uniform int bits 4
uniform int offset 16
uniform int test_signed 1
uniform ivec4 iextract -1 0 1 3
# 983040 is 0x000F0000.
# 61440 is 0x0000F000.
# 114688 is 0x0001C000.
# 229376 is 0x00038000.
uniform ivec4 iinput 983040 61440 114688 229376
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
uniform int test_signed 0
uniform uvec4 uextract 0xF 0x0 0x1 0x3
uniform uvec4 uinput 0x000F0000 0x0000F000 0x0001C000 0x00038000
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
# Copy the whole integer
uniform int bits 32
uniform int offset 0
uniform int test_signed 1
uniform ivec4 iextract 3203386110 3735928559 2343432205 3741239934
uniform ivec4 iinput 3203386110 3735928559 2343432205 3741239934
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
uniform int test_signed 0
uniform uvec4 uextract 0xBEEFCAFE 0xDEADBEEF 0x8BADF00D 0xDEFECA7E
uniform uvec4 uinput 0xBEEFCAFE 0xDEADBEEF 0x8BADF00D 0xDEFECA7E
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
|