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?