objc2_metal/generated/
MTLIntersectionFunctionTable.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::*;
7
8use crate::*;
9
10/// struct containing arguments for intersection function buffers.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlintersectionfunctionbufferarguments?language=objc)
13#[repr(C)]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub struct MTLIntersectionFunctionBufferArguments {
16    /// The GPU resource ID of the buffer containing intersection-function handles.
17    /// Required to be aligned to 8 bytes.
18    pub intersectionFunctionBuffer: u64,
19    /// The maximum range in bytes of intersectionFunctionBuffer that can be used
20    /// for ray tracing.
21    pub intersectionFunctionBufferSize: u64,
22    /// The stride between intersection function entries in intersectionFunctionBuffer.
23    /// The stride needs to be either 0 or aligned to 8 bytes. Note that only the first 12
24    /// bits of this value are used by Metal.
25    pub intersectionFunctionStride: u64,
26}
27
28unsafe impl Encode for MTLIntersectionFunctionBufferArguments {
29    const ENCODING: Encoding =
30        Encoding::Struct("?", &[<u64>::ENCODING, <u64>::ENCODING, <u64>::ENCODING]);
31}
32
33unsafe impl RefEncode for MTLIntersectionFunctionBufferArguments {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37/// Signature defining what data is provided to an intersection function. The signature
38/// must match across the shading language declaration of the intersection function table,
39/// intersection functions in the table, and the intersector using the table.
40///
41/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlintersectionfunctionsignature?language=objc)
42// NS_OPTIONS
43#[repr(transparent)]
44#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
45pub struct MTLIntersectionFunctionSignature(pub NSUInteger);
46bitflags::bitflags! {
47    impl MTLIntersectionFunctionSignature: NSUInteger {
48/// No signature
49        #[doc(alias = "MTLIntersectionFunctionSignatureNone")]
50        const None = 0;
51/// The intersection functions can read the built-in instance_id as described in
52/// the Metal Shading Language Guide.
53        #[doc(alias = "MTLIntersectionFunctionSignatureInstancing")]
54        const Instancing = 1<<0;
55/// The triangle intersection functions can read the built-in barycentric_coord
56/// and front_facing as described in the Metal Shading Language Guide.
57        #[doc(alias = "MTLIntersectionFunctionSignatureTriangleData")]
58        const TriangleData = 1<<1;
59/// The intersection functions can query world_space_origin and
60/// world_space_direction as described in the Metal Shading Language Guide.
61        #[doc(alias = "MTLIntersectionFunctionSignatureWorldSpaceData")]
62        const WorldSpaceData = 1<<2;
63/// The intersection functions may be called from intersectors using the
64/// instance_motion intersection tag as described in the Metal Shading Language Guide.
65        #[doc(alias = "MTLIntersectionFunctionSignatureInstanceMotion")]
66        const InstanceMotion = 1<<3;
67/// The intersection functions can query time, motion_start_time,
68/// motion_end_time and key_frame_count as described in the Metal Shading Language Guide.
69        #[doc(alias = "MTLIntersectionFunctionSignaturePrimitiveMotion")]
70        const PrimitiveMotion = 1<<4;
71/// The intersection functions may be called from intersectors using the
72/// extended_limits intersection tag as described in the Metal Shading Language Guide.
73        #[doc(alias = "MTLIntersectionFunctionSignatureExtendedLimits")]
74        const ExtendedLimits = 1<<5;
75/// The intersection functions may be called from intersectors using the
76/// max_levels intersection tag as described in the Metal Shading Language Guide.
77        #[doc(alias = "MTLIntersectionFunctionSignatureMaxLevels")]
78        const MaxLevels = 1<<6;
79/// The curve intersection functions can read the built-in curve_parameter
80/// as described in the Metal Shading Language Guide.
81        #[doc(alias = "MTLIntersectionFunctionSignatureCurveData")]
82        const CurveData = 1<<7;
83/// The intersection function will be used with intersection function buffers
84        #[doc(alias = "MTLIntersectionFunctionSignatureIntersectionFunctionBuffer")]
85        const IntersectionFunctionBuffer = 1<<8;
86/// The intersection function uses the intersection function buffer user_data pointer
87        #[doc(alias = "MTLIntersectionFunctionSignatureUserData")]
88        const UserData = 1<<9;
89    }
90}
91
92unsafe impl Encode for MTLIntersectionFunctionSignature {
93    const ENCODING: Encoding = NSUInteger::ENCODING;
94}
95
96unsafe impl RefEncode for MTLIntersectionFunctionSignature {
97    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
98}
99
100extern_class!(
101    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlintersectionfunctiontabledescriptor?language=objc)
102    #[unsafe(super(NSObject))]
103    #[derive(Debug, PartialEq, Eq, Hash)]
104    pub struct MTLIntersectionFunctionTableDescriptor;
105);
106
107extern_conformance!(
108    unsafe impl NSCopying for MTLIntersectionFunctionTableDescriptor {}
109);
110
111unsafe impl CopyingHelper for MTLIntersectionFunctionTableDescriptor {
112    type Result = Self;
113}
114
115extern_conformance!(
116    unsafe impl NSObjectProtocol for MTLIntersectionFunctionTableDescriptor {}
117);
118
119impl MTLIntersectionFunctionTableDescriptor {
120    extern_methods!(
121        /// Create an autoreleased intersection function table descriptor
122        #[unsafe(method(intersectionFunctionTableDescriptor))]
123        #[unsafe(method_family = none)]
124        pub fn intersectionFunctionTableDescriptor(
125        ) -> Retained<MTLIntersectionFunctionTableDescriptor>;
126
127        /// The number of functions in the table.
128        #[unsafe(method(functionCount))]
129        #[unsafe(method_family = none)]
130        pub fn functionCount(&self) -> NSUInteger;
131
132        /// Setter for [`functionCount`][Self::functionCount].
133        #[unsafe(method(setFunctionCount:))]
134        #[unsafe(method_family = none)]
135        pub fn setFunctionCount(&self, function_count: NSUInteger);
136    );
137}
138
139/// Methods declared on superclass `NSObject`.
140impl MTLIntersectionFunctionTableDescriptor {
141    extern_methods!(
142        #[unsafe(method(init))]
143        #[unsafe(method_family = init)]
144        pub fn init(this: Allocated<Self>) -> Retained<Self>;
145
146        #[unsafe(method(new))]
147        #[unsafe(method_family = new)]
148        pub fn new() -> Retained<Self>;
149    );
150}
151
152impl DefaultRetained for MTLIntersectionFunctionTableDescriptor {
153    #[inline]
154    fn default_retained() -> Retained<Self> {
155        Self::new()
156    }
157}
158
159extern_protocol!(
160    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlintersectionfunctiontable?language=objc)
161    #[cfg(all(feature = "MTLAllocation", feature = "MTLResource"))]
162    pub unsafe trait MTLIntersectionFunctionTable: MTLResource {
163        #[cfg(feature = "MTLBuffer")]
164        /// # Safety
165        ///
166        /// - `buffer` may need to be synchronized.
167        /// - `buffer` may be unretained, you must ensure it is kept alive while in use.
168        /// - `buffer` contents should be of the correct type.
169        /// - `offset` might not be bounds-checked.
170        /// - `index` might not be bounds-checked.
171        #[unsafe(method(setBuffer:offset:atIndex:))]
172        #[unsafe(method_family = none)]
173        unsafe fn setBuffer_offset_atIndex(
174            &self,
175            buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
176            offset: NSUInteger,
177            index: NSUInteger,
178        );
179
180        #[cfg(feature = "MTLBuffer")]
181        /// # Safety
182        ///
183        /// - `buffers` must be a valid pointer.
184        /// - `offsets` might not be bounds-checked.
185        /// - `offsets` must be a valid pointer.
186        /// - `range` might not be bounds-checked.
187        #[unsafe(method(setBuffers:offsets:withRange:))]
188        #[unsafe(method_family = none)]
189        unsafe fn setBuffers_offsets_withRange(
190            &self,
191            buffers: NonNull<*const ProtocolObject<dyn MTLBuffer>>,
192            offsets: NonNull<NSUInteger>,
193            range: NSRange,
194        );
195
196        #[cfg(feature = "MTLTypes")]
197        /// Handle of the GPU resource suitable for storing in an Argument Buffer
198        #[unsafe(method(gpuResourceID))]
199        #[unsafe(method_family = none)]
200        fn gpuResourceID(&self) -> MTLResourceID;
201
202        #[cfg(feature = "MTLFunctionHandle")]
203        #[unsafe(method(setFunction:atIndex:))]
204        #[unsafe(method_family = none)]
205        fn setFunction_atIndex(
206            &self,
207            function: Option<&ProtocolObject<dyn MTLFunctionHandle>>,
208            index: NSUInteger,
209        );
210
211        #[cfg(feature = "MTLFunctionHandle")]
212        /// # Safety
213        ///
214        /// - `functions` must be a valid pointer.
215        /// - `range` might not be bounds-checked.
216        #[unsafe(method(setFunctions:withRange:))]
217        #[unsafe(method_family = none)]
218        unsafe fn setFunctions_withRange(
219            &self,
220            functions: NonNull<*const ProtocolObject<dyn MTLFunctionHandle>>,
221            range: NSRange,
222        );
223
224        /// # Safety
225        ///
226        /// `index` might not be bounds-checked.
227        #[unsafe(method(setOpaqueTriangleIntersectionFunctionWithSignature:atIndex:))]
228        #[unsafe(method_family = none)]
229        unsafe fn setOpaqueTriangleIntersectionFunctionWithSignature_atIndex(
230            &self,
231            signature: MTLIntersectionFunctionSignature,
232            index: NSUInteger,
233        );
234
235        /// # Safety
236        ///
237        /// `range` might not be bounds-checked.
238        #[unsafe(method(setOpaqueTriangleIntersectionFunctionWithSignature:withRange:))]
239        #[unsafe(method_family = none)]
240        unsafe fn setOpaqueTriangleIntersectionFunctionWithSignature_withRange(
241            &self,
242            signature: MTLIntersectionFunctionSignature,
243            range: NSRange,
244        );
245
246        /// # Safety
247        ///
248        /// `index` might not be bounds-checked.
249        #[unsafe(method(setOpaqueCurveIntersectionFunctionWithSignature:atIndex:))]
250        #[unsafe(method_family = none)]
251        unsafe fn setOpaqueCurveIntersectionFunctionWithSignature_atIndex(
252            &self,
253            signature: MTLIntersectionFunctionSignature,
254            index: NSUInteger,
255        );
256
257        /// # Safety
258        ///
259        /// `range` might not be bounds-checked.
260        #[unsafe(method(setOpaqueCurveIntersectionFunctionWithSignature:withRange:))]
261        #[unsafe(method_family = none)]
262        unsafe fn setOpaqueCurveIntersectionFunctionWithSignature_withRange(
263            &self,
264            signature: MTLIntersectionFunctionSignature,
265            range: NSRange,
266        );
267
268        #[cfg(feature = "MTLVisibleFunctionTable")]
269        /// # Safety
270        ///
271        /// - `function_table` may need to be synchronized.
272        /// - `function_table` may be unretained, you must ensure it is kept alive while in use.
273        /// - `bufferIndex` might not be bounds-checked.
274        #[unsafe(method(setVisibleFunctionTable:atBufferIndex:))]
275        #[unsafe(method_family = none)]
276        unsafe fn setVisibleFunctionTable_atBufferIndex(
277            &self,
278            function_table: Option<&ProtocolObject<dyn MTLVisibleFunctionTable>>,
279            buffer_index: NSUInteger,
280        );
281
282        #[cfg(feature = "MTLVisibleFunctionTable")]
283        /// # Safety
284        ///
285        /// - `function_tables` must be a valid pointer.
286        /// - `bufferRange` might not be bounds-checked.
287        #[unsafe(method(setVisibleFunctionTables:withBufferRange:))]
288        #[unsafe(method_family = none)]
289        unsafe fn setVisibleFunctionTables_withBufferRange(
290            &self,
291            function_tables: NonNull<*const ProtocolObject<dyn MTLVisibleFunctionTable>>,
292            buffer_range: NSRange,
293        );
294    }
295);