Skip to main content

Resource

Trait Resource 

Source
pub trait Resource {
Show 13 methods // Required methods fn allocated_size(&self) -> UInteger; fn cpu_cache_mode(&self) -> CPUCacheMode; fn device(&self) -> Device; fn hazard_tracking_mode(&self) -> HazardTrackingMode; fn heap(&self) -> Option<Heap>; fn heap_offset(&self) -> UInteger; fn is_aliasable(&self) -> bool; fn label(&self) -> Option<String>; fn make_aliasable(&self); fn resource_options(&self) -> ResourceOptions; fn set_label(&self, label: &str); fn set_purgeable_state(&self, state: PurgeableState) -> PurgeableState; fn storage_mode(&self) -> StorageMode;
}
Expand description

Protocol for GPU-accessible resources.

C++ equivalent: MTL::Resource

This trait corresponds to the Objective-C protocol that resource types conform to. In Rust, concrete types like Buffer and Texture implement these methods directly.

§Example

let buffer = device.new_buffer(1024, ResourceOptions::default()).unwrap();
println!("Label: {:?}", buffer.label());
println!("Storage mode: {:?}", buffer.storage_mode());

Required Methods§

Source

fn allocated_size(&self) -> UInteger

Get the allocated size of this resource in bytes.

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

Source

fn cpu_cache_mode(&self) -> CPUCacheMode

Get the CPU cache mode for this resource.

C++ equivalent: CPUCacheMode cpuCacheMode() const

Source

fn device(&self) -> Device

Get the device that created this resource.

C++ equivalent: Device* device() const

Source

fn hazard_tracking_mode(&self) -> HazardTrackingMode

Get the hazard tracking mode for this resource.

C++ equivalent: HazardTrackingMode hazardTrackingMode() const

Source

fn heap(&self) -> Option<Heap>

Get the heap this resource was allocated from.

Returns None if the resource was not allocated from a heap.

C++ equivalent: Heap* heap() const

Source

fn heap_offset(&self) -> UInteger

Get the offset within the heap where this resource is allocated.

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

Source

fn is_aliasable(&self) -> bool

Check if this resource can be aliased with other resources.

C++ equivalent: bool isAliasable()

Source

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

Get the debug label for this resource.

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

Source

fn make_aliasable(&self)

Make this resource aliasable with other resources.

C++ equivalent: void makeAliasable()

Source

fn resource_options(&self) -> ResourceOptions

Get the resource options used to create this resource.

C++ equivalent: ResourceOptions resourceOptions() const

Source

fn set_label(&self, label: &str)

Set the debug label for this resource.

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

Source

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

Set the purgeable state for this resource.

Returns the previous purgeable state.

C++ equivalent: PurgeableState setPurgeableState(PurgeableState)

Source

fn storage_mode(&self) -> StorageMode

Get the storage mode for this resource.

C++ equivalent: StorageMode storageMode() const

Implementors§