To solve #5523, Naga needs information about built-in function argument and result types in a form that the WGSL front end can consume to apply WGSL automatic type conversions.
At the moment, builtins appear in Naga in the following places:
- The IR has enums like
BuiltIn and MathFunction.
- The
typifier module knows the result types.
- The
valid module knows the argument types.
- The WGSL front end and backend both know the function names.
But automatic conversions apply anywhere that they would turn an ill-typed program into a well-typed program, so one needs argument type information to apply them.
Ideally, the first three should be brought together, and the last two should be unified.
It may be the case that we can keep the WGSL front end innocent of these things, and handle automatic conversions with a processing phase.
To solve #5523, Naga needs information about built-in function argument and result types in a form that the WGSL front end can consume to apply WGSL automatic type conversions.
At the moment, builtins appear in Naga in the following places:
BuiltInandMathFunction.typifiermodule knows the result types.validmodule knows the argument types.But automatic conversions apply anywhere that they would turn an ill-typed program into a well-typed program, so one needs argument type information to apply them.
Ideally, the first three should be brought together, and the last two should be unified.
It may be the case that we can keep the WGSL front end innocent of these things, and handle automatic conversions with a processing phase.