-
Notifications
You must be signed in to change notification settings - Fork 965
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 no_std
support to wgpu-types
#6892
Conversation
Just one note while you're working on this, I don't think we need no-alloc support; the rest of the stack depends on it anyway. |
Also fixed some documentation links and a Wasm `std` import
Easy, I've removed that feature and fixed (hopefully) the last CI issue too. |
no_std
and no_alloc
support to wgpu-types
no_std
support to wgpu-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.
Got some comments, but generally looking good.
The other thing that needs to be done is get CI support for a no-std platform so we don't break no-std.
Lets do testing on wasm32v1-none
as that was the inciting incident for this work.
You can add another variant after https://github.com/gfx-rs/wgpu/blob/trunk/.github/workflows/ci.yml#L145-L148 which is the wasmv1 target. It will be a new kind called no-std
and for now lets use the nightly toolchain, so add toolchain: nightly
(not required but this makes setup easier)
Then add a new block similar to https://github.com/gfx-rs/wgpu/blob/trunk/.github/workflows/ci.yml#L234-L248 which is conditioned on if: matrix.kind == "no-std"
and contains the exact things you were testing with. We can expand them as more of wgpu gets no-std access.
Noting here that there is a bug in the current version of |
Ok I've addressed all the items from that review (thanks for being so thorough btw!). I've also added a new |
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.
Looking good. Have some notes about CI, and CI is mad.
Addressed the latest round of comments and fixed that CI issue (forgot to cascade the change in |
Bleh CI crap, I'll deal with this |
Ahh yeah looks like I forgot to |
Nah, I led you astray- I thought bare metal x86_64 was a tier 3 Target and therefore you actually can't tell it to install the target. This is what we have to do for vision OS and why there are two separate tool chain installation steps, but I now realize is one for tier 1 and 2 and one for tier 3 |
I'm going to touch up the CI script to make the definitions more clear when I do the final proper pass on this PR |
Thanks for all the work! |
Thanks for the assistance in getting it over the line! I'm planning on looking into |
Connections
Description
For a possible
no_std
version ofwgpu
(as requested in the above issue), a good first step would be for the already slimwgpu-types
crate to beno_std
compatible. This is what this PR accomplishes.First, I disabled default features on the crates
wgpu-types
relies on (disabling their respectivestd
features). As these dependencies are managed through the workspace, they had to be disabled there, requiring re-enablingdefault
in the adjacent crates.Next, I added
std
anddefault
features towgpu-types
. This ensures users who do not care aboutno_std
compatibility have minimal friction when using this crate. I also added the following lints towgpu-types
:These are very helpful when working on a crate with features for
std
andalloc
, since they will inform you if you're being overly restrictive on how you import items which are re-exported.Next, I added the following to the
lib.rs
file:By being unconditionally
no_std
and optionally includingstd
through a feature, this crate will always use thecore
implicit prelude instead of switching betweencore
andstd
based on thestd
feature. This was a headache in Bevy'sno_std
efforts.Finally, I added appropriate feature gates where required, and tweaked one particular method for serializing
Astc
texture formatsto ensure theserde
feature didn't require thealloc
one. There's nothing wrong with requiringalloc
forserde
, but it was a minor change to decouple these two features.Change isn't required but I've already written it, and it does avoid allocation, so it's marginally more performant.Reverted.Testing
Tested through compiling
wgpu-types
using the following commands:Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.Notes
I have made the assumption that conditionalalloc
may provide utility to this crate, but that may be faulty. It could be removed and theextern crate alloc
line could always be included.