Skip to content

Commit 9a5e646

Browse files
committed
[hal] Make Vulkan and GLES not depend on Metal-specific dependencies
1 parent ffabb52 commit 9a5e646

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

wgpu-hal/Cargo.toml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ metal = [
4444
# Metal is only available on Apple platforms, therefore request MSL output also only if we target an Apple platform.
4545
"naga/msl-out-if-target-apple",
4646
"dep:block",
47+
"dep:core-graphics-types",
48+
"dep:metal",
49+
"dep:objc",
4750
"dep:raw-window-metal",
4851
]
4952
vulkan = [
@@ -52,9 +55,9 @@ vulkan = [
5255
"dep:gpu-alloc",
5356
"dep:gpu-descriptor",
5457
"dep:libloading",
58+
"dep:raw-window-metal",
5559
"dep:smallvec",
5660
"dep:android_system_properties",
57-
"dep:raw-window-metal",
5861
]
5962
gles = [
6063
"naga/glsl-out",
@@ -63,6 +66,7 @@ gles = [
6366
"dep:khronos-egl",
6467
"dep:libloading",
6568
"dep:ndk-sys",
69+
"dep:objc",
6670
"windows/Win32_Graphics_OpenGL",
6771
"windows/Win32_Graphics_Gdi",
6872
"windows/Win32_System_LibraryLoader",
@@ -167,14 +171,15 @@ glutin_wgl_sys = { workspace = true, optional = true }
167171
[target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies]
168172
# backend: Metal
169173
block = { workspace = true, optional = true }
174+
metal = { workspace = true, optional = true }
175+
core-graphics-types = { workspace = true, optional = true }
176+
177+
# backend: Metal + GLES
178+
objc = { workspace = true, optional = true }
170179

171180
# backend: Metal + Vulkan
172181
raw-window-metal = { workspace = true, optional = true }
173182

174-
metal.workspace = true
175-
objc.workspace = true
176-
core-graphics-types.workspace = true
177-
178183
[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies]
179184
wasm-bindgen.workspace = true
180185
web-sys = { workspace = true, features = [

wgpu-hal/src/vulkan/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ impl super::Instance {
511511
Ok(self.create_surface_from_vk_surface_khr(surface))
512512
}
513513

514-
#[cfg(metal)]
514+
#[cfg(target_vendor = "apple")]
515515
fn create_surface_from_layer(
516516
&self,
517517
layer: raw_window_metal::Layer,

0 commit comments

Comments
 (0)