unpack4xI8
On this page

unpack4xI8

Function

Integer byte packing recovers components from a word.

Compare examples

Compare the components, hexadecimal word, and recovered values. Notice which component occupies the low field.

Example 1unpack4xI8(0x04030201)
1234
Components in this example
Result
[1, 2, 3, 4]
Word in binary: 67305985
Example 2unpack4xI8(0xffffffff)
-1-1-1-1
Components in this example
Result
[-1, -1, -1, -1]
Word in binary: 4294967295
Example 3unpack4xI8(0x82828282)
-126-126-126-126
Components in this example
Result
[-126, -126, -126, -126]
Word in binary: 2189591170

The 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

Components are sign-extended when signed and zero-extended when unsigned. These integer byte operations are WebGPU-only in this compiler.

For shader input rules and precision, consult WGSL and GLSL ES 3.00.

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

Unpacks the four bytes of a u32 into a vec4i, sign-extending each byte, the low byte into component 0.

Syntax

declare function unpack4xI8(a0: u32): vec4i
declare function unpack4xI8(e: u32): vec4i

Parameters

Return value

vec4i

Description

The inverse of pack4xI8. Not supported yet on the WebGL2 tier.

Targets

WGSL
unpack4xI8(a)
GLSL ES 3.00
unpack4xI8 is not supported yet on the WebGL2 tier

Examples

See also

Edit this page Report a problem