objc2_metal_performance_shaders/generated/MPSRayIntersector/
MPSAccelerationStructure.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7use objc2_metal::*;
8
9use crate::*;
10
11/// A block of code invoked when an operation on an MPSAccelerationStructure is completed
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsaccelerationstructurecompletionhandler?language=objc)
14#[deprecated]
15#[cfg(all(feature = "MPSCore", feature = "MPSKernel", feature = "block2"))]
16pub type MPSAccelerationStructureCompletionHandler =
17    *mut block2::DynBlock<dyn Fn(*mut MPSAccelerationStructure)>;
18
19/// Options describing how an acceleration structure will be used
20///
21/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsaccelerationstructureusage?language=objc)
22// NS_OPTIONS
23#[deprecated]
24#[repr(transparent)]
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
26pub struct MPSAccelerationStructureUsage(pub NSUInteger);
27bitflags::bitflags! {
28    impl MPSAccelerationStructureUsage: NSUInteger {
29/// No usage options specified
30        #[doc(alias = "MPSAccelerationStructureUsageNone")]
31#[deprecated]
32        const None = 0;
33/// Enable support for refitting the acceleration structure after it has been built.
34/// This option may reduce raytracing performance so do not use it unless the acceleration
35/// structure will be refit.
36        #[doc(alias = "MPSAccelerationStructureUsageRefit")]
37#[deprecated]
38        const Refit = 1;
39/// Option indicating that the acceleration structure will be rebuilt frequently. In this
40/// case, the acceleration structure may choose a higher performance but lower quality
41/// acceleration structure construction algorithm. This option may reduce raytracing performance
42/// performance so do not use it unless reduced acceleration structure build time is
43/// worth reduced raytracing performance. This option may be useful if, for example, the user
44/// is interactively editing a live view of the scene.
45        #[doc(alias = "MPSAccelerationStructureUsageFrequentRebuild")]
46#[deprecated]
47        const FrequentRebuild = 2;
48/// Prefer building the acceleration structure on the GPU. By default, the acceleration
49/// structure will be built on the GPU when possible. However, in some cases such as very small
50/// triangle counts, the acceleration structure may be built on the CPU. This option will force
51/// the acceleration structure to be always be built on the GPU whenever possible.
52        #[doc(alias = "MPSAccelerationStructureUsagePreferGPUBuild")]
53#[deprecated]
54        const PreferGPUBuild = 4;
55/// Prefer building the acceleration structure on the CPU. By default, the acceleration
56/// structure will be built on the GPU when possible, which is typically much faster than
57/// building on the CPU. However, in some cases it may be preferable to build on the CPU such as
58/// to avoid framerate hitches when the GPU is rendering the user interface.
59        #[doc(alias = "MPSAccelerationStructureUsagePreferCPUBuild")]
60#[deprecated]
61        const PreferCPUBuild = 8;
62    }
63}
64
65unsafe impl Encode for MPSAccelerationStructureUsage {
66    const ENCODING: Encoding = NSUInteger::ENCODING;
67}
68
69unsafe impl RefEncode for MPSAccelerationStructureUsage {
70    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
71}
72
73/// Possible values of the acceleration structure status property
74///
75/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsaccelerationstructurestatus?language=objc)
76// NS_ENUM
77#[deprecated]
78#[repr(transparent)]
79#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
80pub struct MPSAccelerationStructureStatus(pub NSUInteger);
81impl MPSAccelerationStructureStatus {
82    /// The acceleration structure has not been built yet
83    #[doc(alias = "MPSAccelerationStructureStatusUnbuilt")]
84    #[deprecated]
85    pub const Unbuilt: Self = Self(0);
86    /// The acceleration structure has finished building
87    #[doc(alias = "MPSAccelerationStructureStatusBuilt")]
88    #[deprecated]
89    pub const Built: Self = Self(1);
90}
91
92unsafe impl Encode for MPSAccelerationStructureStatus {
93    const ENCODING: Encoding = NSUInteger::ENCODING;
94}
95
96unsafe impl RefEncode for MPSAccelerationStructureStatus {
97    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
98}
99
100extern_class!(
101    /// A data structure built over geometry used to accelerate ray tracing
102    ///
103    ///
104    /// Do not use this base class directly. Use one of the derived classes instead.
105    /// The general pattern for creating an acceleration structure is as follows. First, create the
106    /// acceleration structure:
107    ///
108    ///
109    /// ```text
110    ///      MPSTriangleAccelerationStructure *accelerationStructure = nil;
111    ///      accelerationStructure = [[MPSTriangleAccelerationStructure alloc] initWithDevice:device];
112    /// ```
113    ///
114    /// Then, assign values to the acceleration structure's properties:
115    ///
116    ///
117    /// ```text
118    ///      accelerationStructure.vertexBuffer = vertexBuffer;
119    ///      accelerationStructure.triangleCount = triangleCount;
120    /// ```
121    ///
122    /// Finally, the acceleration structure must be built:
123    ///
124    ///
125    /// ```text
126    ///      [accelerationStructure rebuild];
127    /// ```
128    ///
129    /// The acceleration structure can then be used to encode ray intersection tests with an
130    /// MPSRayIntersector:
131    ///
132    ///
133    /// ```text
134    ///      [raytracer encodeIntersectionToCommandBuffer:commandBuffer
135    ///                                  intersectionType:MPSIntersectionTypeNearest
136    ///                                         rayBuffer:rayBuffer
137    ///                                   rayBufferOffset:0
138    ///                                intersectionBuffer:intersectionBuffer
139    ///                          intersectionBufferOffset:0
140    ///                                          rayCount:rayCount
141    ///                             accelerationStructure:accelerationStructure];
142    /// ```
143    ///
144    /// Asynchronous Acceleration Structure Builds: Rebuilding an acceleration structure is an expensive
145    /// operation. Note that there is also a method to rebuild the acceleration structure asynchronously
146    /// to avoid blocking the main thread.
147    ///
148    ///
149    /// ```text
150    ///      [accelerationStructure rebuildWithCompletionHandler:^(MPSAccelerationStructure *accel) {
151    ///          // Kick off ray intersection work
152    ///      }];
153    /// ```
154    ///
155    /// Streaming Geometry Updates: It is generally safe to change buffer properties such as the vertex
156    /// buffer after intersection tests have been encoded into a command buffer, but the contents of
157    /// those buffers cannot be safely changed by the CPU until the command buffer has finished
158    /// executing on the GPU. It is also not safe to rebuild the acceleration structure until the
159    /// command buffer has completed.
160    ///
161    /// If the CPU needs to stream geometry updates to the GPU, ensure the vertex and other buffers are
162    /// double or triple buffered.
163    ///
164    ///
165    /// ```text
166    ///      #define MAX_ASYNC_OPERATIONS 3
167    ///
168    ///      // Initialization:
169    ///
170    ///      // Create a semaphore with the maximum number of asynchronous operations in flight
171    ///      dispatch_semaphore_t asyncOperationSemaphore = dispatch_semaphore_create(MAX_ASYNC_OPERATIONS);
172    ///
173    ///      // Create an acceleration structure for each vertex buffer range
174    ///      NSMutableArray *accelerationStructures = [NSMutableArray array];
175    ///
176    ///      NSUInteger vertexBufferLength = sizeof(float3) * vertexCount * MAX_ASYNC_OPERATIONS;
177    ///      id <MTLBuffer> vertexBuffer = [device newBufferWithLength:vertexBufferLength
178    ///                                                        options:MTLResourceStorageModeManaged];
179    ///
180    ///      for (NSUInteger i = 0; i < MAX_ASYNC_OPERATIONS; i++) {
181    ///          MPSTriangleAccelerationStructure *accel = nil;
182    ///          accel = [[MPSTriangleAccelerationStructure alloc] initWithDevice:device];
183    ///
184    ///          // Configure acceleration structure
185    ///          accel.vertexBuffer = vertexBuffer;
186    ///          accel.vertexBufferOffset = i * sizeof(float3) * vertexCount;
187    ///
188    ///          [accelerationStructures addObject:accel];
189    ///      }
190    ///
191    ///      NSUInteger asyncOperationIndex = 0;
192    ///
193    ///      // Encode intersection testing:
194    ///
195    ///      // Wait until there is a free acceleration structure
196    ///      dispatch_semaphore_wait(asyncOperationSemaphore, DISPATCH_TIME_FOREVER);
197    ///
198    ///      MPSTriangleAccelerationStructure *accel = accelerationStructures[asyncOperationIndex];
199    ///      asyncOperationIndex = (asyncOperationIndex + 1) % MAX_ASYNC_OPERATIONS;
200    ///
201    ///      float3 *vertices = (float3 *)((uint8_t *)vertexBuffer.contents + accel.vertexBufferOffset);
202    ///      // Update vertices
203    ///      MPSDidModifyRange(vertexBuffer, NSMakeRange(accel.vertexBufferOffset, sizeof(float3) * vertexCount));
204    ///
205    ///      // Rebuild the acceleration structure
206    ///      [accel rebuild];
207    ///
208    ///      // Encode actual intersection work
209    ///      [raytracer encodeIntersectionToCommandBuffer:commandBuffer
210    ///                                  intersectionType:MPSIntersectionTypeNearest
211    ///                                         rayBuffer:rayBuffer
212    ///                                   rayBufferOffset:rayBufferOffset
213    ///                                intersectionBuffer:intersectionBuffer
214    ///                          intersectionBufferOffset:intersectionBufferOffset
215    ///                                          rayCount:rayCount
216    ///                             accelerationStructure:accel];
217    ///
218    ///      // Register a completion handler to run when the GPU finishes executing
219    ///      [commandBuffer addCompletedHandler:^(id <MTLCommandBuffer> commandBuffer) {
220    ///          Intersection *intersections = (Intersection *)((uint8_t *)intersectionBuffer.contents +
221    ///              intersectionBufferOffset);
222    ///
223    ///          // Process intersections
224    ///
225    ///          // Signal that the acceleration structure is now available for reuse
226    ///          dispatch_semaphore_signal(asyncOperationSemaphore);
227    ///      }];
228    ///
229    ///      // Commit the command buffer to allow the GPU to start executing
230    ///      [commandBuffer commit];
231    /// ```
232    ///
233    /// Refitting acceleration structures: If geometry has only moved slightly and not added or removed
234    /// from the scene, it can be much faster to refit the existing topology of an acceleration
235    /// structure to the new geometry than to rebuild the acceleration structure from scratch. Refitting
236    /// can also be pipelined with other GPU work such as intersection testing. If the geometry is
237    /// transformed entirely on the GPU, it is not necessary to use double or triple buffering. For
238    /// example:
239    ///
240    ///
241    /// ```text
242    ///      id <MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];
243    ///
244    ///      id <MTLComputeCommandEncoder> encoder = [commandBuffer computeCommandEncoder];
245    ///
246    ///      [encoder setBuffer:untransformedVertexBuffer offset:0 atIndex:0];
247    ///
248    ///      [encoder setBuffer:accelerationStructure.vertexBuffer
249    ///                  offset:accelerationStructure.vertexBufferOffset
250    ///                 atIndex:1];
251    ///
252    ///      [encoder setBuffer:transformationMatrices offset:0 atIndex:2];
253    ///
254    ///      [encoder setComputePipelineState:transformVerticesPipeline];
255    ///
256    ///      [encoder dispatchThreads:MTLSizeMake(accelerationStructure.triangleCount * 3, 1, 1)
257    ///         threadsPerThreadgroup:MTLSizeMake(64, 1, 1)];
258    ///
259    ///      [encoder endEncoding];
260    ///
261    ///      [accelerationStructure encodeRefitToCommandBuffer:commandBuffer];
262    ///
263    ///      [commandBuffer commit];
264    /// ```
265    ///
266    /// Serializing Acceleration Structures: Instead of rebuilding acceleration structures from scratch
267    /// they can be built offline, serialized, and reloaded at runtime using the NSSecureCoding
268    /// protocol:
269    ///
270    ///
271    /// ```text
272    ///      // Build time:
273    ///      NSError *error = nil;
274    ///      NSData *data = [NSKeyedArchiver archivedDataWithRootObject:accel
275    ///                                           requiringSecureCoding:YES
276    ///                                                           error:&error];
277    ///         
278    ///      if (!data)
279    ///          NSLog(@"Error archiving MPSAccelerationStructure: %@",
280    ///              error.localizedDescription);
281    ///
282    ///      // Runtime:
283    ///      MPSTriangleAccelerationStructure *accel;
284    ///      accel = [NSKeyedUnarchiver unarchivedObjectOfClass:[MPSTriangleAccelerationStructure class]
285    ///                                                fromData:data
286    ///                                                   error:&error];
287    ///
288    ///      if (!accel)
289    ///          NSLog(@"Error unarchiving MPSAccelerationStructure: %@",
290    ///              error.localizedDescription);
291    /// ```
292    ///
293    /// Copying Acceleration Structures: Acceleration structures can be copied using the NSCopying
294    /// protocol, even to a different Metal device. This can be used for multi-GPU raytracing. Buffer
295    /// properties are not copied to the new acceleration structure. These buffers must instead be
296    /// copied to the new Metal device and assigned to the new acceleration structure. For example:
297    ///
298    ///
299    /// ```text
300    ///      MPSTriangleAccelerationStructure *copy = [accelerationStructure copyWithZone:nil
301    ///                                                                            device:newDevice];
302    ///
303    ///      copy.vertexBuffer = [self copyBuffer:accelerationStructure.vertexBuffer
304    ///                                withDevice:newDevice];
305    /// ```
306    ///
307    /// Performance Guidelines:
308    ///
309    /// - Provide accurate acceleration structure hints: if an acceleration structure does not
310    /// require support for refitting, a higher quality construction algorithm can be used.
311    /// However, if an acceleration structure must be rebuilt frequently, a lower quality
312    /// but higher performance construction algorithm can be used.
313    ///
314    /// - Consider refitting existing acceleration structures rather than rebuilding them from
315    /// scratch. This is typically much faster and can result in a reasonably high quality
316    /// tree if the geometry has not been modified dramatically. Refitting can also be pipelined
317    /// with other GPU work. If objects have been added to or removed from the scene, it is
318    /// typically necessary to rebuild the acceleration structure rather than refit it.
319    ///
320    /// - Rebuild acceleration structures asynchronously when possible to avoid blocking the main
321    /// thread. Consider presenting a UI indicating that work is happening in the background while
322    /// allowing the user to consider interacting with your application.
323    ///
324    /// - If you need to mix intersection testing with acceleration structure builds (e.g. if the
325    /// user is interactively editing the scene while rendering or if objects are moving
326    /// significantly) consider allocating two independent acceleration structures that refer to
327    /// two copies of the scene data. Then, asynchronously rebuild one acceleration structure
328    /// while the other one is used for rendering. Once the rebuild has completed, swap the
329    /// acceleration structures. The intermediate frames could be filled by refitting the
330    /// rendering acceleration structure until the rebuilt acceleration structure is ready.
331    ///
332    /// - When running in Xcode, disable "Enable Backtrace Recording" in your scheme settings.
333    /// Enabling this setting can significantly increase acceleration structure build time.
334    ///
335    /// - Consider using quadrilaterals instead of triangles to represent your geometry.
336    /// The cost of intersecting a quadrilateral is typically less than the cost of intersecting
337    /// two triangles, so quadrilaterals can improve performance. Quadrilaterals also typically
338    /// require 30-40% less memory than triangles including vertex data and internal buffers
339    /// allocated by the acceleration structure. Whether quadrilaterals improve or hurt
340    /// performance can depend on the geometry and ray distribution, so you should choose
341    /// whichever performs better for your application.
342    ///
343    /// Thread Safety: MPSAccelerationStructures are generally not thread safe. Changing properties
344    /// and rebuilding acceleration structures from multiple threads result in undefined behavior.
345    /// However, it is safe to encode intersection tests with a single acceleration structure
346    /// from multiple threads as long as each thread uses its own MPSRayIntersector.
347    ///
348    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsaccelerationstructure?language=objc)
349    #[unsafe(super(MPSKernel, NSObject))]
350    #[derive(Debug, PartialEq, Eq, Hash)]
351    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
352    #[deprecated]
353    pub struct MPSAccelerationStructure;
354);
355
356#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
357extern_conformance!(
358    unsafe impl NSCoding for MPSAccelerationStructure {}
359);
360
361#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
362extern_conformance!(
363    unsafe impl NSCopying for MPSAccelerationStructure {}
364);
365
366#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
367unsafe impl CopyingHelper for MPSAccelerationStructure {
368    type Result = Self;
369}
370
371#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
372extern_conformance!(
373    unsafe impl NSObjectProtocol for MPSAccelerationStructure {}
374);
375
376#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
377extern_conformance!(
378    unsafe impl NSSecureCoding for MPSAccelerationStructure {}
379);
380
381#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
382impl MPSAccelerationStructure {
383    extern_methods!(
384        #[cfg(feature = "MPSAccelerationStructureGroup")]
385        /// The group this acceleration structure was created with
386        #[deprecated]
387        #[unsafe(method(group))]
388        #[unsafe(method_family = none)]
389        pub unsafe fn group(&self) -> Retained<MPSAccelerationStructureGroup>;
390
391        /// Status indicating whether the acceleration structure has finished building
392        #[deprecated]
393        #[unsafe(method(status))]
394        #[unsafe(method_family = none)]
395        pub unsafe fn status(&self) -> MPSAccelerationStructureStatus;
396
397        /// Acceleration structure usage options. Changes to this property require rebuilding the
398        /// acceleration structure. Defaults to MPSAccelerationStructureUsageNone.
399        #[deprecated]
400        #[unsafe(method(usage))]
401        #[unsafe(method_family = none)]
402        pub unsafe fn usage(&self) -> MPSAccelerationStructureUsage;
403
404        /// Setter for [`usage`][Self::usage].
405        #[deprecated]
406        #[unsafe(method(setUsage:))]
407        #[unsafe(method_family = none)]
408        pub unsafe fn setUsage(&self, usage: MPSAccelerationStructureUsage);
409
410        #[deprecated]
411        #[unsafe(method(init))]
412        #[unsafe(method_family = init)]
413        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
414
415        /// Initialize the acceleration structure with a Metal device
416        #[deprecated]
417        #[unsafe(method(initWithDevice:))]
418        #[unsafe(method_family = init)]
419        pub unsafe fn initWithDevice(
420            this: Allocated<Self>,
421            device: &ProtocolObject<dyn MTLDevice>,
422        ) -> Retained<Self>;
423
424        /// Initialize the acceleration structure with an NSCoder and a Metal device. Buffer
425        /// properties such as the vertex buffer, instance buffer, etc. are set to nil. Encode and decode
426        /// these buffers along with the acceleration structure instead.
427        ///
428        /// # Safety
429        ///
430        /// `a_decoder` possibly has further requirements.
431        #[deprecated]
432        #[unsafe(method(initWithCoder:device:))]
433        #[unsafe(method_family = init)]
434        pub unsafe fn initWithCoder_device(
435            this: Allocated<Self>,
436            a_decoder: &NSCoder,
437            device: &ProtocolObject<dyn MTLDevice>,
438        ) -> Option<Retained<Self>>;
439
440        #[cfg(feature = "MPSAccelerationStructureGroup")]
441        /// Initialize the acceleration structure with an acceleration structure group, if the
442        /// acceleration structure will be used in an instance hierarchy.
443        ///
444        ///
445        /// The Metal device is determined from the acceleration structure group. All
446        /// acceleration structures in the instance hierarchy must share the same group.
447        #[deprecated]
448        #[unsafe(method(initWithGroup:))]
449        #[unsafe(method_family = init)]
450        pub unsafe fn initWithGroup(
451            this: Allocated<Self>,
452            group: &MPSAccelerationStructureGroup,
453        ) -> Retained<Self>;
454
455        #[cfg(feature = "MPSAccelerationStructureGroup")]
456        /// Initialize the acceleration structure with an NSCoder and an acceleration structure
457        /// group, if the acceleration structure will be used in an instance hierarchy. All acceleration
458        /// structures in the instance hierarchy must share the same group. Buffer properties such as the
459        /// vertex buffer, instance buffer, etc. are set to nil. Encode and decode these buffers along with
460        /// the acceleration structure instead.
461        ///
462        /// # Safety
463        ///
464        /// `a_decoder` possibly has further requirements.
465        #[deprecated]
466        #[unsafe(method(initWithCoder:group:))]
467        #[unsafe(method_family = init)]
468        pub unsafe fn initWithCoder_group(
469            this: Allocated<Self>,
470            a_decoder: &NSCoder,
471            group: &MPSAccelerationStructureGroup,
472        ) -> Option<Retained<Self>>;
473
474        /// Rebuild the acceleration structure
475        ///
476        ///
477        /// This method must be called before any intersection tests can be scheduled with this
478        /// acceleration structure. Before calling this method, fill out the properties of the acceleration
479        /// structure such as vertex buffer, instance buffer, etc. The acceleration structure should be
480        /// rebuilt when its contents (e.g. vertices in a triangle acceleration structure) have been
481        /// modified significantly and must be rebuilt when properties such as triangle count,
482        /// vertex stride, etc. have changed. When the contents of the acceleration structure have only been
483        /// modified slightly, it may be cheaper to refit the acceleration structure instead.
484        ///
485        /// This method blocks until the acceleration structure has been rebuilt. Until the rebuild has
486        /// completed, the acceleration structure cannot be copied, encoded with NSSecureCoding, rebuilt, or
487        /// refit. Before this method can be called, any pending GPU writes to the vertex buffer, index
488        /// buffer, etc. must be completed (and, for managed buffers, synchronized). Any prior intersection
489        /// tests must also be completed before the acceleration structure can be rebuilt.
490        #[deprecated]
491        #[unsafe(method(rebuild))]
492        #[unsafe(method_family = none)]
493        pub unsafe fn rebuild(&self);
494
495        #[cfg(feature = "block2")]
496        /// Rebuild the acceleration structure asynchronously
497        ///
498        ///
499        /// This method must be called before any intersection tests can be scheduled with this
500        /// acceleration structure. Before calling this method, fill out the properties of the acceleration
501        /// structure such as vertex buffer, instance buffer, etc. The acceleration structure should be
502        /// rebuilt when its contents (e.g. vertices in a triangle acceleration structure) have been
503        /// modified significantly and must be rebuilt when properties such as triangle count,
504        /// vertex stride, etc. have changed. When the contents of the acceleration structure have only been
505        /// modified slightly, it may be cheaper to refit the acceleration structure instead.
506        ///
507        /// Until the rebuild has completed, the acceleration structure cannot be copied, encoded with
508        /// NSSecureCoding, rebuilt, or refit. Before this method can be called, any pending GPU writes to
509        /// the vertex buffer, index buffer, etc. must be completed (and, for managed buffers,
510        /// synchronized). Any prior intersection tests must also be completed before the acceleration
511        /// structure can be rebuilt.
512        ///
513        /// # Safety
514        ///
515        /// `completion_handler` must be a valid pointer.
516        #[deprecated]
517        #[unsafe(method(rebuildWithCompletionHandler:))]
518        #[unsafe(method_family = none)]
519        pub unsafe fn rebuildWithCompletionHandler(
520            &self,
521            completion_handler: MPSAccelerationStructureCompletionHandler,
522        );
523
524        /// Refit the existing acceleration structure to new data
525        ///
526        ///
527        /// This method is used to refit the acceleration structure to new vertex data,
528        /// index data, instance data, etc. while preserving the existing acceleration structure topology.
529        /// This is typically much faster than a full rebuild of the acceleration structure. Refitting can
530        /// also be pipelined with other GPU work such as ray intersection.
531        ///
532        /// Until the command buffer has completed, the acceleration structure cannot be copied,
533        /// encoded with NSSecureCoding, or rebuilt. Changes to properties such as the triangle count or
534        /// instance count might not be reflected. These changes require that the acceleration structure be
535        /// rebuilt instead. The acceleration structure must be rebuilt at least once before this method can
536        /// be called.
537        #[deprecated]
538        #[unsafe(method(encodeRefitToCommandBuffer:))]
539        #[unsafe(method_family = none)]
540        pub unsafe fn encodeRefitToCommandBuffer(
541            &self,
542            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
543        );
544
545        /// Create a a copy of this acceleration structure
546        ///
547        ///
548        /// The acceleration structure may be copied to a different Metal device. Buffer
549        /// properties of the acceleration structure such as the vertex buffer, instance, buffer, etc. are
550        /// set to nil. Copy these buffers to the new Metal device and assign them to the new acceleration
551        /// structure instead. Do not copy the acceleration structure until any prior refit or rebuild
552        /// operations have completed.
553        ///
554        ///
555        /// Parameter `zone`: This parameter is ignored. Memory zones are no longer used by Objective-C.
556        ///
557        /// Parameter `device`: New Metal device
558        ///
559        /// # Safety
560        ///
561        /// `zone` must be a valid pointer or null.
562        #[deprecated]
563        #[unsafe(method(copyWithZone:device:))]
564        #[unsafe(method_family = copy)]
565        pub unsafe fn copyWithZone_device(
566            &self,
567            zone: *mut NSZone,
568            device: Option<&ProtocolObject<dyn MTLDevice>>,
569        ) -> Retained<Self>;
570
571        #[cfg(feature = "MPSAccelerationStructureGroup")]
572        /// Create a a copy of this acceleration structure
573        ///
574        ///
575        /// The acceleration structure may be copied with a different acceleration structure
576        /// group. Buffer properties of the acceleration structure such as the vertex buffer, instance
577        /// buffer, etc. are set to nil. Copy these buffers with the new Metal device and assign them to
578        /// the new acceleration structure instead. Do not copy the acceleration structure until any prior
579        /// refit or rebuild operations have completed.
580        ///
581        ///
582        /// Parameter `zone`: This parameter is ignored. Memory zones are no longer used by Objective-C.
583        ///
584        /// Parameter `group`: New acceleration structure group
585        ///
586        /// # Safety
587        ///
588        /// `zone` must be a valid pointer or null.
589        #[deprecated]
590        #[unsafe(method(copyWithZone:group:))]
591        #[unsafe(method_family = copy)]
592        pub unsafe fn copyWithZone_group(
593            &self,
594            zone: *mut NSZone,
595            group: &MPSAccelerationStructureGroup,
596        ) -> Retained<Self>;
597
598        /// Encode the acceleration structure with an NSCoder
599        ///
600        ///
601        /// Buffer properties such as the vertex buffer, index buffer, etc. are not be encoded.
602        /// Encode and decode these buffers along with the acceleration structure instead. Do not encode
603        /// the acceleration structure until any prior refit or rebuild operations have completed.
604        ///
605        ///
606        /// Parameter `coder`: An archiver object
607        ///
608        /// # Safety
609        ///
610        /// `coder` possibly has further requirements.
611        #[deprecated]
612        #[unsafe(method(encodeWithCoder:))]
613        #[unsafe(method_family = none)]
614        pub unsafe fn encodeWithCoder(&self, coder: &NSCoder);
615    );
616}
617
618/// Methods declared on superclass `MPSKernel`.
619#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
620impl MPSAccelerationStructure {
621    extern_methods!(
622        /// Called by NSCoder to decode MPSKernels
623        ///
624        /// This isn't the right interface to decode a MPSKernel, but
625        /// it is the one that NSCoder uses. To enable your NSCoder
626        /// (e.g. NSKeyedUnarchiver) to set which device to use
627        /// extend the object to adopt the MPSDeviceProvider
628        /// protocol. Otherwise, the Metal system default device
629        /// will be used.
630        ///
631        /// # Safety
632        ///
633        /// `a_decoder` possibly has further requirements.
634        #[unsafe(method(initWithCoder:))]
635        #[unsafe(method_family = init)]
636        pub unsafe fn initWithCoder(
637            this: Allocated<Self>,
638            a_decoder: &NSCoder,
639        ) -> Option<Retained<Self>>;
640    );
641}
642
643/// Methods declared on superclass `NSObject`.
644#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
645impl MPSAccelerationStructure {
646    extern_methods!(
647        #[unsafe(method(new))]
648        #[unsafe(method_family = new)]
649        pub unsafe fn new() -> Retained<Self>;
650    );
651}