# 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 |
---|---|

[in] The address of the results. | |

[in] The bitfield width to take from | |

[in] The bitfield offset for replacing bits in | |

[in] The number the bits are taken from. | |

[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 |

## Related topics