From 31f1298c96edec5033beea66b1aaa641f6dbef7c Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Sun, 26 Jan 2025 17:23:21 +0100 Subject: [PATCH] fix dx12 enabling wgpu-core on linux - add another workaround crate --- Cargo.lock | 4 ++-- Cargo.toml | 8 ++++++-- wgpu-core-conditional/arch-wasm32/Cargo.toml | 2 +- .../native-non-apple/Cargo.toml | 4 +--- .../{vendor-apple => target-apple}/Cargo.toml | 4 ++-- .../{vendor-apple => target-apple}/src/lib.rs | 0 .../target-windows/Cargo.toml | 18 ++++++++++++++++++ .../target-windows/src/lib.rs | 1 + wgpu/Cargo.toml | 17 ++++++++++------- 9 files changed, 41 insertions(+), 17 deletions(-) rename wgpu-core-conditional/{vendor-apple => target-apple}/Cargo.toml (76%) rename wgpu-core-conditional/{vendor-apple => target-apple}/src/lib.rs (100%) create mode 100644 wgpu-core-conditional/target-windows/Cargo.toml create mode 100644 wgpu-core-conditional/target-windows/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 5eafd1d66e..1709bd99df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4029,7 +4029,7 @@ dependencies = [ "wgpu-core", "wgpu-core-if-arch-wasm32", "wgpu-core-if-native-non-apple", - "wgpu-core-if-vendor-apple", + "wgpu-core-if-target-apple", "wgpu-hal", "wgpu-types", ] @@ -4092,7 +4092,7 @@ dependencies = [ ] [[package]] -name = "wgpu-core-if-vendor-apple" +name = "wgpu-core-if-target-apple" version = "24.0.0" dependencies = [ "wgpu-core", diff --git a/Cargo.toml b/Cargo.toml index e684eaf355..3dfb7c07de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,8 @@ members = [ "wgpu", "wgpu-core-conditional/arch-wasm32", "wgpu-core-conditional/native-non-apple", - "wgpu-core-conditional/vendor-apple", + "wgpu-core-conditional/target-apple", + "wgpu-core-conditional/target-windows", ] exclude = [] default-members = [ @@ -46,6 +47,8 @@ default-members = [ "wgpu-core-conditional/arch-wasm32", "wgpu-core-conditional/native-non-apple", "wgpu-core-conditional/vendor-apple", + "wgpu-core-conditional/target-apple", + "wgpu-core-conditional/target-windows", ] [workspace.lints.clippy] @@ -78,7 +81,8 @@ wgpu = { version = "24.0.0", path = "./wgpu", default-features = false, features wgpu-core = { version = "24.0.0", path = "./wgpu-core" } wgpu-core-if-arch-wasm32 = { version = "24.0.0", path = "./wgpu-core-conditional/arch-wasm32" } wgpu-core-if-native-non-apple = { version = "24.0.0", path = "./wgpu-core-conditional/native-non-apple" } -wgpu-core-if-vendor-apple = { version = "24.0.0", path = "./wgpu-core-conditional/vendor-apple" } +wgpu-core-if-target-apple = { version = "24.0.0", path = "./wgpu-core-conditional/target-apple" } +wgpu-core-if-target-windows = { version = "24.0.0", path = "./wgpu-core-conditional/target-windows" } wgpu-hal = { version = "24.0.0", path = "./wgpu-hal" } wgpu-macros = { version = "24.0.0", path = "./wgpu-macros" } wgpu-test = { version = "24.0.0", path = "./tests" } diff --git a/wgpu-core-conditional/arch-wasm32/Cargo.toml b/wgpu-core-conditional/arch-wasm32/Cargo.toml index 654235a387..544c3c64dc 100644 --- a/wgpu-core-conditional/arch-wasm32/Cargo.toml +++ b/wgpu-core-conditional/arch-wasm32/Cargo.toml @@ -3,7 +3,7 @@ name = "wgpu-core-if-arch-wasm32" version.workspace = true authors.workspace = true edition.workspace = true -description = "Workaround crate for enabling features in wgpu-core when targeting wasm32" +description = "Workaround crate for enabling in wgpu-core when targeting wasm32" homepage.workspace = true repository.workspace = true keywords.workspace = true diff --git a/wgpu-core-conditional/native-non-apple/Cargo.toml b/wgpu-core-conditional/native-non-apple/Cargo.toml index 21182ce72a..c9c9d7f918 100644 --- a/wgpu-core-conditional/native-non-apple/Cargo.toml +++ b/wgpu-core-conditional/native-non-apple/Cargo.toml @@ -3,7 +3,7 @@ name = "wgpu-core-if-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" +description = "Workaround crate for enabling in wgpu-core when targeting native unix platforms excluding macOS/iOS/tvOS/VisionOS" homepage.workspace = true repository.workspace = true keywords.workspace = true @@ -16,7 +16,5 @@ gles = ["wgpu-core/gles"] renderdoc = ["wgpu-core/renderdoc"] vulkan = ["wgpu-core/vulkan"] -raw-window-handle = ["wgpu-core/raw-window-handle"] - [target.'cfg(any(windows, all(unix, not(target_arch = "wasm32"), not(target_vendor = "apple"))))'.dependencies] wgpu-core.workspace = true diff --git a/wgpu-core-conditional/vendor-apple/Cargo.toml b/wgpu-core-conditional/target-apple/Cargo.toml similarity index 76% rename from wgpu-core-conditional/vendor-apple/Cargo.toml rename to wgpu-core-conditional/target-apple/Cargo.toml index 17a7c6a377..3d9f2cd3fc 100644 --- a/wgpu-core-conditional/vendor-apple/Cargo.toml +++ b/wgpu-core-conditional/target-apple/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wgpu-core-if-vendor-apple" +name = "wgpu-core-if-target-apple" version.workspace = true authors.workspace = true edition.workspace = true -description = "Workaround crate for enabling features in wgpu-core when targeting macOS/iOS" +description = "Workaround crate for enabling wgpu-core when targeting macOS/iOS/tvOS/VisionOS" homepage.workspace = true repository.workspace = true keywords.workspace = true diff --git a/wgpu-core-conditional/vendor-apple/src/lib.rs b/wgpu-core-conditional/target-apple/src/lib.rs similarity index 100% rename from wgpu-core-conditional/vendor-apple/src/lib.rs rename to wgpu-core-conditional/target-apple/src/lib.rs diff --git a/wgpu-core-conditional/target-windows/Cargo.toml b/wgpu-core-conditional/target-windows/Cargo.toml new file mode 100644 index 0000000000..942e25fd3c --- /dev/null +++ b/wgpu-core-conditional/target-windows/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "wgpu-core-if-target-windows" +version.workspace = true +authors.workspace = true +edition.workspace = true +description = "Workaround crate for enabling wgpu-core when targeting windows" +homepage.workspace = true +repository.workspace = true +keywords.workspace = true +license.workspace = true + +[lib] + +[features] +dx12 = ["wgpu-core/dx12"] + +[target.'cfg(windows)'.dependencies] +wgpu-core.workspace = true diff --git a/wgpu-core-conditional/target-windows/src/lib.rs b/wgpu-core-conditional/target-windows/src/lib.rs new file mode 100644 index 0000000000..174c77f96a --- /dev/null +++ b/wgpu-core-conditional/target-windows/src/lib.rs @@ -0,0 +1 @@ +//! No code. See README.md for details. diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 94fe43ec5d..f46569b071 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -34,12 +34,14 @@ default = ["wgsl", "dx12", "metal", "vulkan", "gles", "webgpu"] # -------------------------------------------------------------------- ## Enables the DX12 backend on Windows. -# Dx12 doesn't do anything on non-windows wgpu-core & wgpu-hal, so we don't need a proxy crate here. -dx12 = ["wgpu-core/dx12"] +# Note that while wgpu-hal ignores dx12 for non-windows targets, we still need to use a proxy crate, +# since for non-windows targets we don't want to include wgpu-core in the first place via this feature. +dx12 = ["wgpu-core-if-target-windows/dx12"] ## Enables the Metal backend on macOS & iOS. -# Metal doesn't do anything on non-Apple wgpu-core & wgpu-hal, but we already have a proxy crate for Apple platforms anyways. -metal = ["wgpu-core-if-vendor-apple/metal"] +# Note that while wgpu-hal ignores metal for non-apple targets, we still need to use a proxy crate, +# since for non-apple targets we don't want to include wgpu-core in the first place via this feature. +metal = ["wgpu-core-if-target-apple/metal"] ## Enables the Vulkan backend on Windows, Linux, and Android. ## @@ -47,7 +49,7 @@ metal = ["wgpu-core-if-vendor-apple/metal"] vulkan = ["wgpu-core-if-native-non-apple/vulkan"] ## Enables the Vulkan backend on macOS & iOS. -vulkan-portability = ["wgpu-core-if-vendor-apple/vulkan"] +vulkan-portability = ["wgpu-core-if-target-apple/vulkan"] ## Enables the OpenGL/GLES backend on Windows, Linux, and Android. ## @@ -55,7 +57,7 @@ vulkan-portability = ["wgpu-core-if-vendor-apple/vulkan"] gles = ["wgpu-core-if-native-non-apple/gles"] ## Enables the GLES backend via [ANGLE](https://github.com/google/angle) on macOS using. -angle = ["wgpu-core-if-vendor-apple/gles"] +angle = ["wgpu-core-if-target-apple/gles"] ## Enables GLES backend (WebGL) on Wasm webgl = ["wgpu-core-if-arch-wasm32/gles"] @@ -160,7 +162,8 @@ static_assertions.workspace = true wgpu-core-if-arch-wasm32 = { workspace = true, optional = true } wgpu-core-if-native-non-apple = { workspace = true, optional = true } -wgpu-core-if-vendor-apple = { workspace = true, optional = true } +wgpu-core-if-target-apple = { workspace = true, optional = true } +wgpu-core-if-target-windows = { workspace = true, optional = true } ########################################