class
Bitwise
Class for manipulating bit patterns.
Public
Methods
staticNextPow2
Returns the power-of-two number greater or equal to the provided value.
staticClosestPow2
Returns the power-of-two number closest to the provided value.
staticBitsLog2
Returns base-2 logarithm for common bit counts (8, 16, 32, 64), as a constant expression.
staticModPow
Returns modular exponentiation for integers.
staticMostSignificantBit
Finds the most-significant non-zero bit in the provided value and returns the index of that bit.
staticLeastSignificantBit
Finds the least-significant non-zero bit in the provided value and returns the index of that bit.
staticMostSignificantBit
Finds the most-significant non-zero bit in the provided value and returns the index of that bit.
staticLeastSignificantBit
Finds the least-significant non-zero bit in the provided value and returns the index of that bit.
staticCountSetBits
Count the number of set bits in a mask.
staticFixedToFixed
Convert N bit color channel value to P bits.
It fills P bits with the bit pattern repeated. (this is /((1
<
<n
)-1) in fixed point).
staticUnormToUint
Converts floating point value in range [0, 1] to an unsigned integer of a certain number of bits.
Works for any value of bits between 0 and 31.
staticSnormToUint
Converts floating point value in range [-1, 1] to an unsigned integer of a certain number of bits.
Works for any value of bits between 0 and 31.
staticUintToUnorm
Converts an unsigned integer to a floating point in range [0, 1].
staticUintToSnorm
Converts an unsigned integer to a floating point in range [-1, 1].
staticLerpByte
Interpolates between two values using the parameter.
All parameters must be in [0, 255] range. When is zero, value will be returned, and when it is 255 value will be returned, and interpolation between and will occurr for in-between values.
staticLerpWord
Interpolates between two values using the parameter.
All parameters must be in [0, 65536] range. When is zero, value will be returned, and when it is 65536 value will be returned, and interpolation between and will occurr for in-between values.
staticInvLerpByte
Determines the position of the parameter in the [from, to] range, returned in [0, 255] range where 0 is returned if is less or equal than , and 255 is returned if is equal to greater to , and in-between values returned accordingly.
All values must be in [0, 255] range.
staticInvLerpWord
Determines the position of the parameter in the [from, to] range, returned in [0, 65536] range where 0 is returned if is less or equal than , and 65536 is returned if is equal to greater to , and in-between values returned accordingly.
All values must be in [0, 65536] range.
staticIntWrite
Write a n*8 bits integer value to memory in native endian.
staticIntRead
Read a n*8 bits integer value to memory in native endian.
staticFloatToHalf
Convert a float32 to a float16 (NV_half_float).
staticFloatToHalfI
Converts float in u32 format to a a half in u16 format.
staticHalfToFloat
Convert a float16 (NV_half_float) to a float32.
staticHalfToFloatI
Converts a half in u16 format to a float in u32 format.
staticFloatToFloat10
Converts a 32-bit float to a 10-bit float according to OpenGL packed_float extension.
staticFloatToFloat11
Converts a 32-bit float to a 11-bit float according to OpenGL packed_float extension.
staticFloat10ToFloat
Converts a 10-bit float to a 32-bit float according to OpenGL packed_float extension.
staticFloat11ToFloat
Converts a 11-bit float to a 32-bit float according to OpenGL packed_float extension.
staticEncodeVarInt
Encodes a 32-bit integer value as a base-128 varint.
Varints are a method of serializing integers using one or more bytes, where smaller values use less bytes.
- value
- Value to encode.
- output
- Buffer to store the encoded bytes in. Must be at least 5 bytes in length.
Returns: Number of bytes required to store the value, in range [1, 5]
staticDecodeVarInt
Decodes a value encoded using encodeVarInt(u32, u8*).
- outValue
- Variable to receive the decoded value.
- input
- Input buffer to decode the data from.
- size
- Size of the input buffer.
Returns: Number of bytes read.
staticEncodeVarInt
staticDecodeVarInt
staticEncodeVarInt
Encodes a 64-bit integer value as a base-128 varint.
Varints are a method of serializing integers using one or more bytes, where smaller values use less bytes.
- value
- Value to encode.
- output
- Buffer to store the encoded bytes in. Must be at least 10 bytes in length.
Returns: Number of bytes required to store the value, in range [1, 10]
staticDecodeVarInt
Decodes a value encoded using encodeVarInt(u64, u8*).
- outValue
- Variable to receive the decoded value.
- input
- Input buffer to decode the data from.
- size
- Size of the input buffer.
Returns: Number of bytes read.
staticEncodeVarInt
staticDecodeVarInt
staticQuantize8BitSigned
Converts a float in range [-1,1] into an unsigned 8-bit integer.
staticQuantize8BitUnsigned
Converts a float in range [0,1] into an unsigned 8-bit integer.