-
Notifications
You must be signed in to change notification settings - Fork 1.1k
MVP no_std
for wgpu-core
#7746
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
base: trunk
Are you sure you want to change the base?
MVP no_std
for wgpu-core
#7746
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.
really well documented both in code and PR description, thank you!
Would like to see some of it paraphrased in the feature docs to help users make the right choice.
Make once_cell optional by falling back to core::cell:OnceCell.
a. Note that once_cell is no_std compatible, but it requires activating the critical-section feature to access its implementation of OnceCell. Adding such a feature would therefore add critical-section to the lockfile, requiring thorough review due to its use of unsafe and extern "Rust". I believe it is a safe inclusion, but it can be avoided here so I'd rather save that quality of life feature for a follow-up. Users are still able to use once_cell with wgpu-core on no_std, they just have to enable once_cell/critical-section themselves.
b. Note that core::cell::OnceCell is !Sync, so users should prefer to enable critical-section themselves.
It irks me to add yet another feature just because of that, also given that once_cell
is such a small and common crate. I think if we could we'd want to imply not enabling std
to enable once_cell/critical-section
.
Since this isn't possible I'd instead argue it's better to just keep always depending on once_cell
and point out to users that they have to use once_cell/critical-section
if they want Sync
. That's already the case with the PR as-is, only that a user also has to enable the once_cell
feature.
This would save us feature permutations, an extra code path and complexity for users. What do you think?
Agreed! The ideal solution (that we can implement without changes to Cargo or |
I've split out the |
Sorry for the long lead times on these. It's been quite busy at work and I'm now out for a couple of days. Will likely get to it some point next week 🤞 |
No stress! Thanks for your help 🙂 |
Connections
Description
Adds
no_std
support towgpu-core
through 3 changes:num-traits
withintimestamp_normalization
to account for the floating point methods only available withstd
.parking_lot
optional by falling back to eitherstd::sync::{Mutex, RwLock}
,spin::{Mutex, RwLock}
, orcore::cell::RefCell
based on selecting eitherparking_lot
,std
,spin
, or no locking implementation.a. Note that
spin
was already in the lockfile viacrossbeam-deque
so this feature is "free"b. Note that
RefCell
is!Sync
, so users should selectspin
inno_std
environments. The use ofRefCell
as a fallback just allows compilation to succeed without any features enabled.once_cell
optional by falling back tocore::cell:OnceCell
.a. Note that
once_cell
isno_std
compatible, but it requires activating thecritical-section
feature to access its implementation ofOnceCell
. Adding such a feature would therefore addcritical-section
to the lockfile, requiring thorough review due to its use ofunsafe
andextern "Rust"
. I believe it is a safe inclusion, but it can be avoided here so I'd rather save that quality of life feature for a follow-up. Users are still able to useonce_cell
withwgpu-core
onno_std
, they just have to enableonce_cell/critical-section
themselves.b. Note that
core::cell::OnceCell
is!Sync
, so users should prefer to enablecritical-section
themselves.To preserve existing behavior, the newly added
parking_lot
andonce_cell
features are enabled by default.Testing
Added
wgpu-core
to thewasm32v1-none
CI test.Squash or Rebase?
Squash
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.