1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
use objc2::{
extern_class, extern_conformance, extern_methods, msg_send,
rc::{Allocated, Retained},
};
use objc2_foundation::{CopyingHelper, NSCopying, NSObject, NSObjectProtocol, NSString, NSUInteger};
use crate::*;
extern_class!(
/// Base class for all Metal 4 acceleration structure geometry descriptors.
///
/// Don't use this class directly. Use one of the derived classes instead.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4accelerationstructuregeometrydescriptor?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTL4AccelerationStructureGeometryDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTL4AccelerationStructureGeometryDescriptor {}
);
unsafe impl CopyingHelper for MTL4AccelerationStructureGeometryDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTL4AccelerationStructureGeometryDescriptor {}
);
impl MTL4AccelerationStructureGeometryDescriptor {
extern_methods!(
/// Sets the offset that this geometry contributes to determining the intersection function to invoke when a ray intersects it.
///
/// When you perform a ray tracing operation in the Metal Shading Language, and provide the ray intersector object
/// with an instance of ``MTLIntersectionFunctionTable``, Metal adds this offset to the instance offset from structs such
/// as:
///
/// - ``MTLAccelerationStructureInstanceDescriptor``
/// - ``MTLAccelerationStructureUserIDInstanceDescriptor``
/// - ``MTLAccelerationStructureMotionInstanceDescriptor``
/// - ``MTLIndirectAccelerationStructureInstanceDescriptor``
/// - ``MTLIndirectAccelerationStructureMotionInstanceDescriptor``
///
/// The sum of these offsets provides an index into the intersection function table that the ray tracing system uses
/// to retrieve and invoke the function at this index, allowing you to customize the intersection evaluation process.
#[unsafe(method(intersectionFunctionTableOffset))]
#[unsafe(method_family = none)]
pub fn intersection_function_table_offset(&self) -> NSUInteger;
/// Setter for [`intersectionFunctionTableOffset`][Self::intersectionFunctionTableOffset].
#[unsafe(method(setIntersectionFunctionTableOffset:))]
#[unsafe(method_family = none)]
pub fn set_intersection_function_table_offset(
&self,
intersection_function_table_offset: NSUInteger,
);
/// Provides a hint to Metal that this geometry is opaque, potentially accelerating the ray/primitive intersection process.
#[unsafe(method(opaque))]
#[unsafe(method_family = none)]
pub fn opaque(&self) -> bool;
/// Setter for [`opaque`][Self::opaque].
#[unsafe(method(setOpaque:))]
#[unsafe(method_family = none)]
pub fn set_opaque(
&self,
opaque: bool,
);
/// A boolean value that indicates whether the ray-tracing system in Metal allows the invocation of intersection functions
/// more than once per ray-primitive intersection.
///
/// The property's default value is
/// <doc
/// ://com.apple.documentation/documentation/swift/true>.
#[unsafe(method(allowDuplicateIntersectionFunctionInvocation))]
#[unsafe(method_family = none)]
pub fn allow_duplicate_intersection_function_invocation(&self) -> bool;
/// Setter for [`allowDuplicateIntersectionFunctionInvocation`][Self::allowDuplicateIntersectionFunctionInvocation].
#[unsafe(method(setAllowDuplicateIntersectionFunctionInvocation:))]
#[unsafe(method_family = none)]
pub fn set_allow_duplicate_intersection_function_invocation(
&self,
allow_duplicate_intersection_function_invocation: bool,
);
/// Assigns optional buffer containing data to associate with each primitive in this geometry.
///
/// You can use zero as the buffer address in this buffer range.
#[unsafe(method(primitiveDataBuffer))]
#[unsafe(method_family = none)]
pub fn primitive_data_buffer(&self) -> MTL4BufferRange;
/// Setter for [`primitiveDataBuffer`][Self::primitiveDataBuffer].
#[unsafe(method(setPrimitiveDataBuffer:))]
#[unsafe(method_family = none)]
pub fn set_primitive_data_buffer(
&self,
primitive_data_buffer: MTL4BufferRange,
);
/// Defines the stride, in bytes, between each primitive's data in the primitive data buffer ``primitiveDataBuffer`` references.
///
/// You are responsible for ensuring the stride is at least ``primitiveDataElementSize`` in size and a multiple of 4 bytes.
///
/// This property defaults to `0` bytes, which indicates the stride is equal to ``primitiveDataElementSize``.
#[unsafe(method(primitiveDataStride))]
#[unsafe(method_family = none)]
pub fn primitive_data_stride(&self) -> NSUInteger;
/// Setter for [`primitiveDataStride`][Self::primitiveDataStride].
#[unsafe(method(setPrimitiveDataStride:))]
#[unsafe(method_family = none)]
pub fn set_primitive_data_stride(
&self,
primitive_data_stride: NSUInteger,
);
/// Sets the size, in bytes, of the data for each primitive in the primitive data buffer ``primitiveDataBuffer`` references.
///
/// This size needs to be at most ``primitiveDataStride`` in size and a multiple of 4 bytes.
///
/// This property defaults to 0 bytes.
#[unsafe(method(primitiveDataElementSize))]
#[unsafe(method_family = none)]
pub fn primitive_data_element_size(&self) -> NSUInteger;
/// Setter for [`primitiveDataElementSize`][Self::primitiveDataElementSize].
#[unsafe(method(setPrimitiveDataElementSize:))]
#[unsafe(method_family = none)]
pub fn set_primitive_data_element_size(
&self,
primitive_data_element_size: NSUInteger,
);
);
}
/// Methods declared on superclass `NSObject`.
impl MTL4AccelerationStructureGeometryDescriptor {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl MTL4AccelerationStructureGeometryDescriptor {
/// Assigns an optional label you can assign to this geometry for debugging purposes.
pub fn label(&self) -> Option<String> {
let label: Option<Retained<NSString>> = unsafe { msg_send![self, label] };
label.map(|s| s.to_string())
}
/// Setter for label.
pub fn set_label(
&self,
label: Option<&str>,
) {
unsafe {
let _: () = msg_send![self, setLabel: label.map(NSString::from_str).as_deref()];
}
}
}