-
Notifications
You must be signed in to change notification settings - Fork 195
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: handle the case of missing binding #2175
Conversation
I don't see how this change "allows the MSL backend also work correctly for a subset of modules that are valid except for the bindings part". To me it only looks like it introduces more granular errors. |
@teoxoy let me try to explain differently. Currently, it pays attention - it panics if there is a missing resource decoration on a global that it doesn't even use. This is accidental, not intentional. With this PR, it will no longer panic, but instead will happily produce the MSL code. |
Where does this happen in the code? Could you point me to it? This Line 3784 in 5a1f43d
is gated by Lines 3752 to 3756 in 5a1f43d
and the body of this loop is also gated by Lines 3397 to 3401 in 5a1f43d
Besides the more granular error, behavior wise, this PR seems to only ignore globals in Am I missing something? |
@teoxoy thank you for looking deeply into this! Line 3687 in 8e1b052
Note the comment above:
You are correct that there is a check in the loop before this line: let usage = fun_info[handle];
if usage.is_empty() || var.space == crate::AddressSpace::Private {
continue;
} However, the problem is - it panics while trying to output another entry point, not the one we are interested in.
This PR extends this definition by also considering a global variable to not be "available" if it's missing resource binding decorations. That's something the old code path didn't expect, but it's a useful thing to consider for my case. |
Ah, I see how this is supposed to work now! Before this PR, we were ignoring a |
The purpose of this code is to detect if a global variable can or can't be used legally by a given entry point. It assumes the resource binding is present and just checks if the override is set. I find it also useful to check if there is a binding at all. Hence the new error type.
Note that, technically speaking, all backends assume the module is valid. And this validity includes having a binding decoration on all resource globals. And now this code makes MSL backend also work correctly for a subset of modules that are valid except for the bindings part. So it's a tricky case, and it's not directly hit by WebGPU paths.