fma()
Function in Builtins
fma(a, b, c): multiply-add, a·b + c, component-wise for vectors.
import { fma } from 'typeshade/core/ir'
This export returns an IR node. A "use typeshade" file calls the builtin itself: fma()
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
const fma: <K extends FloatKey>( a: ReadonlyNode<K>, b: NoInfer<ArithArg<K>>, c: NoInfer<ArithArg<K>>,) => Node<K>Parameters
aReadonlyNode<K>bNoInfer<ArithArg<K>>cNoInfer<ArithArg<K>>
Return value
Node<K>
Description
WGSL emits the
fma builtin. Its accuracy rules allow an ordinary multiply followed by an ordinary add,
so it does not guarantee a single rounding or an exact product error term. GLSL ES 3.00 has no fma, so the GLSL output is (a * b + c). That target also permits
either one rounding or separate roundings for the product and sum. Neither spelling guarantees identical results across devices or backends.
See WGSL fma and GLSL ES 3.00 section 4.5.1.
Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported |
|
| GLSL ES 3.00 (WebGL2) | Supported |
|
| CPU oracle | Supported | Evaluated in |
See also
Source
src/core/ir/node.ts, line 1489, at commit af54ddad5