pub struct MetalContext {
pub allocation_limit: Cell<Option<usize>>,
pub device: Retained<ProtocolObject<dyn MTLDevice>>,
pub queue: Retained<ProtocolObject<dyn MTLCommandQueue>>,
}Fields§
§allocation_limit: Cell<Option<usize>>§device: Retained<ProtocolObject<dyn MTLDevice>>§queue: Retained<ProtocolObject<dyn MTLCommandQueue>>Implementations§
Source§impl MetalContext
impl MetalContext
pub fn new() -> Result<Self>
pub fn compile_library( &self, source: &str, ) -> Result<Retained<ProtocolObject<dyn MTLLibrary>>>
pub fn pipeline( &self, library: &ProtocolObject<dyn MTLLibrary>, function: &str, ) -> Result<Retained<ProtocolObject<dyn MTLComputePipelineState>>>
Sourcepub unsafe fn wrap_mmap(
&self,
bytes: &[u8],
) -> Result<Retained<ProtocolObject<dyn MTLBuffer>>>
pub unsafe fn wrap_mmap( &self, bytes: &[u8], ) -> Result<Retained<ProtocolObject<dyn MTLBuffer>>>
Expose an existing mapping as a Metal buffer without copying it.
§Safety
The page-rounded region must remain mapped until this buffer and all GPU work using it are finished. The caller must synchronize CPU writes with GPU access; the buffer does not own the mapping.
Sourcepub unsafe fn wrap_region(
&self,
ptr: *mut u8,
len: usize,
) -> Result<Retained<ProtocolObject<dyn MTLBuffer>>>
pub unsafe fn wrap_region( &self, ptr: *mut u8, len: usize, ) -> Result<Retained<ProtocolObject<dyn MTLBuffer>>>
Wrap a page-aligned portion of a mapping owned by the expert pool.
§Safety
ptr..ptr+len must remain mapped for the buffer’s lifetime and all
submitted GPU work. CPU/GPU access must obey the pool’s event
handshake, including outstanding reads before a slot is reused.
fn check_allocation(&self, len: usize) -> Result<()>
pub fn new_buffer( &self, len: usize, ) -> Result<Retained<ProtocolObject<dyn MTLBuffer>>>
pub fn throttle_probe(&self) -> Result<f64>
Auto Trait Implementations§
impl !Freeze for MetalContext
impl !RefUnwindSafe for MetalContext
impl !Sync for MetalContext
impl !UnwindSafe for MetalContext
impl Send for MetalContext
impl Unpin for MetalContext
impl UnsafeUnpin for MetalContext
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more