pack4xI8Clamp
Function
Integer byte packing combines components into one word.
Compare examples
Compare the components, hexadecimal word, and recovered values. Notice which component occupies the low field.
Example 1pack4xI8Clamp(vec4i(1, 2, 3, 4))
1234 - Result
0x04030201
67305985Example 2pack4xI8Clamp(vec4i(-1, -1, -1, -1))
-1-1-1-1 - Result
0xffffffff
4294967295Example 3pack4xI8Clamp(vec4i(130, 130, 130, 130))
130130130130 - Result
0x7f7f7f7f
2139062143The 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
This variant clamps each component before storing it. These integer byte operations are WebGPU-only in this compiler.
For shader input rules and precision, consult WGSL and GLSL ES 3.00.
Related functions
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Packs a vec4i into a u32 as four bytes, clamping each component into [-128, 127] first.
Syntax
declare function pack4xI8Clamp(a0: vec4i): u32declare function pack4xI8Clamp(e: vec4i): u32Parameters
-
evec4i
Return value
Description
The result is unsigned because it is a word of bytes, not a number with a sign. Not supported yet on the WebGL2 tier.
Targets
- WGSL
-
pack4xI8Clamp(a) - GLSL ES 3.00
-
pack4xI8Clampis not supported yet on the WebGL2 tier