[rs] Fix Vulkan portability support on macOS

This commit is contained in:
Dzmitry Malyshau 2020-07-21 12:38:09 -04:00
parent fcb39a1de6
commit 1bb52d8104
3 changed files with 8 additions and 5 deletions

View File

@ -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

View File

@ -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"

View File

@ -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))
}),