-
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
Add countLeadingZeros #2226
Add countLeadingZeros #2226
Conversation
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.
Behavior looks good!
But the GLSL and HLSL backends write the expr multiple times which won't always work.
The expression needs to either be baked or the function needs to be polyfilled.
I'd go with baking for now since we have the mechanism already implemented for GLSL.
Lines 1767 to 1768 in c7d0215
} else if self.need_bake_expressions.contains(&handle) { | |
Some(format!("{}{}", back::BAKE_PREFIX, handle.index())) |
I feel like polyfilling would be a nicer solution but we'd ideally make the transition all at once.
See also #2123 for more details.
Okay, I see the issue. |
I meant |
Had some downtime so just went ahead and did it for the scope of this PR and won’t likely have time to address it later. |
CI is failing due to recently updated clippy lints, we landed a fix in #2229; so we have to rebase this PR.
Thank you for considering this! Line 2901 in c7d0215
Let me know if you can address the comments above. If not, I can rebase it and we can open a new issue for the other change. Looks great otherwise! |
I see what you’re pointing out. You can rebase and open another issue. I tried applying the same polyfill to |
This sounds correct, so the msl polyfill is not correct for negative numbers. |
Adds
countLeadingZeros
from gfx-rs/wgpu#4402For negative expressions return
0
, otherwise return31 - msb
.This assumes
findUMsb
,findMSB
, andfirstbithigh
all return an index from thelsb
,but I don't have the means to verify this is actually the case atm.