quantizeToF16
On this page

quantizeToF16

Function

Rounds e to what an IEEE-754 binary16 can hold and returns it as an f32, so a shader can see the precision an f16 pipeline would give it without the shader-f16 extension.

The signature and the sentence under each name are the compiler's own text at commit 26de7be8.

Syntax

declare function quantizeToF16(a0: f32): f32
declare function quantizeToF16<V extends vec2 | vec3 | vec4>(a0: V): V
declare function quantizeToF16(e: f32): f32
declare function quantizeToF16<T extends vec2 | vec3 | vec4>(e: T): T

Parameters

Return value

f32VT

Description

Takes an f32 or a float vector. GLSL ES 3.00 has no such builtin, so it is spelled as a packHalf2x16/unpackHalf2x16 round trip, whose rounding of an exact half that spec does not pin.

Targets

WGSL
quantizeToF16(a)
GLSL ES 3.00
unpackHalf2x16(packHalf2x16(vec2(a, 0.0))).x

Examples

See also

Edit this page Report a problem