Can be written in plain JS, cannot appear during shader compilation in WGSL.
Furthermore, they are later appended with 'f'/'u'/'i', which can result in accidentally compiling code.
const fn = () => {
'use gpu';
const NaNf = 0;
const b = d.f32(NaN);
};
expect(tgpu.resolve([fn])).toMatchInlineSnapshot(`
"fn fn_1() {
const NaNf = 0;
const b = NaNf;
}"
`);
Solution 1 (sane):
throw when encountered
Solution 2 (insane):
Replace NaN and infinity by calls to the following:
const divide = (a: number, b: number) => {
'use gpu';
return a / b;
};
const getNaN = () => {
'use gpu';
return divide(0, 0);
};
const getInfinity = () => {
'use gpu';
return divide(1, 0);
};
Can be written in plain JS, cannot appear during shader compilation in WGSL.
Furthermore, they are later appended with 'f'/'u'/'i', which can result in accidentally compiling code.
Solution 1 (sane):
throw when encountered
Solution 2 (insane):
Replace NaN and infinity by calls to the following: