Fp64Flavor
Type in Emulated f64
Which arithmetic primitives back the emulated-double (df64) helper functions that fp64Lower injects.
import type { Fp64Flavor } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
type Fp64Flavor = 'float' | 'integer';Description
Which arithmetic primitives back the emulated-double (df64) helper functions that
fp64Lower injects. Both flavours compute the same values; they differ in what a
target’s shader compiler is able to do to them.
'float': the default. Error-free transforms written in float arithmetic, protected from constant folding by a runtime guard binding,_fp64, that the host fills with1.0.'integer': thetwoSum,twoProd, division and square-root leaves are written in integer bit arithmetic; the compositions above them are shared with'float'. A fast-math pass cannot reassociate integer operations, so the hi/lo split survives on compilers that fold the float form (Apple Metal, and the ANGLE Direct3D 11 path through FXC). No guard binding is injected, because the integer bodies never read it.
Choose 'integer' when a target’s compiler folds the float primitives. The symptom is
emulated-double results degrading to f32 precision on one platform while every other target
is fine. recommendFp64Flavor picks a flavour from a device’s adapter or renderer
information.
See also
Source
src/core/passes/fp64-lower.ts, line 113, at commit 26de7be8