-
Notifications
You must be signed in to change notification settings - Fork 193
Conversation
thank you for working on this
According to the glsl specification this should be the case
There's a slight difference,
I do have another issue with the current implementation, it specializes the parsing on |
latest commit adds a cast to Sint, and makes the parsing parse any method and then only specializes on .length in lowering instead |
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.
Amazing work, I wasn't expecting you to include argument handling but nice that you added it.
There are some issues that need to be addressed and I also added some nits.
Also please add a test (you can add it to expressions.frag
)
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.
Amazing work, but I noticed while testing your changes that ArrayLength
only works on pointer to dynamic arrays, while glsl expects .length
to work on all arrays.
To fix this we would need to check the type of the expression and if it's an array of fixed size or a pointer to it pass it as a constant.
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.
Almost perfect just left some nits and ask that you add a test for constant size arrays.
src/front/glsl/context.rs
Outdated
match array_type { | ||
&TypeInner::Array { |
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.
Prefer de referencing the match expression
match array_type { | |
&TypeInner::Array { | |
match *array_type { | |
TypeInner::Array { |
src/front/glsl/context.rs
Outdated
base: _, | ||
size: crate::ArraySize::Constant(size), | ||
stride: _, |
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.
Prefer using ellipsis ..
base: _, | |
size: crate::ArraySize::Constant(size), | |
stride: _, | |
size: crate::ArraySize::Constant(size), | |
.. |
src/front/glsl/context.rs
Outdated
stmt.hir_exprs[expr].meta, | ||
body, | ||
); | ||
self.conversion(&mut array_length, meta, ScalarKind::Sint, 4)?; |
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.
Use forced_conversion
in this case because constant array sizes might already be Sint
self.conversion(&mut array_length, meta, ScalarKind::Sint, 4)?; | |
self.forced_conversion(&mut array_length, meta, ScalarKind::Sint, 4)?; |
Sorry I might have misled you but since we are already lowering with a non |
src/front/glsl/context.rs
Outdated
self.forced_conversion( | ||
parser, | ||
&mut array_length, | ||
meta, | ||
ScalarKind::Sint, | ||
4, | ||
)?; |
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.
I only meant the previous branch, in here we can be sure it will be an Uint
and a cast will be neeeded
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.
Perfect, thanks for your contribution.
this fixes #2016
i see two reasons you may not want to merge this
Expression::ArrayLength
, which it may not haveother than that there should be no problems, other than that this was done in a hasty way