-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[msl-out] BoundsCheckPolicy::ReadZeroSkipWrite
produces invalid Metal when calling functions with pointers to array elements
#4541
Comments
I haven't looked at how the code is setup for this right now but I suspect it might be easier to move the whole ternary operation on it own line to solve the issue. |
I'm assuming you mean something like this: int var = uint(i) < 4 ? arr.inner[i] : DefaultConstructible();
takes_ptr(var); Wouldn't that then write to I'm willing to make a PR for this, BTW. |
I was thinking I think we can go with the solution you proposed. |
Huh, turns out translating that same shader to SPIR-V results in a panic:
I'll try and fix that too while I'm at it. |
…ents Fixes gfx-rs#4541 -- Co-authored-by: Liam Murphy <liampm32@gmail.com>
…ents Fixes gfx-rs#4541 -- Co-authored-by: Liam Murphy <liampm32@gmail.com>
Say you have a shader like this, which calls a function with a pointer to an array element:
When
BoundsCheckPolicy::ReadZeroSkipWrite
is enabled, Naga produces this invalid Metal code:DefaultConstructible()
isn't a valid reference, which Metal rightly complains about:One solution to this that I could see would be to generate a variable containing the default value of the array element type, and pass a reference to that if the index is out of bounds. Something along the lines of this:
The text was updated successfully, but these errors were encountered: