-
Notifications
You must be signed in to change notification settings - Fork 969
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
Make all backends controlled by features (using a very ugly workaround) #6949
Draft
Wumpf
wants to merge
5
commits into
gfx-rs:trunk
Choose a base branch
from
Wumpf:make-remaining-backends-opt-out
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+176
−86
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ff038bf
Use crate indirections to enable feature depending on platforms
Wumpf 5816233
allow disabling wgc on native completely
Wumpf 96bc309
don't always drag in hal
Wumpf a7ec47a
Fix dx12 feature not enabling wgpu-core
Wumpf d14c3a4
Fix missing `hal` namespce
Wumpf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
wgpu-core-target-feature-conditionals/arch-wasm32/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "wgpu-core-feature-conditional-arch-wasm32" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
description = "Workaround crate for enabling features in wgpu-core when targeting wasm32" | ||
homepage.workspace = true | ||
repository.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
|
||
[lib] | ||
|
||
[features] | ||
gles = ["wgc/gles"] | ||
|
||
[target.'cfg(target_arch = "wasm32")'.dependencies.wgc] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! No code. See README.md for details. |
22 changes: 22 additions & 0 deletions
22
wgpu-core-target-feature-conditionals/native-non-apple/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "wgpu-core-feature-conditional-native-non-apple" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
description = "Workaround crate for enabling features in wgpu-core when targeting macOS/iOS" | ||
homepage.workspace = true | ||
repository.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
|
||
[lib] | ||
|
||
[features] | ||
gles = ["wgc/gles"] | ||
renderdoc = ["wgc/renderdoc"] | ||
vulkan = ["wgc/vulkan"] | ||
|
||
raw-window-handle = ["wgc/raw-window-handle"] | ||
|
||
[target.'cfg(any(windows, all(unix, not(target_arch = "wasm32"), not(target_vendor = "apple"))))'.dependencies.wgc] | ||
workspace = true |
1 change: 1 addition & 0 deletions
1
wgpu-core-target-feature-conditionals/native-non-apple/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! No code. See README.md for details. |
22 changes: 22 additions & 0 deletions
22
wgpu-core-target-feature-conditionals/vendor-apple/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "wgpu-core-feature-conditional-vendor-apple" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
description = "Workaround crate for enabling features in wgpu-core when targeting macOS/iOS" | ||
homepage.workspace = true | ||
repository.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
|
||
[lib] | ||
|
||
[features] | ||
gles = ["wgc/gles"] | ||
metal = ["wgc/metal"] | ||
vulkan = ["wgc/vulkan"] | ||
|
||
raw-window-handle = ["wgc/raw-window-handle"] | ||
|
||
[target.'cfg(target_vendor = "apple")'.dependencies.wgc] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! No code. See README.md for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,45 +60,23 @@ impl Instance { | |
/// | ||
/// `InstanceDescriptor::backends` does not need to be a subset of this, | ||
/// but any backend that is not in this set, will not be picked. | ||
/// | ||
/// TODO: Right now it's otherwise not possible yet to opt-out of all features on some platforms. | ||
/// See <https://github.com/gfx-rs/wgpu/issues/3514> | ||
/// * Windows/Linux/Android: always enables Vulkan and GLES with no way to opt out | ||
pub const fn enabled_backend_features() -> Backends { | ||
let mut backends = Backends::empty(); | ||
|
||
if cfg!(native) { | ||
if cfg!(metal) { | ||
backends = backends.union(Backends::METAL); | ||
} | ||
if cfg!(dx12) { | ||
backends = backends.union(Backends::DX12); | ||
} | ||
|
||
// Windows, Android, Linux currently always enable Vulkan and OpenGL. | ||
// See <https://github.com/gfx-rs/wgpu/issues/3514> | ||
if cfg!(target_os = "windows") || cfg!(unix) { | ||
backends = backends.union(Backends::VULKAN).union(Backends::GL); | ||
} | ||
|
||
// Vulkan on Mac/iOS is only available through vulkan-portability. | ||
if cfg!(target_vendor = "apple") && cfg!(feature = "vulkan-portability") { | ||
backends = backends.union(Backends::VULKAN); | ||
} | ||
|
||
// GL on Mac is only available through angle. | ||
if cfg!(target_os = "macos") && cfg!(feature = "angle") { | ||
backends = backends.union(Backends::GL); | ||
} | ||
} else { | ||
if cfg!(webgpu) { | ||
backends = backends.union(Backends::BROWSER_WEBGPU); | ||
} | ||
if cfg!(webgl) { | ||
backends = backends.union(Backends::GL); | ||
} | ||
Comment on lines
-69
to
-99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. <3 always love for removing large blocks of ugly code :) |
||
if cfg!(metal) { | ||
backends = backends.union(Backends::METAL); | ||
} | ||
if cfg!(dx12) { | ||
backends = backends.union(Backends::DX12); | ||
} | ||
if cfg!(vulkan) { | ||
backends = backends.union(Backends::VULKAN); | ||
} | ||
if cfg!(gles) { | ||
backends = backends.union(Backends::GL); | ||
} | ||
if cfg!(webgpu) { | ||
backends = backends.union(Backends::BROWSER_WEBGPU); | ||
} | ||
|
||
backends | ||
} | ||
|
||
|
@@ -221,7 +199,7 @@ impl Instance { | |
/// # Arguments | ||
/// | ||
/// - `backends` - Backends from which to enumerate adapters. | ||
#[cfg(native)] | ||
#[cfg(all(native, wgpu_core))] | ||
pub fn enumerate_adapters(&self, backends: Backends) -> Vec<Adapter> { | ||
let Some(core_instance) = self.inner.as_core_opt() else { | ||
return Vec::new(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could we consider shorter names for these, perhaps with slight reordering?
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.
yeah those names are definitely too crazy right now