mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
Add macOS surface creation
This commit is contained in:
parent
8547b591ad
commit
af1e240655
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user