mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Expose CA surface creation
This commit is contained in:
parent
199e7e5f3b
commit
f7e1304c38
@ -302,7 +302,7 @@ thread_local! {
|
||||
///
|
||||
/// Note: there can only be one non-borrowed `Token` alive on a thread
|
||||
/// at a time, which is enforced by `ACTIVE_TOKEN`.
|
||||
pub struct Token<'a, T: 'a> {
|
||||
pub(crate) struct Token<'a, T: 'a> {
|
||||
level: PhantomData<&'a T>,
|
||||
}
|
||||
|
||||
@ -446,6 +446,7 @@ pub(crate) struct FutureId<'a, I: TypedId, T> {
|
||||
}
|
||||
|
||||
impl<I: TypedId + Copy, T> FutureId<'_, I, T> {
|
||||
#[cfg(feature = "trace")]
|
||||
pub fn id(&self) -> I {
|
||||
self.id
|
||||
}
|
||||
@ -472,14 +473,14 @@ impl<T: Resource, I: TypedId + Copy, F: IdentityHandlerFactory<I>> Registry<T, I
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read<'a, A: Access<T>>(
|
||||
pub(crate) fn read<'a, A: Access<T>>(
|
||||
&'a self,
|
||||
_token: &'a mut Token<A>,
|
||||
) -> (RwLockReadGuard<'a, Storage<T, I>>, Token<'a, T>) {
|
||||
(self.data.read(), Token::new())
|
||||
}
|
||||
|
||||
pub fn write<'a, A: Access<T>>(
|
||||
pub(crate) fn write<'a, A: Access<T>>(
|
||||
&'a self,
|
||||
_token: &'a mut Token<A>,
|
||||
) -> (RwLockWriteGuard<'a, Storage<T, I>>, Token<'a, T>) {
|
||||
@ -508,7 +509,7 @@ impl<T: Resource, I: TypedId + Copy, F: IdentityHandlerFactory<I>> Registry<T, I
|
||||
}
|
||||
|
||||
//TODO: consider remove this once everything uses `prepare`
|
||||
pub fn register_error<A: Access<T>>(
|
||||
pub(crate) fn register_error<A: Access<T>>(
|
||||
&self,
|
||||
id_in: <F::Filter as IdentityHandler<I>>::Input,
|
||||
label: &str,
|
||||
@ -525,7 +526,7 @@ impl<T: Resource, I: TypedId + Copy, F: IdentityHandlerFactory<I>> Registry<T, I
|
||||
value
|
||||
}
|
||||
|
||||
pub fn unregister<'a, A: Access<T>>(
|
||||
pub(crate) fn unregister<'a, A: Access<T>>(
|
||||
&self,
|
||||
id: I,
|
||||
_token: &'a mut Token<A>,
|
||||
|
||||
@ -631,6 +631,28 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
id.0
|
||||
}
|
||||
|
||||
#[cfg(metal)]
|
||||
pub fn instance_create_surface_metal(
|
||||
&self,
|
||||
layer: *mut std::ffi::c_void,
|
||||
id_in: Input<G, SurfaceId>,
|
||||
) -> SurfaceId {
|
||||
span!(_guard, INFO, "Instance::instance_create_surface_metal");
|
||||
|
||||
let surface =
|
||||
Surface {
|
||||
#[cfg(feature = "vulkan-portability")]
|
||||
vulkan: None, //TODO: create_surface_from_layer ?
|
||||
metal: self.instance.metal.as_ref().map(|inst| {
|
||||
inst.create_surface_from_layer(unsafe { std::mem::transmute(layer) })
|
||||
}),
|
||||
};
|
||||
|
||||
let mut token = Token::root();
|
||||
let id = self.surfaces.register_identity(id_in, surface, &mut token);
|
||||
id.0
|
||||
}
|
||||
|
||||
pub fn surface_drop(&self, id: SurfaceId) {
|
||||
span!(_guard, INFO, "Surface::drop");
|
||||
let mut token = Token::root();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user