MPSRayIntersector

Struct MPSRayIntersector 

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

Performs intersection tests between rays and the geometry in an MPSAccelerationStructure

An MPSRayIntersector is used to schedule intersection tests between rays and geometry into an MTLCommandBuffer. First, create a raytracer with a Metal device. Then, configure the properties of the raytracer:

     id <MTLDevice> device = MTLCreateSystemDefaultDevice();
     id <MTLCommandQueue> commandQueue = [device newCommandQueue];
   
     MPSRayIntersector *raytracer = [[MPSRayIntersector alloc] initWithDevice:device];

     // Configure raytracer properties

Before scheduling intersection tests, an MPSAccelerationStructure must be created. The acceleration structure is built over geometry and is used to accelerate intersection testing. For example, to create a triangle acceleration structure, allocate an MPSTriangleAccelerationStructure object. Then, configure the properties of the acceleration structure. For example, triangle acceleration structures require a vertex buffer and a triangle count:

     MPSTriangleAccelerationStructure *accelerationStructure =
         [[MPSTriangleAccelerationStructure alloc] initWithDevice:device];
   
     accelerationStructure.vertexBuffer = vertexBuffer;
     accelerationStructure.triangleCount = triangleCount;

Acceleration structures must be built at least once before they are used for intersection testing, and must be rebuilt when the geometry changes. Rebuilding an acceleration structure is a time consuming operation, so an asynchronous version of this method is also available.

     [accelerationStructure rebuild];

The raytracer is then used to schedule intersection tests into an MTLCommandBuffer. Rays are provided in batches through a Metal buffer, and intersection results are returned through another Metal buffer in the same order, one intersection per ray.

There are several choices of ray data type controlled by the rayDataType property. The default ray data type is MPSRayOriginDirection, which includes just the ray origin direction. The other data types add support for minimum and maximum intersection distances and ray masks. These data types are available in the Metal Shading Language by including the MetalPerformanceShaders/MetalPerformanceShaders.h header. Additional application specific per-ray data can also be appended to the end of the ray data type using the rayStride property. This data will be ignored by the intersector.

If the rays were generated on the CPU:

     typedef MPSRayOriginDirection Ray;

     // Create a buffer to hold the rays
     id <MTLBuffer> rayBuffer = [device newBufferWithLength:sizeof(Ray) * rayCount options:0];

     // Copy the rays into the ray buffer
     memcpy(rayBuffer.contents, rays, sizeof(Ray) * rayCount);
   
     // Create a buffer to hold the intersections
     id <MTLBuffer> intersectionBuffer = [device newBufferWithLength:sizeof(Intersection) * rayCount
                                                             options:0];

It can be useful to prevent certain rays from participating in intersection testing. For example: rays which have bounced out of the scene in previous intersection tests. It may be more efficient to do this by compacting the ray buffer so that threads with invalid rays are not left idle during intersection testing. However, it can be more convenient to disable the ray in place. This can be done by setting most fields to invalid values. For example, setting the maximum distance to a negative value, setting the mask to zero, setting the direction to the zero vector, etc.

Finally, the intersection testing is encoded into an MTLCommandBuffer. There are two intersection types. The โ€œnearestโ€ intersection type returns the closest intersection along each ray. The โ€œanyโ€ intersection type returns immediately when the first intersection is found. The โ€œanyโ€ intersection type is useful for determining whether a point is visible from another point for, e.g., shadow rays or ambient occlusion rays and is typically much faster than the โ€œnearestโ€ intersection type.

     id <MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];
   
     [raytracer encodeIntersectionToCommandBuffer:commandBuffer
                                 intersectionType:MPSIntersectionTypeNearest
                                        rayBuffer:rayBuffer
                                  rayBufferOffset:0
                               intersectionBuffer:intersectionBuffer
                         intersectionBufferOffset:0
                                         rayCount:rayCount
                            accelerationStructure:accelerationStructure];

     [commandBuffer commit];

The intersection results are not available until the command buffer has finished executing on the GPU. It is not safe for the CPU to write or read the contents of the ray buffer, intersection buffer, vertex buffer, etc. until the command buffer has finished executing. Use the waitUntilCompleted or addCompletedHandler methods of the MTLCommandBuffer to block the CPU until the GPU has finished executing. Then retrieve the intersection results from the intersection buffer:

     typedef MPSIntersectionDistancePrimitiveIndexCoordinates Intersection;
     [commandBuffer waitUntilCompleted];

     Intersection *intersections = (Intersection *)intersectionBuffer.contents;

There are also several choices of intersection data type controlled by the intersectionDataType property. The default intersection data type is MPSIntersectionDistancePrimitiveIndexCoordinates, which includes the intersection distance, primitive index, and barycentric coordinates. The other data types remove the primitive index or barycentric coordinates, which can be used to reduce the memory and memory bandwidth usage of the intersection buffer. These data types are available in the Metal Shading Language by including the MetalPerformanceShaders/MetalPerformanceShaders.h header.

The intersection distance field is positive when an intersection has been found and negative when there is no intersection. When using the โ€œnearestโ€ intersection type, the intersection point is the ray origin plus the ray direction multiplied by the intersection distance. The other fields are not valid if there is no intersection. Only the intersection distance field is valid for the โ€œanyโ€ intersection type, and the distance is either a negative or positive value to indicate an intersection or miss. It does not necessarily contain the actual intersection distance when using the โ€œanyโ€ intersection type.

Asynchronous Raytracing: Copying rays and intersections to and from the CPU is expensive. Furthermore, generating rays and consuming intersections on the CPU causes the CPU and GPU to block each other. If the CPU must generate rays and consume intersections, it is better to add an asynchronous completion handler to the MTLCommandBuffer. The CPU can then proceed to do other useful work and will be notified when the GPU has finished executing. Use double or triple buffered ray and intersection buffers to avoid race conditions such as the CPU overwriting data the GPU may be reading. Then the CPU can safely write to one range of the buffer while the GPU reads from another range of the buffer. Once the GPU is done executing, the CPU and GPU can advance to the next range of the buffer. This method can be implemented using a completion handler and a semaphore:

     #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 a ray and intersection buffer large enough for the maximum number of operations
     id <MTLBuffer> rayBuffer =
         [device newBufferWithLength:sizeof(Ray) * rayCount * MAX_ASYNC_OPERATIONS
                             options:0];

     id <MTLBuffer> intersectionBuffer =
         [device newBufferWithLength:sizeof(Intersection) * rayCount * MAX_ASYNC_OPERATIONS
                             options:0];

     NSUInteger asyncOperationIndex = 0;

     // Encode intersection testing:

     // Wait until there is a free buffer range
     dispatch_semaphore_wait(asyncOperationSemaphore, DISPATCH_TIME_FOREVER);

     // Copy rays into ray buffer
     NSUInteger rayBufferOffset = sizeof(Ray) * rayCount * asyncOperationIndex;
     NSUInteger intersectionBufferOffset = sizeof(Intersection) * rayCount * asyncOperationIndex;

     memcpy((uint8_t *)rayBuffer.contents + rayBufferOffset, rays, sizeof(Ray) * rayCount);

     // Advance the async operation index
     asyncOperationIndex = (asyncOperationIndex + 1) % MAX_ASYNC_OPERATIONS;

     // Create a command buffer
     id <MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];

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

     // 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 ray and intersection buffer ranges are now available for reuse
         dispatch_semaphore_signal(asyncOperationSemaphore);
     }];

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

GPU Driven Raytracing: Pipelining CPU and GPU work with asynchronous raytracing is better than allowing the CPU and GPU block each other, but it is even better to produce rays and consume intersections entirely on the GPU. This avoids the need to copy rays and intersections to and from the GPU and avoids any kind of CPU/GPU synchronization. To do this, encode compute kernels before and after intersection testing. By processing rays in parallel, the compute kernels may also be able to generate and consume rays faster than the CPU. The ray generation kernel typically produces rays according to some camera model, and the intersection consumption kernel typically updates the output buffer or texture according to some shading model.

Since the rays and intersections will never leave the GPU, store them in private Metal buffers that are allocated in GPU memory rather than system memory. Because the ray generation, intersection testing, and intersection consumption kernels are pipelined on the GPU, there is no need to double or triple buffer the ray or intersection buffers, which saves memory.

     id <MTLBuffer> rayBuffer =
         [device newBufferWithLength:sizeof(Ray) * rayCount
                             options:MTLResourceStorageModePrivate];
     id <MTLBuffer> intersectionBuffer =
         [device newBufferWithLength:sizeof(Intersection) * rayCount
                             options:MTLResourceStorageModePrivate];

     id <MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];

     // Generate rays
     id <MTLComputeCommandEncoder> encoder = [commandBuffer computeCommandEncoder];

     [encoder setBuffer:rayBuffer offset:0 atIndex:0];
     [encoder setBytes:&uniformData length:sizeof(uniformData) atIndex:1];

     [encoder setComputePipelineState:cameraPipeline];

     [encoder dispatchThreads:MTLSizeMake(rayCount, 1, 1)
        threadsPerThreadgroup:MTLSizeMake(64, 1, 1)];

     [encoder endEncoding];

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

     // Perform shading at intersections and update framebuffer texture
     encoder = [commandBuffer computeCommandEncoder];

     [encoder setBuffer:rayBuffer offset:0 atIndex:0];
     [encoder setBuffer:intersectionBuffer offset:0 atIndex:1];
     [encoder setBytes:&uniformData length:sizeof(uniformData) atIndex:2];

     [encoder setTexture:framebufferTexture atIndex:0];

     [encoder setComputePipelineState:shadingPipeline];

     [encoder dispatchThreads:MTLSizeMake(rayCount, 1, 1)
        threadsPerThreadgroup:MTLSizeMake(64, 1, 1)];

     [encoder endEncoding];

     [commandBuffer commit];

Note that the intersection consumption kernel can in turn produce new rays that can be passed back to the MPSRayIntersector. This technique can be used to implement iterative techniques such as progressive path tracing without leaving the GPU. For example, the shading kernel in the example above could produce both a secondary ray that will be passed back to the raytracer in the next iteration as well as a shadow ray that will be used to sample the direct lighting. A final kernel can consume the shadow ray intersections to accumulate lighting contributions into the framebuffer.

There is an alternative version of the intersection test encoding method that does not accept a literal ray count. The ray count is instead fetched indirectly by the GPU. For example, this can be combined with a parallel reduction on the GPU to compact the ray buffer after each iteration as rays bounce out of the scene or are absorbed. Alternatively, setting the maximum distance of a ray to a negative number indicates that the ray has become inactive and causes the raytracer to ignore the ray.

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

Multi-GPU Raytracing: to implement multi-GPU raytracing, create the MPSRayIntersector and MPSAccelerationStructure objects first with one Metal device and copy them to the other Metal device(s). The raytracing process can then proceed independently on each GPU. For example, divide the output image into tiles or slices that are rendered independently. Then composite finished tiles or slices back together on one GPU and present the output image to the screen. The workload should be distributed across GPUs according to their performance to avoid a more powerful GPU idly waiting for a less powerful GPU to finish.

Acceleration Structure Serialization: MPSAccelerationStructure objects can be serialized and deserialized using the NSSecureCoding protocol. This can be used to build acceleration structures offline and reload them at runtime rather than building them from scratch.

Performance Guidelines:

  • For vertex buffers, ray buffers, intersection buffers, etc., use private or managed buffers rather than shared buffers when possible on discrete memory GPU architectures as they are much faster than fetching data over the PCIe bus. If the CPU only writes once to a ray buffer once and reads once from the intersection buffer, then a shared buffer may be acceptable and avoids extra copies to and from the GPU. However, it is generally preferable to generate and consume rays and intersections on the GPU instead, in which case a private buffer should be used. Vertex data is typically static and reused many times so it should be stored in private or managed buffers.

  • If the CPU must generate and consume rays and intersections, use double or triple buffering as described above. This avoids the CPU and GPU mutually blocking each other.

  • In general, disable any unused features such as ray masks, backface culling, etc. Enabling extra features increases the number of instructions and register usage of the ray intersection kernel(s), reducing intersection performance. For example, it may be more efficient to compute barycentric coordinates in your intersection consumption kernel rather getting them from the raytracer. Use of an index buffer may also reduce performance, so consider disabling the index buffer if there is enough memory available.

  • Try to submit rays in large batches. This amortizes the costs involved in dispatching work to the GPU and also allows the GPU to perform more effective latency hiding. Use the recommendedMinimumRayBatchSizeForRayCount method to get an estimate of the minimum recommended ray batch size. For this reason, small images or sample counts may not perform as well as large images or sample counts. Note, however, that submitting rays in very large batches can reduce the responsiveness of the system because the GPU will be busy for long periods. Experiment to find a balance between raytracing throughput and system responsiveness.

  • When possible, organize rays within a batch for spatial locality. Rays that originate at nearby points or are oriented in similar directions tend to access the same locations in memory and can therefore make more effective use of the GPUโ€™s caches. For example, the camera rays associated with nearby pixels in the output image will likely originate at the same point and travel in very similar directions. Therefore, divide the output image into small tiles (e.g., 8x8). Rather than laying out all of the rays in the ray buffer in scanline order, first lay out the ray in scanline order within each tile, then lay out the tiles in scanline order or according to some space filling curve.

  • If CPU encode time is an issue, disable Metal API validation and enable MPSKernelOptionsSkipAPIValidation.

  • Choose the minimal ray and intersection data types for your use case. Loading and storing extra values such as ray masks or primitive indices can reduce raytracing performance, so use a simpler data type if they are not needed. For example, camera rays typically have no need for a maximum distance field, while shadow rays do.

  • Use MPSIntersectionTestTypeAny when possible: this is typically much faster than MPSIntersectionTestTypeNearest and can be used when you only need to check for binary visibility between two points such as shadow and ambient occlusion rays. Combine this with MPSRayDataTypeDistance to minimize memory bandwidth usage.

  • Try to keep the geometry, textures, ray buffers, etc. within the Metal deviceโ€™s recommended working set size. Paging data into GPU memory can significantly reduce raytracing performance.

  • Changes to MPSRayIntersector properties can trigger internal pipeline compilations when intersection tests are next encoded. If you need to avoid hitches due to pipeline compilation, encode a small ray intersection with each raytracer configuration you will use at encode-time. This creates and caches the corresponding pipelines.

  • Disable rays which should not participate in intersection testing. This can be done either by compacting the ray buffer such that it only contains valid rays, or by setting fields of the ray struct to invalid values. For example, setting the maximum distance to a negative value, setting the mask to zero, setting the direction to the zero vector, etc. In particular, rays should NOT be disabled using schemes such as moving their origin outside the scene. These rays will still partially traverse the acceleration structure, potentially evicting data from the cache which could have been used by valid rays. Note that it is preferable to provide only valid rays so that threads are not left idle if their rays are found to be invalid, but it can be convenient to disable rays in place in the ray buffer.

See MPSAccelerationStructure and MPSInstanceAccelerationStructure for more performance guidelines.

Thread Safety: MPSRayIntersectors are generally not thread safe: changing properties and encoding intersection tests from multiple threads result in undefined behavior. Instead, multiple threads should copy or create their own MPSRayIntersectors.

See also Appleโ€™s documentation

Implementationsยง

Sourceยง

impl MPSRayIntersector

Source

pub unsafe fn cullMode(&self) -> MTLCullMode

๐Ÿ‘ŽDeprecated

Whether to ignore intersections between rays and back-facing or front-facing triangles or quadrilaterals. Defaults to MTLCullModeNone.

A triangle or quadrilateral is back-facing if its normal points in the same direction as a ray and front-facing if its normal points in the opposite direction as a ray. If the cull mode is set to MTLCullModeBack, then back-facing triangles and quadrilaterals will be ignored. If the cull mode is set to MTLCullModeFront, then front-facing triangles and quadrilaterals will be ignored. Otherwise, if the cull mode is set to MTLCullModeNone, no triangles or quadrilaterals will be ignored. The front and back faces can be swapped using the frontFacingWinding property.

Backface culling is necessary for some scenes but can reduce raytracing performance.

Source

pub unsafe fn setCullMode(&self, cull_mode: MTLCullMode)

๐Ÿ‘ŽDeprecated

Setter for cullMode.

Source

pub unsafe fn frontFacingWinding(&self) -> MTLWinding

๐Ÿ‘ŽDeprecated

Winding order used to determine which direction a triangle or quadrilateralโ€™s normal points when back face or front face culling is enabled. Defaults to MTLWindingClockwise.

If the front face winding is set to MTLWindingClockwise, the triangle or quadrilateral normal is considered to point towards the direction where the vertices are in clockwise order when viewed from that direction. Otherwise, if the front facing winding is set to MTLWindingCounterClockwise, the triangle or quadrilateral normal is considered to point in the opposite direction.

Source

pub unsafe fn setFrontFacingWinding(&self, front_facing_winding: MTLWinding)

๐Ÿ‘ŽDeprecated

Setter for frontFacingWinding.

Source

pub unsafe fn triangleIntersectionTestType( &self, ) -> MPSTriangleIntersectionTestType

๐Ÿ‘ŽDeprecated

Ray/triangle intersection test type. Defaults to MPSTriangleIntersectionTestTypeDefault. Quads are broken into two triangles for intersection testing, so this property also applies to quadrilateral intersections.

Source

pub unsafe fn setTriangleIntersectionTestType( &self, triangle_intersection_test_type: MPSTriangleIntersectionTestType, )

๐Ÿ‘ŽDeprecated
Source

pub unsafe fn boundingBoxIntersectionTestType( &self, ) -> MPSBoundingBoxIntersectionTestType

๐Ÿ‘ŽDeprecated

Ray/bounding box intersection test type. Defaults to MPSBoundingBoxIntersectionTestTypeDefault.

Source

pub unsafe fn setBoundingBoxIntersectionTestType( &self, bounding_box_intersection_test_type: MPSBoundingBoxIntersectionTestType, )

๐Ÿ‘ŽDeprecated
Source

pub unsafe fn rayMaskOptions(&self) -> MPSRayMaskOptions

๐Ÿ‘ŽDeprecated

Whether to enable primitive and instance masks. Defaults to MPSRayMaskOptionNone.

If MPSRayMaskOptionPrimitive or MPSRayMaskOptionInstance is enabled, each ray and primitive and/or instance is associated with a 32 bit unsigned integer mask. Before checking for intersection between a ray and a primitive or instance, the corresponding masks are compared using the ray mask operator defined by the rayMaskOperator property. If the result is zero, the intersection is skipped.

This can be used to make certain primitives or instances invisible to certain rays. For example, objects can be grouped into layers and their visibility can be toggled by modifying the ray masks rather than removing the objects from the scene and rebuilding the acceleration structure. Alternatively, certain objects can be prevented from casting shadows by making them invisible to shadow rays.

Enabling this option may reduce raytracing performance.

Source

pub unsafe fn setRayMaskOptions(&self, ray_mask_options: MPSRayMaskOptions)

๐Ÿ‘ŽDeprecated

Setter for rayMaskOptions.

Source

pub unsafe fn rayMaskOperator(&self) -> MPSRayMaskOperator

๐Ÿ‘ŽDeprecated

The operator to apply to determine whether to accept an intersection between a ray and a primitive or instance. Defaults to MPSRayMaskOperatorAnd.

Source

pub unsafe fn setRayMaskOperator(&self, ray_mask_operator: MPSRayMaskOperator)

๐Ÿ‘ŽDeprecated

Setter for rayMaskOperator.

Source

pub unsafe fn rayStride(&self) -> NSUInteger

๐Ÿ‘ŽDeprecated

Offset, in bytes, between consecutive rays in the ray buffer. Defaults to 0, indicating that the rays are packed according to their natural aligned size.

This can be used to skip past any additional per-ray data that may be stored alongside the MPSRay struct such as the current radiance along the ray or the source pixel coordinates. Must be aligned to the alignment of the ray data type.

Source

pub unsafe fn setRayStride(&self, ray_stride: NSUInteger)

๐Ÿ‘ŽDeprecated

Setter for rayStride.

Source

pub unsafe fn intersectionStride(&self) -> NSUInteger

๐Ÿ‘ŽDeprecated

Offset, in bytes, between consecutive intersections in the intersection buffer. Defaults to 0, indicating that the intersections are packed according to their natural aligned size.

This can be used to skip past any additional per-intersection that which may be stored alongside the MPSRayIntersection struct such as the surface normal at the point of intersection. Must be aligned to the alignment of the intersection data type.

Source

pub unsafe fn setIntersectionStride(&self, intersection_stride: NSUInteger)

๐Ÿ‘ŽDeprecated

Setter for intersectionStride.

Source

pub unsafe fn rayDataType(&self) -> MPSRayDataType

๐Ÿ‘ŽDeprecated

Ray data type. Defaults to MPSRayDataTypeOriginDirection.

Source

pub unsafe fn setRayDataType(&self, ray_data_type: MPSRayDataType)

๐Ÿ‘ŽDeprecated

Setter for rayDataType.

Source

pub unsafe fn intersectionDataType(&self) -> MPSIntersectionDataType

๐Ÿ‘ŽDeprecated

Intersection data type. Defaults to MPSIntersectionDataTypeDistancePrimitiveIndexCoordinates.

Source

pub unsafe fn setIntersectionDataType( &self, intersection_data_type: MPSIntersectionDataType, )

๐Ÿ‘ŽDeprecated
Source

pub unsafe fn rayIndexDataType(&self) -> MPSDataType

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

Ray index data type. Defaults to MPSDataTypeUInt32. Only MPSDataTypeUInt16 and MPSDataTypeUInt32 are supported.

Source

pub unsafe fn setRayIndexDataType(&self, ray_index_data_type: MPSDataType)

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

Setter for rayIndexDataType.

Source

pub unsafe fn rayMask(&self) -> c_uint

๐Ÿ‘ŽDeprecated

Global ray mask. Defaults to 0xFFFFFFFF. This value will be logically AND-ed with the per-ray mask if the ray data type contains a mask.

Source

pub unsafe fn setRayMask(&self, ray_mask: c_uint)

๐Ÿ‘ŽDeprecated

Setter for rayMask.

Source

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

๐Ÿ‘ŽDeprecated
Source

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

๐Ÿ‘ŽDeprecated

Initialize the raytracer with a Metal device

Source

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

๐Ÿ‘ŽDeprecated

Initialize the raytracer with an NSCoder and a Metal device

ยงSafety

a_decoder possibly has further requirements.

Source

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

๐Ÿ‘ŽDeprecated

Copy the raytracer with a Metal device

Parameter zone: The NSZone in which to allocate the object

Parameter device: The Metal device for the new MPSRayIntersector

Returns: A pointer to a copy of this MPSRayIntersector

ยงSafety

zone must be a valid pointer or null.

Source

pub unsafe fn recommendedMinimumRayBatchSizeForRayCount( &self, ray_count: NSUInteger, ) -> NSUInteger

๐Ÿ‘ŽDeprecated

Get the recommended minimum number of rays to submit for intersection in one batch

In order to keep the system responsive, and to limit the amount of memory allocated to ray and intersection buffers, it may be desirable to divide the rays to be intersected against an acceleration structure into smaller batches. However, submitting too few rays in a batch reduces GPU utilization and performance. This method provides a recommended minimum number of rays to submit in any given batch. For example, for a 1920x1080 image, this method may recommend that the image be divided into 512x512 tiles. The actual recommendation varies per device and total ray count.

Parameter rayCount: The total number of rays to be submitted

Returns: The recommended minimum ray batch size

Source

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

๐Ÿ‘ŽDeprecated
ยงSafety

coder possibly has further requirements.

Source

pub unsafe fn encodeIntersectionToCommandBuffer_intersectionType_rayBuffer_rayBufferOffset_intersectionBuffer_intersectionBufferOffset_rayCount_accelerationStructure( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, intersection_type: MPSIntersectionType, ray_buffer: &ProtocolObject<dyn MTLBuffer>, ray_buffer_offset: NSUInteger, intersection_buffer: &ProtocolObject<dyn MTLBuffer>, intersection_buffer_offset: NSUInteger, ray_count: NSUInteger, acceleration_structure: &MPSAccelerationStructure, )

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

Schedule intersection tests between rays and an acceleration structure

Parameter commandBuffer: Command buffer to schedule intersection testing in

Parameter intersectionType: Which type of intersection to test for

Parameter rayBuffer: Buffer containing rays to intersect against the acceleration structure. The ray data type is defined by the rayDataType and rayStride properties.

Parameter rayBufferOffset: Offset, in bytes, into the ray buffer. Must be a multiple of the ray stride.

Parameter intersectionBuffer: Buffer to store intersection in. Intersections are stored in the same order as the ray buffer, one intersection per ray. The intersection data type is defined by the intersectionDataType and intersectionStride properties.

Parameter intersectionBufferOffset: Offset, in bytes, into the intersection buffer. Must be a multiple of the intersection stride.

Parameter rayCount: Number of rays

Parameter accelerationStructure: Acceleration structure to test against

ยงSafety
  • ray_buffer may need to be synchronized.
  • ray_buffer may be unretained, you must ensure it is kept alive while in use.
  • ray_buffer contents should be of the correct type.
  • intersection_buffer may need to be synchronized.
  • intersection_buffer may be unretained, you must ensure it is kept alive while in use.
  • intersection_buffer contents should be of the correct type.
Source

pub unsafe fn encodeIntersectionToCommandBuffer_intersectionType_rayBuffer_rayBufferOffset_intersectionBuffer_intersectionBufferOffset_rayCountBuffer_rayCountBufferOffset_accelerationStructure( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, intersection_type: MPSIntersectionType, ray_buffer: &ProtocolObject<dyn MTLBuffer>, ray_buffer_offset: NSUInteger, intersection_buffer: &ProtocolObject<dyn MTLBuffer>, intersection_buffer_offset: NSUInteger, ray_count_buffer: &ProtocolObject<dyn MTLBuffer>, ray_count_buffer_offset: NSUInteger, acceleration_structure: &MPSAccelerationStructure, )

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

Schedule intersection tests between rays and an acceleration structure with a ray count provided in a buffer

Parameter commandBuffer: Command buffer to schedule intersection testing in

Parameter intersectionType: Which type of intersection to test for

Parameter rayBuffer: Buffer containing rays to intersect against the acceleration structure. The ray data type is defined by the rayDataType and rayStride properties.

Parameter rayBufferOffset: Offset, in bytes, into the ray buffer. Must be a multiple of the ray stride.

Parameter intersectionBuffer: Buffer to store intersection in. Intersections are stored in the same order as the ray buffer, one intersection per ray. The intersection data type is defined by the intersectionDataType and intersectionStride properties.

Parameter intersectionBufferOffset: Offset, in bytes, into the intersection buffer. Must be a multiple of the intersection stride.

Parameter rayCountBuffer: Buffer containing number of rays as a 32 bit unsigned integer

Parameter rayCountBufferOffset: Offset, in bytes, into the ray count buffer. Must be a multiple of 4 bytes.

Parameter accelerationStructure: Acceleration structure to test against

ยงSafety
  • ray_buffer may need to be synchronized.
  • ray_buffer may be unretained, you must ensure it is kept alive while in use.
  • ray_buffer contents should be of the correct type.
  • intersection_buffer may need to be synchronized.
  • intersection_buffer may be unretained, you must ensure it is kept alive while in use.
  • intersection_buffer contents should be of the correct type.
  • ray_count_buffer may need to be synchronized.
  • ray_count_buffer may be unretained, you must ensure it is kept alive while in use.
  • ray_count_buffer contents should be of the correct type.
Source

pub unsafe fn encodeIntersectionToCommandBuffer_intersectionType_rayBuffer_rayBufferOffset_rayIndexBuffer_rayIndexBufferOffset_intersectionBuffer_intersectionBufferOffset_rayIndexCount_accelerationStructure( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, intersection_type: MPSIntersectionType, ray_buffer: &ProtocolObject<dyn MTLBuffer>, ray_buffer_offset: NSUInteger, ray_index_buffer: &ProtocolObject<dyn MTLBuffer>, ray_index_buffer_offset: NSUInteger, intersection_buffer: &ProtocolObject<dyn MTLBuffer>, intersection_buffer_offset: NSUInteger, ray_index_count: NSUInteger, acceleration_structure: &MPSAccelerationStructure, )

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

Schedule intersection tests between rays and an acceleration structure

Parameter commandBuffer: Command buffer to schedule intersection testing in

Parameter intersectionType: Which type of intersection to test for

Parameter rayBuffer: Buffer containing rays to intersect against the acceleration structure. The ray data type is defined by the rayDataType and rayStride properties.

Parameter rayBufferOffset: Offset, in bytes, into the ray buffer. Must be a multiple of the ray stride.

Parameter rayIndexBuffer: Buffer containing ray indices. Each index references a ray in the ray buffer. The ray index data type is controlled by the rayIndexDataType property.

Parameter rayIndexBufferOffset: Offset, in bytes, into the ray index buffer. Must be a multiple of the stride of the ray index type.

Parameter intersectionBuffer: Buffer to store intersection in. Intersections are stored in the same order as the ray buffer, one intersection per ray. The intersection data type is defined by the intersectionDataType and intersectionStride properties.

Parameter intersectionBufferOffset: Offset, in bytes, into the intersection buffer. Must be a multiple of the intersection stride.

Parameter rayIndexCount: Number of ray indices

Parameter accelerationStructure: Acceleration structure to test against

ยงSafety
  • ray_buffer may need to be synchronized.
  • ray_buffer may be unretained, you must ensure it is kept alive while in use.
  • ray_buffer contents should be of the correct type.
  • ray_index_buffer may need to be synchronized.
  • ray_index_buffer may be unretained, you must ensure it is kept alive while in use.
  • ray_index_buffer contents should be of the correct type.
  • intersection_buffer may need to be synchronized.
  • intersection_buffer may be unretained, you must ensure it is kept alive while in use.
  • intersection_buffer contents should be of the correct type.
Source

pub unsafe fn encodeIntersectionToCommandBuffer_intersectionType_rayBuffer_rayBufferOffset_rayIndexBuffer_rayIndexBufferOffset_intersectionBuffer_intersectionBufferOffset_rayIndexCountBuffer_rayIndexCountBufferOffset_accelerationStructure( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, intersection_type: MPSIntersectionType, ray_buffer: &ProtocolObject<dyn MTLBuffer>, ray_buffer_offset: NSUInteger, ray_index_buffer: &ProtocolObject<dyn MTLBuffer>, ray_index_buffer_offset: NSUInteger, intersection_buffer: &ProtocolObject<dyn MTLBuffer>, intersection_buffer_offset: NSUInteger, ray_index_count_buffer: &ProtocolObject<dyn MTLBuffer>, ray_index_count_buffer_offset: NSUInteger, acceleration_structure: &MPSAccelerationStructure, )

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

Schedule intersection tests between rays and an acceleration structure with a ray count provided in a buffer

Parameter commandBuffer: Command buffer to schedule intersection testing in

Parameter intersectionType: Which type of intersection to test for

Parameter rayBuffer: Buffer containing rays to intersect against the acceleration structure. The ray data type is defined by the rayDataType and rayStride properties.

Parameter rayBufferOffset: Offset, in bytes, into the ray buffer. Must be a multiple of the ray stride.

Parameter rayIndexBuffer: Buffer containing ray indices. Each index references a ray in the ray buffer. The ray index data type is controlled by the rayIndexDataType property.

Parameter rayIndexBufferOffset: Offset, in bytes, into the ray index buffer. Must be a multiple of the stride of the ray index type.

Parameter intersectionBuffer: Buffer to store intersection in. Intersections are stored in the same order as the ray buffer, one intersection per ray. The intersection data type is defined by the intersectionDataType and intersectionStride properties.

Parameter intersectionBufferOffset: Offset, in bytes, into the intersection buffer. Must be a multiple of the intersection stride.

Parameter rayIndexCountBuffer: Buffer containing number of rays as a 32 bit unsigned integer

Parameter rayIndexCountBufferOffset: Offset, in bytes, into the ray count buffer. Must be a multiple of 4 bytes.

Parameter accelerationStructure: Acceleration structure to test against

ยงSafety
  • ray_buffer may need to be synchronized.
  • ray_buffer may be unretained, you must ensure it is kept alive while in use.
  • ray_buffer contents should be of the correct type.
  • ray_index_buffer may need to be synchronized.
  • ray_index_buffer may be unretained, you must ensure it is kept alive while in use.
  • ray_index_buffer contents should be of the correct type.
  • intersection_buffer may need to be synchronized.
  • intersection_buffer may be unretained, you must ensure it is kept alive while in use.
  • intersection_buffer contents should be of the correct type.
  • ray_index_count_buffer may need to be synchronized.
  • ray_index_count_buffer may be unretained, you must ensure it is kept alive while in use.
  • ray_index_count_buffer contents should be of the correct type.
Source

pub unsafe fn encodeIntersectionToCommandBuffer_intersectionType_rayTexture_intersectionTexture_accelerationStructure( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, intersection_type: MPSIntersectionType, ray_texture: &ProtocolObject<dyn MTLTexture>, intersection_texture: &ProtocolObject<dyn MTLTexture>, acceleration_structure: &MPSAccelerationStructure, )

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

Schedule intersection tests between rays and an acceleration structure, where rays and loaded from a texture and intersections are stored into a texture.

This is convenient for hybrid rendering applications which produce ray data from a fragment shader. The ray and intersection texture must be 2D array textures. Ray data must be packed into consecutive channels and slices of the ray texture. Intersection data will be packed the same way. The ray and intersection data types are defined by the rayDataType and intersectionDataType properties. The rayStride and intersectionStride properties are ignored. Channels and slices beyond the required number are ignored when reading from the ray texture. Channels and slices beyond the required number are undefined when writing to the intersection texture.

For example, if the ray data type is MPSRayDataTypeOriginMaskDirectionMaxDistance, the ray texture must have pixel format MTLPixelFormatRGBA32Float and at least two array slices, packed as follows:

     tex.write(float4(ray.position, as_type<float>(ray.mask)), pixel, 0); // slice 0
     tex.write(float4(ray.direction, ray.maxDistance), pixel, 1);         // slice 1
     @end

 If the intersection data type is MPSIntersectionDataTypeDistance, the intersection texture may
 have pixel format MTLPixelFormatR32Float with just a single channel and one array slice, and
 should be unpacked as follows:

     @code
     float distance = tex.read(pixel, 0).x;
     @end

 On the other hand, if the intersection data type is
 MPSIntersectionDistancePrimitiveIndexInstanceIndexCoordinates, the intersection texture must
 have pixel format MTLPixelFormatRGBA32Float and at least two slices:

     @code
     float3 f0 = tex.read(pixel, 0);

     float distance = f0.x;
     unsigned int primitiveIndex = as_type<unsigned int>(f0.y);
     unsigned int instanceIndex = as_type<unsigned int>(f0.z);
     // w component is padding for this intersection data type

     float2 coordinates = tex.read(pixel, 1).xy;
     @end

 @param commandBuffer            Command buffer to schedule intersection testing in
 @param intersectionType         Which type of intersection to test for
 @param rayTexture               A 2D array texture containing rays to intersect against the
                                 acceleration structure. The ray data type is defined by the
                                 rayDataType property.
 @param intersectionTexture      Texture to store intersection in. Intersections are stored in
                                 the same position as the ray texture, one intersection per ray.
                                 The intersection data type is defined by the
                                 intersectionDataType property.
 @param accelerationStructure    Acceleration structure to test against
  
ยงSafety
  • ray_texture may need to be synchronized.
  • ray_texture may be unretained, you must ensure it is kept alive while in use.
  • intersection_texture may need to be synchronized.
  • intersection_texture may be unretained, you must ensure it is kept alive while in use.
Sourceยง

impl MPSRayIntersector

Methods declared on superclass MPSKernel.

Source

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

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 MPSRayIntersector

Methods declared on superclass NSObject.

Source

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

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 MPSRayIntersector

Sourceยง

fn as_ref(&self) -> &AnyObject

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

impl AsRef<MPSKernel> for MPSRayIntersector

Sourceยง

fn as_ref(&self) -> &MPSKernel

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

impl AsRef<MPSRayIntersector> for MPSRayIntersector

Sourceยง

fn as_ref(&self) -> &Self

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

impl AsRef<NSObject> for MPSRayIntersector

Sourceยง

fn as_ref(&self) -> &NSObject

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

impl Borrow<AnyObject> for MPSRayIntersector

Sourceยง

fn borrow(&self) -> &AnyObject

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

impl Borrow<MPSKernel> for MPSRayIntersector

Sourceยง

fn borrow(&self) -> &MPSKernel

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

impl Borrow<NSObject> for MPSRayIntersector

Sourceยง

fn borrow(&self) -> &NSObject

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

impl ClassType for MPSRayIntersector

Sourceยง

const NAME: &'static str = "MPSRayIntersector"

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 = <<MPSRayIntersector 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 MPSRayIntersector

Sourceยง

type Result = MPSRayIntersector

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

impl Debug for MPSRayIntersector

Sourceยง

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

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

impl Deref for MPSRayIntersector

Sourceยง

type Target = MPSKernel

The resulting type after dereferencing.
Sourceยง

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

Dereferences the value.
Sourceยง

impl Hash for MPSRayIntersector

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 MPSRayIntersector

Sourceยง

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

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

impl NSCoding for MPSRayIntersector

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 MPSRayIntersector

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 MPSRayIntersector

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 MPSRayIntersector

Sourceยง

impl PartialEq for MPSRayIntersector

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 MPSRayIntersector

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 MPSRayIntersector

Sourceยง

impl Eq for MPSRayIntersector

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,