1591: Expose calayer r=kvark a=Sineaggi

**Description**

This pr restores the ability to create a surface from a pre-existing CAMetalLayer. This is required for wgpu-native.

Co-authored-by: Clayton Walker <cwalker@sofi.org>
This commit is contained in:
bors[bot]
2021-07-03 00:23:25 +00:00
committed by GitHub
2 changed files with 12 additions and 2 deletions

View File

@@ -376,7 +376,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
id.0
}
/*TODO: raw CALayer handling
#[cfg(metal)]
pub fn instance_create_surface_metal(
&self,
@@ -396,7 +395,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
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");

View File

@@ -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<Api> for Instance {
unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
//TODO: enable `METAL_DEVICE_WRAPPER_TYPE` environment based on the flags?