Name
bitfieldExtract - return an extracted range of bits from a bitfield.
Synopsis
int bitfieldExtract(int a, int b, int c)
int2 bitfieldExtract(int2 a, int b, int c)
int3 bitfieldExtract(int3 a, int b, int c)
int4 bitfieldExtract(int4 a, int b, int c)
uint bitfieldExtract(uint a, int b, int c)
uint2 bitfieldExtract(uint2 a, int b, int c)
uint3 bitfieldExtract(uint3 a, int b, int c)
uint4 bitfieldExtract(uint4 a, int b, int c)
Parameters
- a
-
Bitfield to extract bits from.
- b
-
Bit offset number. Bit offsets start at 0.
- c
-
Number of bits to extract.
Description
Returns bits from offset b of length c in the bitfield a.
Reference Implementation
bitfieldExtract for an int bitfield can be implemented like this:
int bitfieldExtract(int a, int b, int c)
{
int mask = ~(0xffffffff << c);
if (b > 0)
return (a >> (b - 1)) & mask;
else
return a & mask;
}
Profile Support
bitfieldExtract is supported in gp5 profiles.
See Also
http://www.opengl.org/registry/specs/ARB/gpu_shader5.txt
bitfieldInsert, bitfieldReverse, bitCount, findLSB and findMSB
|