objc2_metal_performance_shaders/generated/MPSRayIntersector/MPSPolygonAccelerationStructure.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/// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpspolygontype?language=objc)
12// NS_ENUM
13#[deprecated]
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct MPSPolygonType(pub NSUInteger);
17impl MPSPolygonType {
18 /// Triangles with three vertices
19 #[doc(alias = "MPSPolygonTypeTriangle")]
20 #[deprecated]
21 pub const Triangle: Self = Self(0);
22 /// Quadrilaterals with four vertices
23 #[doc(alias = "MPSPolygonTypeQuadrilateral")]
24 #[deprecated]
25 pub const Quadrilateral: Self = Self(1);
26}
27
28unsafe impl Encode for MPSPolygonType {
29 const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for MPSPolygonType {
33 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_class!(
37 /// An acceleration structure built over polygonal shapes
38 ///
39 ///
40 /// See MPSAccelerationStructure for more information
41 ///
42 /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpspolygonaccelerationstructure?language=objc)
43 #[unsafe(super(MPSAccelerationStructure, MPSKernel, NSObject))]
44 #[derive(Debug, PartialEq, Eq, Hash)]
45 #[cfg(all(
46 feature = "MPSAccelerationStructure",
47 feature = "MPSCore",
48 feature = "MPSKernel"
49 ))]
50 #[deprecated]
51 pub struct MPSPolygonAccelerationStructure;
52);
53
54#[cfg(all(
55 feature = "MPSAccelerationStructure",
56 feature = "MPSCore",
57 feature = "MPSKernel"
58))]
59extern_conformance!(
60 unsafe impl NSCoding for MPSPolygonAccelerationStructure {}
61);
62
63#[cfg(all(
64 feature = "MPSAccelerationStructure",
65 feature = "MPSCore",
66 feature = "MPSKernel"
67))]
68extern_conformance!(
69 unsafe impl NSCopying for MPSPolygonAccelerationStructure {}
70);
71
72#[cfg(all(
73 feature = "MPSAccelerationStructure",
74 feature = "MPSCore",
75 feature = "MPSKernel"
76))]
77unsafe impl CopyingHelper for MPSPolygonAccelerationStructure {
78 type Result = Self;
79}
80
81#[cfg(all(
82 feature = "MPSAccelerationStructure",
83 feature = "MPSCore",
84 feature = "MPSKernel"
85))]
86extern_conformance!(
87 unsafe impl NSObjectProtocol for MPSPolygonAccelerationStructure {}
88);
89
90#[cfg(all(
91 feature = "MPSAccelerationStructure",
92 feature = "MPSCore",
93 feature = "MPSKernel"
94))]
95extern_conformance!(
96 unsafe impl NSSecureCoding for MPSPolygonAccelerationStructure {}
97);
98
99#[cfg(all(
100 feature = "MPSAccelerationStructure",
101 feature = "MPSCore",
102 feature = "MPSKernel"
103))]
104impl MPSPolygonAccelerationStructure {
105 extern_methods!(
106 /// The type of polygon. Defaults to MPSPolygonTypeTriangle. Changes to this property require
107 /// rebuilding the acceleration structure.
108 #[deprecated]
109 #[unsafe(method(polygonType))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn polygonType(&self) -> MPSPolygonType;
112
113 /// Setter for [`polygonType`][Self::polygonType].
114 #[deprecated]
115 #[unsafe(method(setPolygonType:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn setPolygonType(&self, polygon_type: MPSPolygonType);
118
119 /// Offset, in bytes, between consecutive vertices in the vertex buffer. Defaults to 0 bytes,
120 /// indicating that the vertices are packed according to the natural alignment of the vector_float3
121 /// type: 16 bytes.
122 ///
123 ///
124 /// This can be used to skip past any additional per-vertex data which may be stored
125 /// alongside the position such as the vertex normal and texture coordinates. Must be a multiple of
126 /// 4 bytes, and must be at least 12 bytes. Changes to this property require rebuilding the
127 /// acceleration structure.
128 #[deprecated]
129 #[unsafe(method(vertexStride))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn vertexStride(&self) -> NSUInteger;
132
133 /// Setter for [`vertexStride`][Self::vertexStride].
134 #[deprecated]
135 #[unsafe(method(setVertexStride:))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn setVertexStride(&self, vertex_stride: NSUInteger);
138
139 #[cfg(feature = "MPSCoreTypes")]
140 /// Index type. Defaults to MPSDataTypeUInt32. Only MPSDataTypeUInt16 and MPSDataTypeUInt32
141 /// are supported.
142 #[deprecated]
143 #[unsafe(method(indexType))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn indexType(&self) -> MPSDataType;
146
147 #[cfg(feature = "MPSCoreTypes")]
148 /// Setter for [`indexType`][Self::indexType].
149 #[deprecated]
150 #[unsafe(method(setIndexType:))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn setIndexType(&self, index_type: MPSDataType);
153
154 /// Vertex buffer containing vertex data encoded as three 32 bit floats per vertex. Note
155 /// that by default each vertex is aligned to the alignment of the vector_float3 type: 16 bytes.
156 /// This can be changed using the vertexStride property. A vertex buffer must be provided before
157 /// the acceleration structure is built.
158 ///
159 /// When using triangle polygons, degenerate (zero or negative area) triangles are ignored
160 /// during acceleration structure construction. This can be used to pad triangle indices if needed.
161 ///
162 /// Quadrilateral polygons are internally treated as two triangles. If the quadrilateral has
163 /// vertices v0, v1, v2, and v3, the two triangles will have vertices v0, v1, v2 and v0, v2, v3.
164 /// A quadrilateral may be used to represent a triangle by repeating the last vertex. If the first
165 /// triangle is degenerate (zero or negative area), the entire quadrilateral will be ignored. This
166 /// can be used to pad quadrilateral indices if needed. All four vertices of a quadrilateral must
167 /// be coplanar and the quadrilateral must be convex.
168 ///
169 /// This is an alias for polygonBuffers[0].vertexBuffer. There must be exactly one polygon buffer
170 /// to use this property, or the polygonBuffers property must be nil, in which case an
171 /// MPSPolygonBuffer will be created automatically.
172 #[deprecated]
173 #[unsafe(method(vertexBuffer))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn vertexBuffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
176
177 /// Setter for [`vertexBuffer`][Self::vertexBuffer].
178 ///
179 /// # Safety
180 ///
181 /// - `vertex_buffer` may need to be synchronized.
182 /// - `vertex_buffer` may be unretained, you must ensure it is kept alive while in use.
183 /// - `vertex_buffer` contents should be of the correct type.
184 #[deprecated]
185 #[unsafe(method(setVertexBuffer:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn setVertexBuffer(&self, vertex_buffer: Option<&ProtocolObject<dyn MTLBuffer>>);
188
189 /// Offset, in bytes, into the vertex buffer. Defaults to 0 bytes. Must be aligned to 4
190 /// bytes.
191 ///
192 /// This is an alias for polygonBuffers[0].vertexBufferOffset. There must be exactly one polygon
193 /// buffer to use this property, or the polygonBuffers property must be nil, in which case an
194 /// MPSPolygonBuffer will be created automatically.
195 #[deprecated]
196 #[unsafe(method(vertexBufferOffset))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn vertexBufferOffset(&self) -> NSUInteger;
199
200 /// Setter for [`vertexBufferOffset`][Self::vertexBufferOffset].
201 #[deprecated]
202 #[unsafe(method(setVertexBufferOffset:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn setVertexBufferOffset(&self, vertex_buffer_offset: NSUInteger);
205
206 /// Index buffer containing index data. Each index references a vertex in the vertex buffer.
207 /// May be nil.
208 ///
209 /// This is an alias for polygonBuffers[0].indexBuffer. There must be exactly one polygon buffer
210 /// to use this property, or the polygonBuffers property must be nil, in which case an
211 /// MPSPolygonBuffer will be created automatically.
212 #[deprecated]
213 #[unsafe(method(indexBuffer))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn indexBuffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
216
217 /// Setter for [`indexBuffer`][Self::indexBuffer].
218 ///
219 /// # Safety
220 ///
221 /// - `index_buffer` may need to be synchronized.
222 /// - `index_buffer` may be unretained, you must ensure it is kept alive while in use.
223 /// - `index_buffer` contents should be of the correct type.
224 #[deprecated]
225 #[unsafe(method(setIndexBuffer:))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn setIndexBuffer(&self, index_buffer: Option<&ProtocolObject<dyn MTLBuffer>>);
228
229 /// Offset, in bytes, into the index buffer. Defaults to 0 bytes. Must be aligned to a
230 /// multiple of the index type. Changes to this property require rebuilding the acceleration
231 /// structure.
232 ///
233 /// This is an alias for polygonBuffers[0].indexBufferOffset. There must be exactly one polygon
234 /// buffer to use this property, or the polygonBuffers property must be nil, in which case an
235 /// MPSPolygonBuffer will be created automatically.
236 #[deprecated]
237 #[unsafe(method(indexBufferOffset))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn indexBufferOffset(&self) -> NSUInteger;
240
241 /// Setter for [`indexBufferOffset`][Self::indexBufferOffset].
242 #[deprecated]
243 #[unsafe(method(setIndexBufferOffset:))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn setIndexBufferOffset(&self, index_buffer_offset: NSUInteger);
246
247 /// Mask buffer containing one uint32_t mask per polygon. May be nil. Otherwise, the mask
248 /// type must be specified on the MPSRayIntersector with which it is used.
249 ///
250 /// This is an alias for polygonBuffers[0].maskBuffer. There must be exactly one polygon buffer
251 /// to use this property, or the polygonBuffers property must be nil, in which case an
252 /// MPSPolygonBuffer will be created automatically.
253 #[deprecated]
254 #[unsafe(method(maskBuffer))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn maskBuffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
257
258 /// Setter for [`maskBuffer`][Self::maskBuffer].
259 ///
260 /// # Safety
261 ///
262 /// - `mask_buffer` may need to be synchronized.
263 /// - `mask_buffer` may be unretained, you must ensure it is kept alive while in use.
264 /// - `mask_buffer` contents should be of the correct type.
265 #[deprecated]
266 #[unsafe(method(setMaskBuffer:))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn setMaskBuffer(&self, mask_buffer: Option<&ProtocolObject<dyn MTLBuffer>>);
269
270 /// Offset, in bytes, into the mask buffer. Defaults to 0 bytes. Must be aligned to 4 bytes.
271 ///
272 /// This is an alias for polygonBuffers[0].maskBufferOffset. There must be exactly one polygon
273 /// buffer to use this property, or the polygonBuffers property must be nil, in which case an
274 /// MPSPolygonBuffer will be created automatically.
275 #[deprecated]
276 #[unsafe(method(maskBufferOffset))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn maskBufferOffset(&self) -> NSUInteger;
279
280 /// Setter for [`maskBufferOffset`][Self::maskBufferOffset].
281 #[deprecated]
282 #[unsafe(method(setMaskBufferOffset:))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn setMaskBufferOffset(&self, mask_buffer_offset: NSUInteger);
285
286 /// Number of polygons. Changes to this property require rebuilding the acceleration
287 /// structure.
288 ///
289 /// This is an alias for polygonBuffers[0].polygonCount. There must be exactly one polygon buffer
290 /// to use this property, or the polygonBuffers property must be nil, in which case an
291 /// MPSPolygonBuffer will be created automatically.
292 #[deprecated]
293 #[unsafe(method(polygonCount))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn polygonCount(&self) -> NSUInteger;
296
297 /// Setter for [`polygonCount`][Self::polygonCount].
298 #[deprecated]
299 #[unsafe(method(setPolygonCount:))]
300 #[unsafe(method_family = none)]
301 pub unsafe fn setPolygonCount(&self, polygon_count: NSUInteger);
302
303 #[cfg(feature = "MPSPolygonBuffer")]
304 /// Array of polygon buffers. Each buffer contains a vertex buffer and optional index and
305 /// mask buffer for an array of polygons. Changing the length of this array requires rebuilding the
306 /// acceleration structure.
307 ///
308 /// Using more than one MPSPolygonBuffer will reduce performance. It is better to concatenate
309 /// these buffers into a single vertex buffer, index buffer, and mask buffer and use a single
310 /// MPSPolygonBuffer if possible. This also applies when using an MPSInstanceAccelerationStructure:
311 /// each instance or subclass of MPSPolygonAccelerationStructure in an instance hierarchy should use
312 /// the same vertex buffer, index buffer, and mask buffer, although each acceleration structure
313 /// may use different offsets into these buffers. This allows for the vertex, index, and mask
314 /// buffers to be bound directly instead of indirectly through an argument buffer.
315 ///
316 /// There must be at least one MPSPolygonBuffer. On argument buffer tier 1 devices, there must be
317 /// be exactly one MPSPolygonBuffer. Use the argumentBuffersSupport property of the MTLDevice to
318 /// check for support.
319 #[deprecated]
320 #[unsafe(method(polygonBuffers))]
321 #[unsafe(method_family = none)]
322 pub unsafe fn polygonBuffers(&self) -> Option<Retained<NSArray<MPSPolygonBuffer>>>;
323
324 #[cfg(feature = "MPSPolygonBuffer")]
325 /// Setter for [`polygonBuffers`][Self::polygonBuffers].
326 #[deprecated]
327 #[unsafe(method(setPolygonBuffers:))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn setPolygonBuffers(&self, polygon_buffers: Option<&NSArray<MPSPolygonBuffer>>);
330 );
331}
332
333/// Methods declared on superclass `MPSAccelerationStructure`.
334#[cfg(all(
335 feature = "MPSAccelerationStructure",
336 feature = "MPSCore",
337 feature = "MPSKernel"
338))]
339impl MPSPolygonAccelerationStructure {
340 extern_methods!(
341 #[deprecated]
342 #[unsafe(method(init))]
343 #[unsafe(method_family = init)]
344 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
345
346 /// Initialize the acceleration structure with a Metal device
347 #[deprecated]
348 #[unsafe(method(initWithDevice:))]
349 #[unsafe(method_family = init)]
350 pub unsafe fn initWithDevice(
351 this: Allocated<Self>,
352 device: &ProtocolObject<dyn MTLDevice>,
353 ) -> Retained<Self>;
354
355 /// Initialize the acceleration structure with an NSCoder and a Metal device. Buffer
356 /// properties such as the vertex buffer, instance buffer, etc. are set to nil. Encode and decode
357 /// these buffers along with the acceleration structure instead.
358 ///
359 /// # Safety
360 ///
361 /// `a_decoder` possibly has further requirements.
362 #[deprecated]
363 #[unsafe(method(initWithCoder:device:))]
364 #[unsafe(method_family = init)]
365 pub unsafe fn initWithCoder_device(
366 this: Allocated<Self>,
367 a_decoder: &NSCoder,
368 device: &ProtocolObject<dyn MTLDevice>,
369 ) -> Option<Retained<Self>>;
370
371 #[cfg(feature = "MPSAccelerationStructureGroup")]
372 /// Initialize the acceleration structure with an acceleration structure group, if the
373 /// acceleration structure will be used in an instance hierarchy.
374 ///
375 ///
376 /// The Metal device is determined from the acceleration structure group. All
377 /// acceleration structures in the instance hierarchy must share the same group.
378 #[deprecated]
379 #[unsafe(method(initWithGroup:))]
380 #[unsafe(method_family = init)]
381 pub unsafe fn initWithGroup(
382 this: Allocated<Self>,
383 group: &MPSAccelerationStructureGroup,
384 ) -> Retained<Self>;
385
386 #[cfg(feature = "MPSAccelerationStructureGroup")]
387 /// Initialize the acceleration structure with an NSCoder and an acceleration structure
388 /// group, if the acceleration structure will be used in an instance hierarchy. All acceleration
389 /// structures in the instance hierarchy must share the same group. Buffer properties such as the
390 /// vertex buffer, instance buffer, etc. are set to nil. Encode and decode these buffers along with
391 /// the acceleration structure instead.
392 ///
393 /// # Safety
394 ///
395 /// `a_decoder` possibly has further requirements.
396 #[deprecated]
397 #[unsafe(method(initWithCoder:group:))]
398 #[unsafe(method_family = init)]
399 pub unsafe fn initWithCoder_group(
400 this: Allocated<Self>,
401 a_decoder: &NSCoder,
402 group: &MPSAccelerationStructureGroup,
403 ) -> Option<Retained<Self>>;
404 );
405}
406
407/// Methods declared on superclass `MPSKernel`.
408#[cfg(all(
409 feature = "MPSAccelerationStructure",
410 feature = "MPSCore",
411 feature = "MPSKernel"
412))]
413impl MPSPolygonAccelerationStructure {
414 extern_methods!(
415 /// Called by NSCoder to decode MPSKernels
416 ///
417 /// This isn't the right interface to decode a MPSKernel, but
418 /// it is the one that NSCoder uses. To enable your NSCoder
419 /// (e.g. NSKeyedUnarchiver) to set which device to use
420 /// extend the object to adopt the MPSDeviceProvider
421 /// protocol. Otherwise, the Metal system default device
422 /// will be used.
423 ///
424 /// # Safety
425 ///
426 /// `a_decoder` possibly has further requirements.
427 #[unsafe(method(initWithCoder:))]
428 #[unsafe(method_family = init)]
429 pub unsafe fn initWithCoder(
430 this: Allocated<Self>,
431 a_decoder: &NSCoder,
432 ) -> Option<Retained<Self>>;
433 );
434}
435
436/// Methods declared on superclass `NSObject`.
437#[cfg(all(
438 feature = "MPSAccelerationStructure",
439 feature = "MPSCore",
440 feature = "MPSKernel"
441))]
442impl MPSPolygonAccelerationStructure {
443 extern_methods!(
444 #[unsafe(method(new))]
445 #[unsafe(method_family = new)]
446 pub unsafe fn new() -> Retained<Self>;
447 );
448}