mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Merge #1591
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:
@@ -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");
|
||||
|
||||
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user