From 655828f88fee9d9f4a0985770fc012cc2fd6a7ec Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Tue, 21 Jul 2020 12:38:09 -0400 Subject: [PATCH] Fix Vulkan portability support on macOS --- .github/workflows/ci.yml | 2 +- Cargo.toml | 2 +- src/lib.rs | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5109bb49..a923630d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: include: - os: macos-10.15 wasm: false - CHECK_COMMAND: cargo check --all-targets + CHECK_COMMAND: cargo check --all-targets --features vulkan-portability TEST_COMMAND: cargo test --all-targets --no-run - os: ubuntu-18.04 wasm: false diff --git a/Cargo.toml b/Cargo.toml index c80820aaf..ed93f8228 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ trace = ["serde", "wgc/trace"] replay = ["serde", "wgc/replay"] subscriber = ["wgc/subscriber"] # Make Vulkan backend available on platforms where it is by default not, e.g. macOS -vulkan = ["wgc/gfx-backend-vulkan"] +vulkan-portability = ["wgc/gfx-backend-vulkan"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" diff --git a/src/lib.rs b/src/lib.rs index 49d168bc1..217d6c400 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1036,6 +1036,11 @@ impl Instance { } } + /// Creates a surface from `CoreAnimationLayer`. + /// + /// # Safety + /// + /// - layer must be a valid object to create a surface upon. #[cfg(any(target_os = "ios", target_os = "macos"))] pub unsafe fn create_surface_from_core_animation_layer( &self, @@ -1043,9 +1048,7 @@ impl Instance { ) -> Surface { let surface = wgc::instance::Surface { #[cfg(feature = "vulkan-portability")] - vulkan: self.context.instance.vulkan.as_ref().map(|inst| { - inst.create_surface_from_layer(layer as *mut _, cfg!(debug_assertions)) - }), + vulkan: None, //TODO: create_surface_from_layer ? metal: self.context.instance.metal.as_ref().map(|inst| { inst.create_surface_from_layer(layer as *mut _, cfg!(debug_assertions)) }),