naga
naga copied to clipboard
glsl-in: Perform output parameters implicit casts
Rant: this is incredibly cursed and I wouldn't even believe this existed if I hadn't ran into a shader that used this.
Glsl defines under Function Definitions
(Paragraph 6.1 in glsl 4.60),
the following:
When function calls are resolved, an exact type match for all the arguments is sought. (...) If no exact match is found, then the implicit conversions in section “Implicit Conversions” will be applied to find a match. (...) Mismatched types on output parameters (out or inout) must have a conversion from the formal parameter type to the calling argument type.
The glsl frontend wasn't performing this implicit cast for output parameters.
They are now implemented trough a proxy write (like when swizzling for output parameters), where a spill variable with the correct type is passed and on the call prologue a conversion back to the original type is performed and the value stored in the original variable.
Furthermore if the variable in declared inout
, a conversion is also made in the call prelude from the original type to the correct type and the value is stored in the spill variable.