bfi (sm5 - asm)

Given a bit range from the LSB of a number, place that number of bits in another number at any offset.

bfi dest[.mask], src0[.swizzle], src1[.swizzle], src2[.swizzle], src3[.swizzle]
Item Description
dest
[in] The address of the results.
src0
[in] The bitfield width to take from src2.
src1
[in] The bitfield offset for replacing bits in src3.
src2
[in] The number the bits are taken from.
src3
[in] The number with bits to be replaced.

Remarks

The LSB 5 bits of src0 provide the bitfield width (0-31) to take from src2.

The LSB 5 bits of src1 provide the bitfield offset (0-31) to start replacing bits in the number read from src3.

Given width, offset:
                bitmask = (((1 << width)-1) << offset) & 0xffffffff
                dest = ((src2 << offset) & bitmask) | (src3 & ~bitmask)

This instruction is used for packing integers or flags.

This instruction applies to the following shader stages:

Vertex Hull Domain Geometry Pixel Compute
X X X X X X

Minimum Shader Model

This instruction is supported in the following shader models:

Shader Model Supported
Shader Model 5 yes
Shader Model 4.1 no
Shader Model 4 no
Shader Model 3 (DirectX HLSL) no
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

Shader Model 5 Assembly (DirectX HLSL)