Skip to main content

BorrowedAppleMetalDevice

Struct BorrowedAppleMetalDevice 

Source
pub struct BorrowedAppleMetalDevice<'a> { /* private fields */ }
Expand description

An apple_metal::MetalDevice borrowed from an SCK MetalDevice.

Returned by MetalDevice::as_apple_metal. Dereferences to [apple_metal::MetalDevice] and does not release the underlying MTLDevice; the borrow keeps the owning MetalDevice alive.

Methods from Deref<Target = MetalDevice>§

pub fn name(&self) -> String

Human-readable device name.

pub fn registry_id(&self) -> u64

Global IORegistry identifier for the device.

pub fn supports_dynamic_libraries(&self) -> bool

Whether this device supports Metal dynamic libraries.

pub fn supports_render_dynamic_libraries(&self) -> bool

Whether this device supports render-stage dynamic libraries.

pub fn supports_raytracing(&self) -> bool

Whether this device supports compute ray tracing.

pub fn supports_function_pointers(&self) -> bool

pub fn supports_counter_sampling(&self, sampling_point: usize) -> bool

Query support for a hardware counter sampling point.

pub fn counter_set_names(&self) -> Vec<String>

Return the names of all counter sets exposed by this device.

pub fn new_command_queue_with_max_command_buffer_count( &self, max_command_buffer_count: usize, ) -> Option<CommandQueue>

Create a command queue with an explicit maximum in-flight command-buffer count.

pub fn new_command_queue_with_log_state( &self, max_command_buffer_count: usize, log_state: &LogState, ) -> Option<CommandQueue>

Create a command queue that uses log_state for shader logging.

pub fn new_heap(&self, size: usize, storage_mode: usize) -> Option<Heap>

Create a heap with the requested size and storage mode.

pub fn new_fence(&self) -> Option<Fence>

Create a new fence.

pub fn new_shared_event(&self) -> Option<Event>

Create a new shared event.

pub fn new_dynamic_library_with_source( &self, source: &str, install_name: &str, ) -> Result<DynamicLibrary, String>

Compile source as a Metal dynamic library with the given install_name.

§Errors

Returns Metal’s localized compiler or linker error on failure.

pub fn load_dynamic_library( &self, path: &Path, ) -> Result<DynamicLibrary, String>

Load a serialized Metal dynamic library from path.

§Errors

Returns Metal’s localized file or linker error on failure.

pub fn new_binary_archive( &self, path: Option<&Path>, ) -> Result<BinaryArchive, String>

Create a binary archive, optionally loading it from path first.

§Errors

Returns Metal’s localized archive creation error on failure.

pub fn new_indirect_command_buffer( &self, command_types: usize, max_command_count: usize, max_vertex_buffer_bind_count: usize, max_fragment_buffer_bind_count: usize, max_kernel_buffer_bind_count: usize, options: usize, ) -> Option<IndirectCommandBuffer>

Create a new indirect command buffer.

pub fn new_acceleration_structure_with_size( &self, size: usize, ) -> Option<AccelerationStructure>

Allocate storage for a ray-tracing acceleration structure.

pub fn new_counter_sample_buffer( &self, counter_set_name: &str, sample_count: usize, storage_mode: usize, label: Option<&str>, ) -> Result<CounterSampleBuffer, String>

Create a counter sample buffer for the named counter set.

§Errors

Returns Metal’s localized counter-sample-buffer error on failure.

pub fn new_log_state( &self, level: usize, buffer_size: isize, ) -> Result<LogState, String>

Create a shader log state.

§Errors

Returns Metal’s localized log-state creation error on failure.

pub fn new_residency_set( &self, label: Option<&str>, initial_capacity: usize, ) -> Result<ResidencySet, String>

Create a residency set.

§Errors

Returns Metal’s localized residency-set creation error on failure.

pub fn new_argument_encoder_with_descriptors( &self, descriptors: &[ArgumentDescriptor], ) -> Result<ArgumentEncoder, ArgumentEncoderError>

Create an argument encoder from explicit descriptors.

§Errors

Returns descriptor validation failures or native creation failure.

pub fn max_buffer_length(&self) -> usize

pub fn new_tensor( &self, descriptor: &TensorDescriptor, ) -> Result<MetalTensor, TensorError>

pub fn new_spatial_scaler( &self, descriptor: &SpatialScalerDescriptor, ) -> Option<SpatialScaler>

Create a MTLFXSpatialScaler for this device.

pub fn new_temporal_scaler( &self, descriptor: &TemporalScalerDescriptor, ) -> Option<TemporalScaler>

Create a MTLFXTemporalScaler for this device.

pub fn new_compute_pipeline_state_with_descriptor( &self, descriptor: &ComputePipelineDescriptor<'_>, ) -> Result<ComputePipelineState, String>

Compile a compute pipeline from a public MTLComputePipelineDescriptor wrapper.

§Errors

Returns Metal’s localized pipeline compiler error on failure.

pub fn new_render_pipeline_state_with_descriptor( &self, descriptor: &RenderPipelineDescriptor<'_>, ) -> Result<RenderPipelineState, String>

Compile a render pipeline from a public MTLRenderPipelineDescriptor wrapper.

§Errors

Returns Metal’s localized pipeline compiler error on failure.

pub fn new_tile_render_pipeline_state( &self, descriptor: &TileRenderPipelineDescriptor<'_>, ) -> Result<RenderPipelineState, String>

Compile a tile render pipeline from a public MTLTileRenderPipelineDescriptor wrapper.

§Errors

Returns Metal’s localized pipeline compiler error on failure.

pub fn new_render_pipeline_state( &self, vertex: &MetalFunction, fragment: &MetalFunction, color_pixel_format: usize, sample_count: usize, ) -> Result<RenderPipelineState, String>

Compile a render pipeline state from vertex and fragment functions.

§Errors

Returns Metal’s localized pipeline compiler error on failure.

pub fn argument_buffers_support(&self) -> usize

Query the device for the supported argument-buffer tier.

pub fn new_depth_stencil_state( &self, descriptor: &DepthStencilDescriptor, ) -> Option<DepthStencilState>

Compile a MTLDepthStencilState from the given descriptor.

pub fn new_sampler_state( &self, descriptor: &SamplerDescriptor, ) -> Option<SamplerState>

Compile a MTLSamplerState from the given descriptor.

pub fn as_ptr(&self) -> *mut c_void

Raw id<MTLDevice> pointer.

pub fn has_unified_memory(&self) -> bool

True if the GPU uses unified memory (Apple Silicon).

pub fn recommended_max_working_set_size(&self) -> u64

Recommended maximum working-set size in bytes.

pub fn supports_family(&self, family: i64) -> bool

True if this device supports the requested feature family — see [gpu_family].

pub fn new_buffer(&self, length: usize, options: usize) -> Option<MetalBuffer>

Allocate a GPU-visible buffer of length bytes. options is an MTLResourceOptions bitmask (see [resource_options]).

pub fn new_buffer_with_bytes( &self, bytes: &[u8], options: usize, ) -> Option<MetalBuffer>

pub fn new_texture(&self, descriptor: TextureDescriptor) -> Option<MetalTexture>

Allocate a fresh MTLTexture matching descriptor.

pub fn new_command_queue(&self) -> Option<CommandQueue>

Create a new MTLCommandQueue to schedule GPU work.

pub fn new_library_with_source( &self, source: &str, ) -> Result<MetalLibrary, String>

Compile a Metal Shading Language source string into a runtime MTLLibrary. On error, returns the localized Metal compiler diagnostic.

§Errors

Returns the Metal compiler’s localized error string on failure.

pub fn new_compute_pipeline_state( &self, function: &MetalFunction, ) -> Result<ComputePipelineState, String>

Compile a kernel into a MTLComputePipelineState ready for dispatch on a command buffer.

§Errors

Returns the Metal pipeline compiler’s localized error string on failure.

Trait Implementations§

Source§

impl Debug for BorrowedAppleMetalDevice<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for BorrowedAppleMetalDevice<'_>

Source§

type Target = MetalDevice

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.