Name
bitfieldReverse - return the reversed bitfield.
Synopsis
int bitfieldReverse(int x)
int2 bitfieldReverse(int2 x)
int3 bitfieldReverse(int3 x)
int4 bitfieldReverse(int4 x)
uint bitfieldReverse(uint x)
uint2 bitfieldReverse(uint2 x)
uint3 bitfieldReverse(uint3 x)
uint4 bitfieldReverse(uint4 x)
Parameters
- x
-
Bitfield to reverse.
Description
Returns the reverse of the bitfield x.
Reference Implementation
bitfieldReverse for an int bitfield can be implemented like this:
int bitfieldReverse(int x)
{
int res = 0;
int i, shift, mask;
for(i = 0; i < 32; i++) {
mask = 1 << i;
shift = 32 - 2*i - 1;
mask &= x;
mask = (shift > 0) ? mask << shift : mask >> -shift;
res |= mask;
}
return res;
}
Profile Support
bitfieldReverse is supported in gp5 and hlsl11 profiles.
See Also
http://www.opengl.org/registry/specs/ARB/gpu_shader5.txt
bitfieldInsert, bitfieldExtract, bitCount, findLSB and findMSB
|