Make all backends controlled by features (using a very ugly workaround)#6949
Make all backends controlled by features (using a very ugly workaround)#6949Wumpf wants to merge 6 commits intogfx-rs:trunkfrom
Conversation
cwfitzgerald
left a comment
There was a problem hiding this comment.
I think this is broadly fine, I will have some comments on specifics once this is ready for review, but we definitely shouldn't be scared of crates. Might be worthwhile looking into cargo-release or release-plz or something if the count grows.
brody2consult
left a comment
There was a problem hiding this comment.
quick comments from an outsider
|
@Wumpf My impassioned request is that the explanation in the top of this PR make it into the code as a comment. I agree that this a good PR, but people are going to be utterly WTH when they see this. |
|
Also: spectacular |
|
Sorry, kinda stepped on your toes a bit with #6980 - lmk if you need help managing the migration |
d14c3a4 to
df354a9
Compare
TODO: we should test this on ci with cargo tree, it's too easy to sneak back in
df354a9 to
0456cc6
Compare
31f1298 to
d24dbc9
Compare
|
hit a bit of a snag: any feature that is supposed to be forwarded to wgpu-core needs to be forwarded now to all four (yeah it's four by now) proxy crates. Doable, but extra annoying The problem is that if I put |
Connections
Description
Feature flag changes:
vulkanfeature for enabling Vulkan on Windows/Android/Linux (part of default feature set)glesfeature for enabling Vulkan on Windows/Android/Linux (part of default feature set, debatable if that's a good idea)webglenabling GL on all platformsThis is achieved by introducing three proxy crates. Each depends on wgpu-core under a different platform condition and will "forward" all feature flags to it.
Reminder why this horrible construct is the only way:
This is necessary because it's impossible today to drag in a dependency conditionally BOTH on a platform & a feature flag.
It is possible to do all these things in code, so we can forward features all the way to wgpu-hal and not have it compile e.g. it's vulkan backend on Mac iff
vulkan-portabilityis off. But without this workaround it's impossible to avoid building vulkan associated dependencies anyways.For more details see
Building with
default-features=falsewill now not even drag in wgpu-core!cargo tree -p wgpu --edges normalfor simple application depending on wgpu this way:Similarly, only depending on
dx12(on Windows) doesn't includeashorglow(the former is a slow building dependency!):Testing
Checklist
cargo fmt.taplo format.cargo clippy. If applicable, add:--target wasm32-unknown-unknown--target wasm32-unknown-emscriptencargo xtask testto run tests.CHANGELOG.md. See simple instructions inside file.Draft todo: