-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Convert as_hal
calls to use guards intead of callbacks
#7863
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
Conversation
as_hal
calls to use guards intead of callbacks
e57540a
to
f58ac37
Compare
I'm not the one doing the review, I just noticed a typo. |
f58ac37
to
946983e
Compare
Do you still have to unwrap() manually in case of backend API mismatch? |
Yes all apis return options. |
I'd rather it unwrap in wgpu, personally. I can't imagine why you would want it to be optional. Users are likely going to perform a backend check higher-up, and switch between e.g. dlss_vk and dlss_dx. |
Very strongly in favor of keeping options instead of wgpu-internal unwrap! And either way we need less unwraps in wgpu when we can avoid it! I never ever want to leave my users with an application crashing inside of wgpu because I didn't real all the details of a docstring warning about correct use. |
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.
beautiful, huge improvement!
the locking mechanism is quite elaborate, I think I followed it all the way and there's no error in there but it would be nice to add some basic tests for this. Any chance we could add some test code that covers the guard types?
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.
we decided on maintainer call that this is good enough for release, but we still want some extra tests here
946983e
to
61a0bf1
Compare
Description
This converts all
as_hal
calls (except CommandBuffers) from callbacks to guards. This will make the api signifigantly better.I needed to add a few escape hatches in the locking infrastructure to allow dependent locks to exist in a single guard. All of the unsafe in this PR does not affect Mozilla.
Review experience is commit by commit
Testing
No current testing of the as_hal api at all. Working on it.
Squash or Rebase?
Rebase
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.