From 25c452cbdd98817388e70e536d628a2741c35603 Mon Sep 17 00:00:00 2001 From: Clayton Walker Date: Fri, 2 Jul 2021 14:46:40 -0600 Subject: [PATCH] Add metal layer back in --- wgpu-core/src/instance.rs | 3 +-- wgpu-hal/src/metal/mod.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 5849c73a44..bd29eaa694 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -376,7 +376,6 @@ impl Global { id.0 } - /*TODO: raw CALayer handling #[cfg(metal)] pub fn instance_create_surface_metal( &self, @@ -396,7 +395,7 @@ impl Global { let mut token = Token::root(); let id = self.surfaces.prepare(id_in).assign(surface, &mut token); id.0 - }*/ + } pub fn surface_drop(&self, id: SurfaceId) { profiling::scope!("drop", "Surface"); diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index 76ecb33f5e..c6ac3f3615 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -63,6 +63,17 @@ impl crate::Api for Api { pub struct Instance {} +impl Instance { + pub fn create_surface_from_layer( + &self, + layer: &mtl::MetalLayerRef, + ) -> Surface { + unsafe { + Surface::from_layer(layer) + } + } +} + impl crate::Instance for Instance { unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result { //TODO: enable `METAL_DEVICE_WRAPPER_TYPE` environment based on the flags?