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§
Sourcefn allocated_size(&self) -> UInteger
fn allocated_size(&self) -> UInteger
Get the allocated size of this resource in bytes.
C++ equivalent: NS::UInteger allocatedSize() const
Sourcefn cpu_cache_mode(&self) -> CPUCacheMode
fn cpu_cache_mode(&self) -> CPUCacheMode
Get the CPU cache mode for this resource.
C++ equivalent: CPUCacheMode cpuCacheMode() const
Sourcefn device(&self) -> Device
fn device(&self) -> Device
Get the device that created this resource.
C++ equivalent: Device* device() const
Sourcefn hazard_tracking_mode(&self) -> HazardTrackingMode
fn hazard_tracking_mode(&self) -> HazardTrackingMode
Get the hazard tracking mode for this resource.
C++ equivalent: HazardTrackingMode hazardTrackingMode() const
Sourcefn heap(&self) -> Option<Heap>
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
Sourcefn heap_offset(&self) -> UInteger
fn heap_offset(&self) -> UInteger
Get the offset within the heap where this resource is allocated.
C++ equivalent: NS::UInteger heapOffset() const
Sourcefn is_aliasable(&self) -> bool
fn is_aliasable(&self) -> bool
Check if this resource can be aliased with other resources.
C++ equivalent: bool isAliasable()
Sourcefn label(&self) -> Option<String>
fn label(&self) -> Option<String>
Get the debug label for this resource.
C++ equivalent: NS::String* label() const
Sourcefn make_aliasable(&self)
fn make_aliasable(&self)
Make this resource aliasable with other resources.
C++ equivalent: void makeAliasable()
Sourcefn resource_options(&self) -> ResourceOptions
fn resource_options(&self) -> ResourceOptions
Get the resource options used to create this resource.
C++ equivalent: ResourceOptions resourceOptions() const
Sourcefn set_label(&self, label: &str)
fn set_label(&self, label: &str)
Set the debug label for this resource.
C++ equivalent: void setLabel(const NS::String*)
Sourcefn set_purgeable_state(&self, state: PurgeableState) -> PurgeableState
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)
Sourcefn storage_mode(&self) -> StorageMode
fn storage_mode(&self) -> StorageMode
Get the storage mode for this resource.
C++ equivalent: StorageMode storageMode() const