-
Notifications
You must be signed in to change notification settings - Fork 193
glsl-in: Perform output parameters implicit casts #2063
Conversation
157c13d
to
7bc7b79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rant: this is incredibly cursed and I wouldn't even believe this existed if I hadn't ran into a shader that used this.
That's indeed quite some magic the GLSL spec mandates 😅
Looks like there are some test conflicts, feel free to merge once resolved. |
(I had this review sitting there since forever, and didn't realize I hadn't posted it) |
b3d2ee2
to
e260a5c
Compare
It looks like the log message on commit e260a5c isn't right. |
Oh no, seems like I did something that made git override the commit message with one of another commit that was merged by master (It also seems to have squashed commits 😞) |
1c1364c
to
f12409e
Compare
@jimblandy should be fixed and rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to land.
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. This commit fixes that by using a proxy write, this creates a spill variable with the correct type and in the call prologue a conversion is made back to the original type and the value is stored in the original variable.
f12409e
to
3d87400
Compare
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:
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.