Add macOS surface creation

This commit is contained in:
Joshua Groves 2019-01-23 19:25:04 -07:00 committed by Dzmitry Malyshau
parent 8547b591ad
commit af1e240655

View File

@ -1,9 +1,5 @@
use crate::registry::{HUB, Items};
use crate::{WeaklyStored, Device,
AdapterId, DeviceId, InstanceId,
};
#[cfg(feature = "winit")]
use crate::{Surface, SurfaceId};
use crate::{AdapterId, Device, DeviceId, InstanceId, Surface, SurfaceId, WeaklyStored};
use hal::{self, Instance as _Instance, PhysicalDevice as _PhysicalDevice};
@ -67,6 +63,30 @@ pub extern "C" fn wgpu_instance_create_surface_from_winit(
.register(surface)
}
#[no_mangle]
pub extern "C" fn wgpu_instance_create_surface_from_macos_layer(
instance_id: InstanceId,
layer: *mut std::ffi::c_void,
) -> SurfaceId {
#[cfg(not(feature = "gfx-backend-metal"))]
unimplemented!();
#[cfg(feature = "gfx-backend-metal")]
{
let raw = HUB.instances
.read()
.get(instance_id)
.create_surface_from_layer(layer as *mut _);
let surface = Surface {
raw,
};
HUB.surfaces
.write()
.register(surface)
}
}
#[no_mangle]
pub extern "C" fn wgpu_instance_get_adapter(
instance_id: InstanceId,