pub struct MetalTextureHandle { /* private fields */ }Expand description
MTLTexture* (Objective-C-bridged Metal texture).
Implementations§
Source§impl MetalTextureHandle
impl MetalTextureHandle
Sourcepub unsafe fn try_from_raw(
tex: *mut c_void,
registry_id: Option<u64>,
keep_alive: Option<KeepAlive>,
) -> Result<Self, InvalidHandleError>
pub unsafe fn try_from_raw( tex: *mut c_void, registry_id: Option<u64>, keep_alive: Option<KeepAlive>, ) -> Result<Self, InvalidHandleError>
Wrap a raw id<MTLTexture>. Borrowing: the handle is stored
non-owningly, this type has no Drop, and every obligation below
extends to each Clone.
§Safety
texmust be a live Objective-C object conforming toMTLTexture. It is stored verbatim and consumers send Metal selectors to it, so any other class is undefined behaviour. Null is rejected asInvalidHandleError::NullPointerand is not a caller obligation.- Refcount: no
retainis issued here and there is noDropthat wouldrelease. The producer’s own strong reference must outlive this value and everyCloneof it — either by parking that reference in thekeep_aliveanchor, or by the caller keeping the owningRetained<…>/ autorelease pool alive itself whenkeep_aliveisNone. BecauseClonecopies the bareidwith no ARC traffic, an earlyreleaseleaves live clones pointing at a deallocated object. registry_id, whenSome, must be the owningMTLDevice’sregistryID; importers use it to refuse textures from a different GPU than the wgpu device.- Cross-thread:
MetalTextureHandleisSend + Sync.MTLTextureinstances are thread-safe per the Metal specification and ARC retain counts are atomic, which is what makes that sound. The caller must still not mutate the texture’s contents concurrently with the consumer’s reads.
pub fn texture(&self) -> *mut c_void
pub fn registry_id(&self) -> Option<u64>
pub fn keep_alive(&self) -> Option<&KeepAlive>
Trait Implementations§
Source§impl Clone for MetalTextureHandle
impl Clone for MetalTextureHandle
Source§impl Debug for MetalTextureHandle
impl Debug for MetalTextureHandle
impl Send for MetalTextureHandle
impl Sync for MetalTextureHandle
Auto Trait Implementations§
impl !RefUnwindSafe for MetalTextureHandle
impl !UnwindSafe for MetalTextureHandle
impl Freeze for MetalTextureHandle
impl Unpin for MetalTextureHandle
impl UnsafeUnpin for MetalTextureHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more