MPSAccelerationStructure

Struct MPSAccelerationStructure 

Source
pub struct MPSAccelerationStructure { /* private fields */ }
๐Ÿ‘ŽDeprecated
Available on crate features MPSAccelerationStructure and MPSCore and MPSKernel only.
Expand description

A data structure built over geometry used to accelerate ray tracing

Do not use this base class directly. Use one of the derived classes instead. The general pattern for creating an acceleration structure is as follows. First, create the acceleration structure:

     MPSTriangleAccelerationStructure *accelerationStructure = nil;
     accelerationStructure = [[MPSTriangleAccelerationStructure alloc] initWithDevice:device];

Then, assign values to the acceleration structureโ€™s properties:

     accelerationStructure.vertexBuffer = vertexBuffer;
     accelerationStructure.triangleCount = triangleCount;

Finally, the acceleration structure must be built:

     [accelerationStructure rebuild];

The acceleration structure can then be used to encode ray intersection tests with an MPSRayIntersector:

     [raytracer encodeIntersectionToCommandBuffer:commandBuffer
                                 intersectionType:MPSIntersectionTypeNearest
                                        rayBuffer:rayBuffer
                                  rayBufferOffset:0
                               intersectionBuffer:intersectionBuffer
                         intersectionBufferOffset:0
                                         rayCount:rayCount
                            accelerationStructure:accelerationStructure];

Asynchronous Acceleration Structure Builds: Rebuilding an acceleration structure is an expensive operation. Note that there is also a method to rebuild the acceleration structure asynchronously to avoid blocking the main thread.

     [accelerationStructure rebuildWithCompletionHandler:^(MPSAccelerationStructure *accel) {
         // Kick off ray intersection work
     }];

Streaming Geometry Updates: It is generally safe to change buffer properties such as the vertex buffer after intersection tests have been encoded into a command buffer, but the contents of those buffers cannot be safely changed by the CPU until the command buffer has finished executing on the GPU. It is also not safe to rebuild the acceleration structure until the command buffer has completed.

If the CPU needs to stream geometry updates to the GPU, ensure the vertex and other buffers are double or triple buffered.

     #define MAX_ASYNC_OPERATIONS 3

     // Initialization:

     // Create a semaphore with the maximum number of asynchronous operations in flight
     dispatch_semaphore_t asyncOperationSemaphore = dispatch_semaphore_create(MAX_ASYNC_OPERATIONS);

     // Create an acceleration structure for each vertex buffer range
     NSMutableArray *accelerationStructures = [NSMutableArray array];

     NSUInteger vertexBufferLength = sizeof(float3) * vertexCount * MAX_ASYNC_OPERATIONS;
     id <MTLBuffer> vertexBuffer = [device newBufferWithLength:vertexBufferLength
                                                       options:MTLResourceStorageModeManaged];

     for (NSUInteger i = 0; i < MAX_ASYNC_OPERATIONS; i++) {
         MPSTriangleAccelerationStructure *accel = nil;
         accel = [[MPSTriangleAccelerationStructure alloc] initWithDevice:device];

         // Configure acceleration structure
         accel.vertexBuffer = vertexBuffer;
         accel.vertexBufferOffset = i * sizeof(float3) * vertexCount;

         [accelerationStructures addObject:accel];
     }

     NSUInteger asyncOperationIndex = 0;

     // Encode intersection testing:

     // Wait until there is a free acceleration structure
     dispatch_semaphore_wait(asyncOperationSemaphore, DISPATCH_TIME_FOREVER);

     MPSTriangleAccelerationStructure *accel = accelerationStructures[asyncOperationIndex];
     asyncOperationIndex = (asyncOperationIndex + 1) % MAX_ASYNC_OPERATIONS;

     float3 *vertices = (float3 *)((uint8_t *)vertexBuffer.contents + accel.vertexBufferOffset);
     // Update vertices
     MPSDidModifyRange(vertexBuffer, NSMakeRange(accel.vertexBufferOffset, sizeof(float3) * vertexCount));

     // Rebuild the acceleration structure
     [accel rebuild];

     // Encode actual intersection work
     [raytracer encodeIntersectionToCommandBuffer:commandBuffer
                                 intersectionType:MPSIntersectionTypeNearest
                                        rayBuffer:rayBuffer
                                  rayBufferOffset:rayBufferOffset
                               intersectionBuffer:intersectionBuffer
                         intersectionBufferOffset:intersectionBufferOffset
                                         rayCount:rayCount
                            accelerationStructure:accel];

     // Register a completion handler to run when the GPU finishes executing
     [commandBuffer addCompletedHandler:^(id <MTLCommandBuffer> commandBuffer) {
         Intersection *intersections = (Intersection *)((uint8_t *)intersectionBuffer.contents +
             intersectionBufferOffset);

         // Process intersections

         // Signal that the acceleration structure is now available for reuse
         dispatch_semaphore_signal(asyncOperationSemaphore);
     }];

     // Commit the command buffer to allow the GPU to start executing
     [commandBuffer commit];

Refitting acceleration structures: If geometry has only moved slightly and not added or removed from the scene, it can be much faster to refit the existing topology of an acceleration structure to the new geometry than to rebuild the acceleration structure from scratch. Refitting can also be pipelined with other GPU work such as intersection testing. If the geometry is transformed entirely on the GPU, it is not necessary to use double or triple buffering. For example:

     id <MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];

     id <MTLComputeCommandEncoder> encoder = [commandBuffer computeCommandEncoder];

     [encoder setBuffer:untransformedVertexBuffer offset:0 atIndex:0];

     [encoder setBuffer:accelerationStructure.vertexBuffer
                 offset:accelerationStructure.vertexBufferOffset
                atIndex:1];

     [encoder setBuffer:transformationMatrices offset:0 atIndex:2];

     [encoder setComputePipelineState:transformVerticesPipeline];

     [encoder dispatchThreads:MTLSizeMake(accelerationStructure.triangleCount * 3, 1, 1)
        threadsPerThreadgroup:MTLSizeMake(64, 1, 1)];

     [encoder endEncoding];

     [accelerationStructure encodeRefitToCommandBuffer:commandBuffer];

     [commandBuffer commit];

Serializing Acceleration Structures: Instead of rebuilding acceleration structures from scratch they can be built offline, serialized, and reloaded at runtime using the NSSecureCoding protocol:

     // Build time:
     NSError *error = nil;
     NSData *data = [NSKeyedArchiver archivedDataWithRootObject:accel
                                          requiringSecureCoding:YES
                                                          error:&error];
         
     if (!data)
         NSLog(@"Error archiving MPSAccelerationStructure: %@",
             error.localizedDescription);

     // Runtime:
     MPSTriangleAccelerationStructure *accel;
     accel = [NSKeyedUnarchiver unarchivedObjectOfClass:[MPSTriangleAccelerationStructure class]
                                               fromData:data
                                                  error:&error];

     if (!accel)
         NSLog(@"Error unarchiving MPSAccelerationStructure: %@",
             error.localizedDescription);

Copying Acceleration Structures: Acceleration structures can be copied using the NSCopying protocol, even to a different Metal device. This can be used for multi-GPU raytracing. Buffer properties are not copied to the new acceleration structure. These buffers must instead be copied to the new Metal device and assigned to the new acceleration structure. For example:

     MPSTriangleAccelerationStructure *copy = [accelerationStructure copyWithZone:nil
                                                                           device:newDevice];

     copy.vertexBuffer = [self copyBuffer:accelerationStructure.vertexBuffer
                               withDevice:newDevice];

Performance Guidelines:

  • Provide accurate acceleration structure hints: if an acceleration structure does not require support for refitting, a higher quality construction algorithm can be used. However, if an acceleration structure must be rebuilt frequently, a lower quality but higher performance construction algorithm can be used.

  • Consider refitting existing acceleration structures rather than rebuilding them from scratch. This is typically much faster and can result in a reasonably high quality tree if the geometry has not been modified dramatically. Refitting can also be pipelined with other GPU work. If objects have been added to or removed from the scene, it is typically necessary to rebuild the acceleration structure rather than refit it.

  • Rebuild acceleration structures asynchronously when possible to avoid blocking the main thread. Consider presenting a UI indicating that work is happening in the background while allowing the user to consider interacting with your application.

  • If you need to mix intersection testing with acceleration structure builds (e.g. if the user is interactively editing the scene while rendering or if objects are moving significantly) consider allocating two independent acceleration structures that refer to two copies of the scene data. Then, asynchronously rebuild one acceleration structure while the other one is used for rendering. Once the rebuild has completed, swap the acceleration structures. The intermediate frames could be filled by refitting the rendering acceleration structure until the rebuilt acceleration structure is ready.

  • When running in Xcode, disable โ€œEnable Backtrace Recordingโ€ in your scheme settings. Enabling this setting can significantly increase acceleration structure build time.

  • Consider using quadrilaterals instead of triangles to represent your geometry. The cost of intersecting a quadrilateral is typically less than the cost of intersecting two triangles, so quadrilaterals can improve performance. Quadrilaterals also typically require 30-40% less memory than triangles including vertex data and internal buffers allocated by the acceleration structure. Whether quadrilaterals improve or hurt performance can depend on the geometry and ray distribution, so you should choose whichever performs better for your application.

Thread Safety: MPSAccelerationStructures are generally not thread safe. Changing properties and rebuilding acceleration structures from multiple threads result in undefined behavior. However, it is safe to encode intersection tests with a single acceleration structure from multiple threads as long as each thread uses its own MPSRayIntersector.

See also Appleโ€™s documentation

Implementationsยง

Sourceยง

impl MPSAccelerationStructure

Source

pub unsafe fn group(&self) -> Retained<MPSAccelerationStructureGroup>

๐Ÿ‘ŽDeprecated
Available on crate features MPSRayIntersector and MPSAccelerationStructureGroup only.

The group this acceleration structure was created with

Source

pub unsafe fn status(&self) -> MPSAccelerationStructureStatus

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.

Status indicating whether the acceleration structure has finished building

Source

pub unsafe fn usage(&self) -> MPSAccelerationStructureUsage

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.

Acceleration structure usage options. Changes to this property require rebuilding the acceleration structure. Defaults to MPSAccelerationStructureUsageNone.

Source

pub unsafe fn setUsage(&self, usage: MPSAccelerationStructureUsage)

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.

Setter for usage.

Source

pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.
Source

pub unsafe fn initWithDevice( this: Allocated<Self>, device: &ProtocolObject<dyn MTLDevice>, ) -> Retained<Self>

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.

Initialize the acceleration structure with a Metal device

Source

pub unsafe fn initWithCoder_device( this: Allocated<Self>, a_decoder: &NSCoder, device: &ProtocolObject<dyn MTLDevice>, ) -> Option<Retained<Self>>

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.

Initialize the acceleration structure with an NSCoder and a Metal device. Buffer properties such as the vertex buffer, instance buffer, etc. are set to nil. Encode and decode these buffers along with the acceleration structure instead.

ยงSafety

a_decoder possibly has further requirements.

Source

pub unsafe fn initWithGroup( this: Allocated<Self>, group: &MPSAccelerationStructureGroup, ) -> Retained<Self>

๐Ÿ‘ŽDeprecated
Available on crate features MPSRayIntersector and MPSAccelerationStructureGroup only.

Initialize the acceleration structure with an acceleration structure group, if the acceleration structure will be used in an instance hierarchy.

The Metal device is determined from the acceleration structure group. All acceleration structures in the instance hierarchy must share the same group.

Source

pub unsafe fn initWithCoder_group( this: Allocated<Self>, a_decoder: &NSCoder, group: &MPSAccelerationStructureGroup, ) -> Option<Retained<Self>>

๐Ÿ‘ŽDeprecated
Available on crate features MPSRayIntersector and MPSAccelerationStructureGroup only.

Initialize the acceleration structure with an NSCoder and an acceleration structure group, if the acceleration structure will be used in an instance hierarchy. All acceleration structures in the instance hierarchy must share the same group. Buffer properties such as the vertex buffer, instance buffer, etc. are set to nil. Encode and decode these buffers along with the acceleration structure instead.

ยงSafety

a_decoder possibly has further requirements.

Source

pub unsafe fn rebuild(&self)

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.

Rebuild the acceleration structure

This method must be called before any intersection tests can be scheduled with this acceleration structure. Before calling this method, fill out the properties of the acceleration structure such as vertex buffer, instance buffer, etc. The acceleration structure should be rebuilt when its contents (e.g. vertices in a triangle acceleration structure) have been modified significantly and must be rebuilt when properties such as triangle count, vertex stride, etc. have changed. When the contents of the acceleration structure have only been modified slightly, it may be cheaper to refit the acceleration structure instead.

This method blocks until the acceleration structure has been rebuilt. Until the rebuild has completed, the acceleration structure cannot be copied, encoded with NSSecureCoding, rebuilt, or refit. Before this method can be called, any pending GPU writes to the vertex buffer, index buffer, etc. must be completed (and, for managed buffers, synchronized). Any prior intersection tests must also be completed before the acceleration structure can be rebuilt.

Source

pub unsafe fn rebuildWithCompletionHandler( &self, completion_handler: MPSAccelerationStructureCompletionHandler, )

๐Ÿ‘ŽDeprecated
Available on crate features MPSRayIntersector and block2 only.

Rebuild the acceleration structure asynchronously

This method must be called before any intersection tests can be scheduled with this acceleration structure. Before calling this method, fill out the properties of the acceleration structure such as vertex buffer, instance buffer, etc. The acceleration structure should be rebuilt when its contents (e.g. vertices in a triangle acceleration structure) have been modified significantly and must be rebuilt when properties such as triangle count, vertex stride, etc. have changed. When the contents of the acceleration structure have only been modified slightly, it may be cheaper to refit the acceleration structure instead.

Until the rebuild has completed, the acceleration structure cannot be copied, encoded with NSSecureCoding, rebuilt, or refit. Before this method can be called, any pending GPU writes to the vertex buffer, index buffer, etc. must be completed (and, for managed buffers, synchronized). Any prior intersection tests must also be completed before the acceleration structure can be rebuilt.

ยงSafety

completion_handler must be a valid pointer.

Source

pub unsafe fn encodeRefitToCommandBuffer( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, )

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.

Refit the existing acceleration structure to new data

This method is used to refit the acceleration structure to new vertex data, index data, instance data, etc. while preserving the existing acceleration structure topology. This is typically much faster than a full rebuild of the acceleration structure. Refitting can also be pipelined with other GPU work such as ray intersection.

Until the command buffer has completed, the acceleration structure cannot be copied, encoded with NSSecureCoding, or rebuilt. Changes to properties such as the triangle count or instance count might not be reflected. These changes require that the acceleration structure be rebuilt instead. The acceleration structure must be rebuilt at least once before this method can be called.

Source

pub unsafe fn copyWithZone_device( &self, zone: *mut NSZone, device: Option<&ProtocolObject<dyn MTLDevice>>, ) -> Retained<Self>

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.

Create a a copy of this acceleration structure

The acceleration structure may be copied to a different Metal device. Buffer properties of the acceleration structure such as the vertex buffer, instance, buffer, etc. are set to nil. Copy these buffers to the new Metal device and assign them to the new acceleration structure instead. Do not copy the acceleration structure until any prior refit or rebuild operations have completed.

Parameter zone: This parameter is ignored. Memory zones are no longer used by Objective-C.

Parameter device: New Metal device

ยงSafety

zone must be a valid pointer or null.

Source

pub unsafe fn copyWithZone_group( &self, zone: *mut NSZone, group: &MPSAccelerationStructureGroup, ) -> Retained<Self>

๐Ÿ‘ŽDeprecated
Available on crate features MPSRayIntersector and MPSAccelerationStructureGroup only.

Create a a copy of this acceleration structure

The acceleration structure may be copied with a different acceleration structure group. Buffer properties of the acceleration structure such as the vertex buffer, instance buffer, etc. are set to nil. Copy these buffers with the new Metal device and assign them to the new acceleration structure instead. Do not copy the acceleration structure until any prior refit or rebuild operations have completed.

Parameter zone: This parameter is ignored. Memory zones are no longer used by Objective-C.

Parameter group: New acceleration structure group

ยงSafety

zone must be a valid pointer or null.

Source

pub unsafe fn encodeWithCoder(&self, coder: &NSCoder)

๐Ÿ‘ŽDeprecated
Available on crate feature MPSRayIntersector only.

Encode the acceleration structure with an NSCoder

Buffer properties such as the vertex buffer, index buffer, etc. are not be encoded. Encode and decode these buffers along with the acceleration structure instead. Do not encode the acceleration structure until any prior refit or rebuild operations have completed.

Parameter coder: An archiver object

ยงSafety

coder possibly has further requirements.

Sourceยง

impl MPSAccelerationStructure

Methods declared on superclass MPSKernel.

Source

pub unsafe fn initWithCoder( this: Allocated<Self>, a_decoder: &NSCoder, ) -> Option<Retained<Self>>

Available on crate feature MPSRayIntersector only.

Called by NSCoder to decode MPSKernels

This isnโ€™t the right interface to decode a MPSKernel, but it is the one that NSCoder uses. To enable your NSCoder (e.g. NSKeyedUnarchiver) to set which device to use extend the object to adopt the MPSDeviceProvider protocol. Otherwise, the Metal system default device will be used.

ยงSafety

a_decoder possibly has further requirements.

Sourceยง

impl MPSAccelerationStructure

Methods declared on superclass NSObject.

Source

pub unsafe fn new() -> Retained<Self>

Available on crate feature MPSRayIntersector only.

Methods from Deref<Target = MPSKernel>ยง

Source

pub unsafe fn options(&self) -> MPSKernelOptions

Available on crate feature MPSCoreTypes only.

The set of options used to run the kernel. subsubsection_options

Source

pub unsafe fn setOptions(&self, options: MPSKernelOptions)

Available on crate feature MPSCoreTypes only.

Setter for options.

Source

pub unsafe fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>

The device on which the kernel will be used

Source

pub unsafe fn label(&self) -> Option<Retained<NSString>>

A string to help identify this object.

Source

pub unsafe fn setLabel(&self, label: Option<&NSString>)

Setter for label.

This is copied when set.

Source

pub unsafe fn copyWithZone_device( &self, zone: *mut NSZone, device: Option<&ProtocolObject<dyn MTLDevice>>, ) -> Retained<Self>

Make a copy of this MPSKernel for a new device

-copyWithZone: will call this API to make a copy of the MPSKernel on the same device. This interface may also be called directly to make a copy of the MPSKernel on a new device. Typically, the same MPSKernels should not be used to encode kernels on multiple command buffers from multiple threads. Many MPSKernels have mutable properties that might be changed by the other thread while this one is trying to encode. If you need to use a MPSKernel from multiple threads make a copy of it for each additional thread using -copyWithZone: or -copyWithZone:device:

Parameter zone: The NSZone in which to allocate the object

Parameter device: The device for the new MPSKernel. If nil, then use self.device.

Returns: a pointer to a copy of this MPSKernel. This will fail, returning nil if the device is not supported. Devices must be MTLFeatureSet_iOS_GPUFamily2_v1 or later.

ยงSafety

zone must be a valid pointer or null.

Methods from Deref<Target = NSObject>ยง

Source

pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !

Handle messages the object doesnโ€™t recognize.

See Appleโ€™s documentation for details.

Methods from Deref<Target = AnyObject>ยง

Source

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());
Source

pub unsafe fn get_ivar<T>(&self, name: &str) -> &T
where T: Encode,

๐Ÿ‘ŽDeprecated: this is difficult to use correctly, use 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.

Source

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 MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl AsRef<MPSAccelerationStructure> for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl AsRef<MPSAccelerationStructure> for MPSInstanceAccelerationStructure

Available on crate features MPSInstanceAccelerationStructure and MPSRayIntersector only.
Sourceยง

fn as_ref(&self) -> &MPSAccelerationStructure

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl AsRef<MPSAccelerationStructure> for MPSPolygonAccelerationStructure

Available on crate features MPSPolygonAccelerationStructure and MPSRayIntersector only.
Sourceยง

fn as_ref(&self) -> &MPSAccelerationStructure

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl AsRef<MPSAccelerationStructure> for MPSQuadrilateralAccelerationStructure

Available on crate features MPSQuadrilateralAccelerationStructure and MPSRayIntersector and MPSPolygonAccelerationStructure only.
Sourceยง

fn as_ref(&self) -> &MPSAccelerationStructure

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl AsRef<MPSAccelerationStructure> for MPSTriangleAccelerationStructure

Available on crate features MPSTriangleAccelerationStructure and MPSRayIntersector and MPSPolygonAccelerationStructure only.
Sourceยง

fn as_ref(&self) -> &MPSAccelerationStructure

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl AsRef<MPSKernel> for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn as_ref(&self) -> &MPSKernel

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl AsRef<NSObject> for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn as_ref(&self) -> &NSObject

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl Borrow<AnyObject> for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Sourceยง

impl Borrow<MPSAccelerationStructure> for MPSInstanceAccelerationStructure

Available on crate features MPSInstanceAccelerationStructure and MPSRayIntersector only.
Sourceยง

fn borrow(&self) -> &MPSAccelerationStructure

Immutably borrows from an owned value. Read more
Sourceยง

impl Borrow<MPSAccelerationStructure> for MPSPolygonAccelerationStructure

Available on crate features MPSPolygonAccelerationStructure and MPSRayIntersector only.
Sourceยง

fn borrow(&self) -> &MPSAccelerationStructure

Immutably borrows from an owned value. Read more
Sourceยง

impl Borrow<MPSAccelerationStructure> for MPSQuadrilateralAccelerationStructure

Available on crate features MPSQuadrilateralAccelerationStructure and MPSRayIntersector and MPSPolygonAccelerationStructure only.
Sourceยง

fn borrow(&self) -> &MPSAccelerationStructure

Immutably borrows from an owned value. Read more
Sourceยง

impl Borrow<MPSAccelerationStructure> for MPSTriangleAccelerationStructure

Available on crate features MPSTriangleAccelerationStructure and MPSRayIntersector and MPSPolygonAccelerationStructure only.
Sourceยง

fn borrow(&self) -> &MPSAccelerationStructure

Immutably borrows from an owned value. Read more
Sourceยง

impl Borrow<MPSKernel> for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn borrow(&self) -> &MPSKernel

Immutably borrows from an owned value. Read more
Sourceยง

impl Borrow<NSObject> for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn borrow(&self) -> &NSObject

Immutably borrows from an owned value. Read more
Sourceยง

impl ClassType for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

const NAME: &'static str = "MPSAccelerationStructure"

The name of the Objective-C class that this type represents. Read more
Sourceยง

type Super = MPSKernel

The superclass of this class. Read more
Sourceยง

type ThreadKind = <<MPSAccelerationStructure as ClassType>::Super as ClassType>::ThreadKind

Whether the type can be used from any thread, or from only the main thread. Read more
Sourceยง

fn class() -> &'static AnyClass

Get a reference to the Objective-C class that this type represents. Read more
Sourceยง

fn as_super(&self) -> &Self::Super

Get an immutable reference to the superclass.
Sourceยง

impl CopyingHelper for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

type Result = MPSAccelerationStructure

The immutable counterpart of the type, or Self if the type has no immutable counterpart. Read more
Sourceยง

impl Debug for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Deref for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

type Target = MPSKernel

The resulting type after dereferencing.
Sourceยง

fn deref(&self) -> &Self::Target

Dereferences the value.
Sourceยง

impl Hash for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 ยท Sourceยง

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Sourceยง

impl Message for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Sourceยง

impl NSCoding for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

unsafe fn encodeWithCoder(&self, coder: &NSCoder)
where Self: Sized + Message,

Safety Read more
Sourceยง

unsafe fn initWithCoder( this: Allocated<Self>, coder: &NSCoder, ) -> Option<Retained<Self>>
where Self: Sized + Message,

Safety Read more
Sourceยง

impl NSCopying for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn copy(&self) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance thatโ€™s a copy of the receiver. Read more
Sourceยง

unsafe fn copyWithZone(&self, zone: *mut NSZone) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance thatโ€™s a copy of the receiver. Read more
Sourceยง

impl NSObjectProtocol for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn isEqual(&self, other: Option<&AnyObject>) -> bool
where Self: Sized + Message,

Check whether the object is equal to an arbitrary other object. Read more
Sourceยง

fn hash(&self) -> usize
where Self: Sized + Message,

An integer that can be used as a table address in a hash table structure. Read more
Sourceยง

fn isKindOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of the class, or one of its subclasses. Read more
Sourceยง

fn is_kind_of<T>(&self) -> bool
where T: ClassType, Self: Sized + Message,

๐Ÿ‘ŽDeprecated: use isKindOfClass directly, or cast your objects with AnyObject::downcast_ref
Check if the object is an instance of the class type, or one of its subclasses. Read more
Sourceยง

fn isMemberOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of a specific class, without checking subclasses. Read more
Sourceยง

fn respondsToSelector(&self, aSelector: Sel) -> bool
where Self: Sized + Message,

Check whether the object implements or inherits a method with the given selector. Read more
Sourceยง

fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
where Self: Sized + Message,

Check whether the object conforms to a given protocol. Read more
Sourceยง

fn description(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object. Read more
Sourceยง

fn debugDescription(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object to use when debugging. Read more
Sourceยง

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

Check whether the receiver is a subclass of the NSProxy root class instead of the usual NSObject. Read more
Sourceยง

fn retainCount(&self) -> usize
where Self: Sized + Message,

The reference count of the object. Read more
Sourceยง

impl NSSecureCoding for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

impl PartialEq for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Sourceยง

impl RefEncode for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

const ENCODING_REF: Encoding = <MPSKernel as ::objc2::RefEncode>::ENCODING_REF

The Objective-C type-encoding for a reference of this type. Read more
Sourceยง

impl DowncastTarget for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.
Sourceยง

impl Eq for MPSAccelerationStructure

Available on crate feature MPSRayIntersector only.

Auto Trait Implementationsยง

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<'a, T> AnyThread for T
where T: ClassType<ThreadKind = dyn AnyThread + 'a> + ?Sized,

Sourceยง

fn alloc() -> Allocated<Self>
where Self: Sized + ClassType,

Allocate a new instance of the class. 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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Sourceยง

type Target = T

๐Ÿ”ฌThis is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Sourceยง

impl<T> AutoreleaseSafe for T
where T: ?Sized,