pub struct MTLHeapDescriptor { /* private fields */ }MTLHeap only.Expand description
Implementations§
Source§impl MTLHeapDescriptor
impl MTLHeapDescriptor
Sourcepub fn size(&self) -> NSUInteger
pub fn size(&self) -> NSUInteger
Requested size of the heap’s backing memory.
The size may be rounded up to GPU page granularity.
Sourcepub fn setSize(&self, size: NSUInteger)
pub fn setSize(&self, size: NSUInteger)
Setter for size.
Sourcepub fn storageMode(&self) -> MTLStorageMode
Available on crate feature MTLResource only.
pub fn storageMode(&self) -> MTLStorageMode
MTLResource only.Storage mode for the heap. Default is MTLStorageModePrivate.
All resources created from this heap share the same storage mode. MTLStorageModeManaged and MTLStorageModeMemoryless are disallowed.
Sourcepub fn setStorageMode(&self, storage_mode: MTLStorageMode)
Available on crate feature MTLResource only.
pub fn setStorageMode(&self, storage_mode: MTLStorageMode)
MTLResource only.Setter for storageMode.
Sourcepub fn cpuCacheMode(&self) -> MTLCPUCacheMode
Available on crate feature MTLResource only.
pub fn cpuCacheMode(&self) -> MTLCPUCacheMode
MTLResource only.CPU cache mode for the heap. Default is MTLCPUCacheModeDefaultCache.
All resources created from this heap share the same cache mode. CPU cache mode is ignored for MTLStorageModePrivate.
Sourcepub fn setCpuCacheMode(&self, cpu_cache_mode: MTLCPUCacheMode)
Available on crate feature MTLResource only.
pub fn setCpuCacheMode(&self, cpu_cache_mode: MTLCPUCacheMode)
MTLResource only.Setter for cpuCacheMode.
Sourcepub fn sparsePageSize(&self) -> MTLSparsePageSize
Available on crate feature MTLResource only.
pub fn sparsePageSize(&self) -> MTLSparsePageSize
MTLResource only.The sparse page size to use for resources created from the heap.
Sourcepub fn setSparsePageSize(&self, sparse_page_size: MTLSparsePageSize)
Available on crate feature MTLResource only.
pub fn setSparsePageSize(&self, sparse_page_size: MTLSparsePageSize)
MTLResource only.Setter for sparsePageSize.
Sourcepub fn hazardTrackingMode(&self) -> MTLHazardTrackingMode
Available on crate feature MTLResource only.
pub fn hazardTrackingMode(&self) -> MTLHazardTrackingMode
MTLResource only.Set hazard tracking mode for the heap. The default value is MTLHazardTrackingModeDefault.
For heaps, MTLHazardTrackingModeDefault is treated as MTLHazardTrackingModeUntracked. Setting hazardTrackingMode to MTLHazardTrackingModeTracked causes hazard tracking to be enabled heap. When a resource on a hazard tracked heap is modified, reads and writes from all resources suballocated on that heap will be delayed until the modification is complete. Similarly, modifying heap resources will be delayed until all in-flight reads and writes from all resources suballocated on that heap have completed. For optimal performance, perform hazard tracking manually through MTLFence or MTLEvent instead. All resources created from this heap shared the same hazard tracking mode.
Sourcepub fn setHazardTrackingMode(&self, hazard_tracking_mode: MTLHazardTrackingMode)
Available on crate feature MTLResource only.
pub fn setHazardTrackingMode(&self, hazard_tracking_mode: MTLHazardTrackingMode)
MTLResource only.Setter for hazardTrackingMode.
Sourcepub fn resourceOptions(&self) -> MTLResourceOptions
Available on crate feature MTLResource only.
pub fn resourceOptions(&self) -> MTLResourceOptions
MTLResource only.A packed tuple of the storageMode, cpuCacheMode and hazardTrackingMode properties.
Modifications to this property are reflected in the other properties and vice versa.
Sourcepub fn setResourceOptions(&self, resource_options: MTLResourceOptions)
Available on crate feature MTLResource only.
pub fn setResourceOptions(&self, resource_options: MTLResourceOptions)
MTLResource only.Setter for resourceOptions.
Sourcepub fn type(&self) -> MTLHeapType
pub fn type(&self) -> MTLHeapType
The type of the heap. The default value is MTLHeapTypeAutomatic.
This constrains the resource creation functions that are available.
Sourcepub fn setType(&self, type: MTLHeapType)
pub fn setType(&self, type: MTLHeapType)
Setter for type.
Sourcepub fn maxCompatiblePlacementSparsePageSize(&self) -> MTLSparsePageSize
Available on crate feature MTLResource only.
pub fn maxCompatiblePlacementSparsePageSize(&self) -> MTLSparsePageSize
MTLResource only.Specifies the largest sparse page size that the Metal heap supports.
This parameter only affects the heap if you set the type property of this descriptor
to MTLHeapType/MTLHeapTypePlacement.
The value you assign to this property determines the compatibility of the Metal heap with with placement sparse resources, because placement sparse resources require that their sparse page size be less than or equal to the placement sparse page of the Metal heap that this property controls.
Sourcepub fn setMaxCompatiblePlacementSparsePageSize(
&self,
max_compatible_placement_sparse_page_size: MTLSparsePageSize,
)
Available on crate feature MTLResource only.
pub fn setMaxCompatiblePlacementSparsePageSize( &self, max_compatible_placement_sparse_page_size: MTLSparsePageSize, )
MTLResource only.Setter for maxCompatiblePlacementSparsePageSize.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for MTLHeapDescriptor
impl AsRef<AnyObject> for MTLHeapDescriptor
Source§impl AsRef<MTLHeapDescriptor> for MTLHeapDescriptor
impl AsRef<MTLHeapDescriptor> for MTLHeapDescriptor
Source§impl AsRef<NSObject> for MTLHeapDescriptor
impl AsRef<NSObject> for MTLHeapDescriptor
Source§impl Borrow<AnyObject> for MTLHeapDescriptor
impl Borrow<AnyObject> for MTLHeapDescriptor
Source§impl Borrow<NSObject> for MTLHeapDescriptor
impl Borrow<NSObject> for MTLHeapDescriptor
Source§impl ClassType for MTLHeapDescriptor
impl ClassType for MTLHeapDescriptor
Source§const NAME: &'static str = "MTLHeapDescriptor"
const NAME: &'static str = "MTLHeapDescriptor"
Source§type ThreadKind = <<MTLHeapDescriptor as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<MTLHeapDescriptor as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for MTLHeapDescriptor
impl CopyingHelper for MTLHeapDescriptor
Source§type Result = MTLHeapDescriptor
type Result = MTLHeapDescriptor
Self if the type has no
immutable counterpart. Read moreSource§impl Debug for MTLHeapDescriptor
impl Debug for MTLHeapDescriptor
Source§impl DefaultRetained for MTLHeapDescriptor
impl DefaultRetained for MTLHeapDescriptor
Source§impl Deref for MTLHeapDescriptor
impl Deref for MTLHeapDescriptor
Source§impl Hash for MTLHeapDescriptor
impl Hash for MTLHeapDescriptor
Source§impl Message for MTLHeapDescriptor
impl Message for MTLHeapDescriptor
Source§impl NSCopying for MTLHeapDescriptor
impl NSCopying for MTLHeapDescriptor
Source§impl NSObjectProtocol for MTLHeapDescriptor
impl NSObjectProtocol for MTLHeapDescriptor
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref