Skip to main content

Heap

Struct Heap 

Source
pub struct Heap(/* private fields */);
Expand description

A memory pool from which resources can be allocated.

C++ equivalent: MTL::Heap

Implementations§

Source§

impl Heap

Source

pub unsafe fn from_raw(ptr: *mut c_void) -> Option<Self>

Create a Heap from a raw pointer.

§Safety

The pointer must be a valid Metal heap object.

Source

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

Get the raw pointer to the heap.

Source

pub fn label(&self) -> Option<String>

Get the label for this heap.

C++ equivalent: NS::String* label() const

Source

pub fn set_label(&self, label: &str)

Set the label for this heap.

C++ equivalent: void setLabel(const NS::String*)

Source

pub fn device(&self) -> Device

Get the device that created this heap.

C++ equivalent: Device* device() const

Source

pub fn storage_mode(&self) -> StorageMode

Get the storage mode.

C++ equivalent: StorageMode storageMode() const

Source

pub fn cpu_cache_mode(&self) -> CPUCacheMode

Get the CPU cache mode.

C++ equivalent: CPUCacheMode cpuCacheMode() const

Source

pub fn hazard_tracking_mode(&self) -> HazardTrackingMode

Get the hazard tracking mode.

C++ equivalent: HazardTrackingMode hazardTrackingMode() const

Source

pub fn resource_options(&self) -> ResourceOptions

Get the resource options.

C++ equivalent: ResourceOptions resourceOptions() const

Source

pub fn size(&self) -> UInteger

Get the heap size in bytes.

C++ equivalent: NS::UInteger size() const

Source

pub fn used_size(&self) -> UInteger

Get the currently used size in bytes.

C++ equivalent: NS::UInteger usedSize() const

Source

pub fn current_allocated_size(&self) -> UInteger

Get the current size available for new allocations.

C++ equivalent: NS::UInteger currentAllocatedSize() const

Source

pub fn max_available_size(&self, alignment: UInteger) -> UInteger

Get the maximum size available for new allocations.

C++ equivalent: NS::UInteger maxAvailableSize(NS::UInteger alignment)

Source

pub fn heap_type(&self) -> HeapType

Get the heap type.

C++ equivalent: HeapType type() const

Source

pub fn set_purgeable_state(&self, state: PurgeableState) -> PurgeableState

Set the purgeable state.

C++ equivalent: PurgeableState setPurgeableState(PurgeableState state)

Source

pub fn new_buffer( &self, length: UInteger, options: ResourceOptions, ) -> Option<Buffer>

Create a buffer from the heap.

C++ equivalent: Buffer* newBuffer(NS::UInteger length, MTL::ResourceOptions options)

Source

pub fn new_buffer_with_offset( &self, length: UInteger, options: ResourceOptions, offset: UInteger, ) -> Option<Buffer>

Create a buffer from the heap with offset.

C++ equivalent: Buffer* newBuffer(NS::UInteger length, MTL::ResourceOptions options, NS::UInteger offset)

Source

pub unsafe fn new_texture(&self, descriptor: *const c_void) -> Option<Texture>

Create a texture from the heap.

C++ equivalent: Texture* newTexture(const TextureDescriptor*)

§Safety

The descriptor pointer must be valid.

Source

pub unsafe fn new_texture_with_offset( &self, descriptor: *const c_void, offset: UInteger, ) -> Option<Texture>

Create a texture from the heap with offset.

C++ equivalent: Texture* newTexture(const TextureDescriptor*, NS::UInteger offset)

§Safety

The descriptor pointer must be valid.

Source

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

Create an acceleration structure from the heap with a given size.

C++ equivalent: AccelerationStructure* newAccelerationStructure(NS::UInteger size)

Source

pub fn new_acceleration_structure( &self, descriptor: &AccelerationStructureDescriptor, ) -> Option<AccelerationStructure>

Create an acceleration structure from the heap with a descriptor.

C++ equivalent: AccelerationStructure* newAccelerationStructure(const AccelerationStructureDescriptor*)

Source

pub fn new_acceleration_structure_with_size_and_offset( &self, size: UInteger, offset: UInteger, ) -> Option<AccelerationStructure>

Create an acceleration structure from the heap with size and offset.

C++ equivalent: AccelerationStructure* newAccelerationStructure(NS::UInteger size, NS::UInteger offset)

Source

pub fn new_acceleration_structure_with_offset( &self, descriptor: &AccelerationStructureDescriptor, offset: UInteger, ) -> Option<AccelerationStructure>

Create an acceleration structure from the heap with descriptor and offset.

C++ equivalent: AccelerationStructure* newAccelerationStructure(const AccelerationStructureDescriptor*, NS::UInteger offset)

Trait Implementations§

Source§

impl Clone for Heap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Heap

Source§

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

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

impl Drop for Heap

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Referencing for Heap

Source§

fn as_ptr(&self) -> *const c_void

Get the raw pointer to the Objective-C object.
Source§

fn as_mut_ptr(&self) -> *mut c_void

Get the raw mutable pointer to the Objective-C object.
Source§

fn retain(&self) -> Self
where Self: Clone,

Retain the object, incrementing its reference count. Read more
Source§

fn release(&self)

Release the object, decrementing its reference count. Read more
Source§

fn autorelease(&self) -> Self
where Self: Clone,

Autorelease the object. Read more
Source§

fn retain_count(&self) -> usize

Get the retain count of the object. Read more
Source§

impl Send for Heap

Source§

impl Sync for Heap

Auto Trait Implementations§

§

impl Freeze for Heap

§

impl RefUnwindSafe for Heap

§

impl Unpin for Heap

§

impl UnwindSafe for Heap

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.