MTLResource

Trait MTLResource 

Source
pub unsafe trait MTLResource: MTLAllocation {
Show 13 methods // Provided methods fn label(&self) -> Option<Retained<NSString>> where Self: Sized + Message { ... } fn setLabel(&self, label: Option<&NSString>) where Self: Sized + Message { ... } fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>> where Self: Sized + Message { ... } fn cpuCacheMode(&self) -> MTLCPUCacheMode where Self: Sized + Message { ... } fn storageMode(&self) -> MTLStorageMode where Self: Sized + Message { ... } fn hazardTrackingMode(&self) -> MTLHazardTrackingMode where Self: Sized + Message { ... } fn resourceOptions(&self) -> MTLResourceOptions where Self: Sized + Message { ... } fn setPurgeableState(&self, state: MTLPurgeableState) -> MTLPurgeableState where Self: Sized + Message { ... } fn heap(&self) -> Option<Retained<ProtocolObject<dyn MTLHeap>>> where Self: Sized + Message { ... } fn heapOffset(&self) -> NSUInteger where Self: Sized + Message { ... } fn allocatedSize(&self) -> NSUInteger where Self: Sized + Message { ... } unsafe fn makeAliasable(&self) where Self: Sized + Message { ... } fn isAliasable(&self) -> bool where Self: Sized + Message { ... }
}
Available on crate features MTLAllocation and MTLResource only.
Expand description

Common APIs available for MTLBuffer and MTLTexture instances

See also Apple’s documentation

Provided Methods§

Source

fn label(&self) -> Option<Retained<NSString>>
where Self: Sized + Message,

A string to help identify this object.

Source

fn setLabel(&self, label: Option<&NSString>)
where Self: Sized + Message,

Setter for label.

This is copied when set.

Source

fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>
where Self: Sized + Message,

Available on crate feature MTLDevice only.

The device this resource was created against. This resource can only be used with this device.

Source

fn cpuCacheMode(&self) -> MTLCPUCacheMode
where Self: Sized + Message,

The cache mode used for the CPU mapping for this resource

Source

fn storageMode(&self) -> MTLStorageMode
where Self: Sized + Message,

The resource storage mode used for the CPU mapping for this resource

Source

fn hazardTrackingMode(&self) -> MTLHazardTrackingMode
where Self: Sized + Message,

Whether or not the resource is hazard tracked.

This value can be either MTLHazardTrackingModeUntracked or MTLHazardTrackingModeTracked. Resources created from heaps are by default untracked, whereas resources created from the device are by default tracked.

Source

fn resourceOptions(&self) -> MTLResourceOptions
where Self: Sized + Message,

A packed tuple of the storageMode, cpuCacheMode and hazardTrackingMode properties.

Source

fn setPurgeableState(&self, state: MTLPurgeableState) -> MTLPurgeableState
where Self: Sized + Message,

Set (or query) the purgeability state of a resource

Synchronously set the purgeability state of a resource and return what the prior (or current) state is. FIXME: If the device is keeping a cached copy of the resource, both the shared copy and cached copy are made purgeable. Any access to the resource by either the CPU or device will be undefined.

Source

fn heap(&self) -> Option<Retained<ProtocolObject<dyn MTLHeap>>>
where Self: Sized + Message,

Available on crate feature MTLHeap only.

The heap from which this resouce was created.

Nil when this resource is not backed by a heap.

Source

fn heapOffset(&self) -> NSUInteger
where Self: Sized + Message,

The offset inside the heap at which this resource was created.

Zero when this resource was not created on a heap with MTLHeapTypePlacement.

Source

fn allocatedSize(&self) -> NSUInteger
where Self: Sized + Message,

The size in bytes occupied by this resource

Source

unsafe fn makeAliasable(&self)
where Self: Sized + Message,

Allow future heap sub-allocations to alias against this resource’s memory.

It is illegal to call this method on a non heap-based resource. It is also illegal to call this method on texture views created from heap-based textures. The debug layer will raise an exception. Calling this method on textures sub-allocated from Buffers backed by heap memory has no effect. Once a resource is made aliasable, the decision cannot be reverted.

Source

fn isAliasable(&self) -> bool
where Self: Sized + Message,

Returns whether future heap sub-allocations may alias against this resource’s memory.

Returns: YES if <st

makeAliasable </st was previously successfully called on this resource. NO otherwise. If resource is sub-allocated from other resource created on the heap, isAliasable returns aliasing state of that base resource. Also returns NO when storage mode is memoryless.

Trait Implementations§

Source§

impl ProtocolType for dyn MTLResource

Source§

const NAME: &'static str = "MTLResource"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn MTLResource
where T: ?Sized + Message + MTLResource,

Implementations on Foreign Types§

Source§

impl<T> MTLResource for ProtocolObject<T>
where T: ?Sized + MTLResource,

Implementors§