firstbitlow function
Returns the location of the first set bit starting from the lowest order bit and working upward, per component. This intrinsic corresponds to the DXBC instruction firstbit_lo.
Syntax
int firstbitlow(
in int value
);
Parameters
-
value [in]
-
Type: int
The input value.
Return value
Type: int
The location of the first set bit.
The locaton is a zero-based count (or index), starting from the least significant bit (LSB). So you can use 1U << firstbitlow(value)
to recreate the corresponding bit found. When no bit is set in the input, the return value is 0xFFFFFFFF (all bits set). Endian-ness isn't relevant here; only bit significance in the integer (not in the memory layout).
Remarks
The following overloaded versions are also available:
uint2 firstbitlow(uint2 value);
uint3 firstbitlow(uint3 value);
uint4 firstbitlow(uint4 value);
Minimum shader model
This function is supported in the following shader models.
Shader model | Supported |
---|---|
Shader Model 5 and higher shader models | yes |
This function is supported in the following types of shaders:
Vertex | Hull | Domain | Geometry | Pixel | Compute |
---|---|---|---|---|---|
x | x | x | x | x | x |