unpack2x16float
Function
Half-precision packing stores floating-point components as compact binary16 fields.
Related names in other languages
These related operations can differ in arguments, support, and semantics. The foreign names are not accepted TypeShade aliases. Check the target forms and restrictions.
- GLSL:
unpackHalf2x16
Compare examples
Compare the components, hexadecimal word, and recovered values. Notice which component occupies the low field.
Example 1unpack2x16float(0x3c000000)
01 - Result
[0, 1]
1006632960Example 2unpack2x16float(0x3800bc00)
-10.5 - Result
[-1, 0.5]
939572224Example 3unpack2x16float(0xc0004000)
2-2 - Result
[2, -2]
3221241856The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.
When to use it
Use it to reduce storage or bandwidth when the reduced precision is acceptable.
Inputs and limits
Binary16 has less range and precision than f32. The examples avoid halfway rounding cases; do not expect every input to survive a round trip.
For shader input rules and precision, consult WGSL and GLSL ES 3.00.
Related functions
- WGSL
unpack2x16float(a)- GLSL ES 3.00
unpackHalf2x16(a)
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Unpacks the two binary16 halves of a u32 into a vec2, the low 16 bits into component 0.
Syntax
declare function unpack2x16float(a0: u32): vec2declare function unpack2x16float(e: u32): vec2Parameters
-
eu32
Return value
Description
unpackHalf2x16 on GLSL ES 3.00.
Targets
- WGSL
-
unpack2x16float(a) - GLSL ES 3.00
-
unpackHalf2x16(a)