objc2_metal/generated/
MTLArgumentEncoder.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/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlattributestridestatic?language=objc)
11pub static MTLAttributeStrideStatic: NSUInteger = NSUIntegerMax as _;
12
13extern_protocol!(
14    /// MTLArgumentEncoder encodes buffer, texture, sampler, and constant data into a buffer.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlargumentencoder?language=objc)
17    pub unsafe trait MTLArgumentEncoder: NSObjectProtocol {
18        #[cfg(feature = "MTLDevice")]
19        /// The device this argument encoder was created against.
20        #[unsafe(method(device))]
21        #[unsafe(method_family = none)]
22        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
23
24        /// A string to help identify this object.
25        #[unsafe(method(label))]
26        #[unsafe(method_family = none)]
27        fn label(&self) -> Option<Retained<NSString>>;
28
29        /// Setter for [`label`][Self::label].
30        ///
31        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
32        #[unsafe(method(setLabel:))]
33        #[unsafe(method_family = none)]
34        fn setLabel(&self, label: Option<&NSString>);
35
36        /// The number of bytes required to store the encoded resource bindings.
37        #[unsafe(method(encodedLength))]
38        #[unsafe(method_family = none)]
39        fn encodedLength(&self) -> NSUInteger;
40
41        /// The alignment in bytes required to store the encoded resource bindings.
42        #[unsafe(method(alignment))]
43        #[unsafe(method_family = none)]
44        fn alignment(&self) -> NSUInteger;
45
46        #[cfg(all(
47            feature = "MTLAllocation",
48            feature = "MTLBuffer",
49            feature = "MTLResource"
50        ))]
51        /// Sets the destination buffer and offset at which the arguments will be encoded.
52        ///
53        /// # Safety
54        ///
55        /// - `argument_buffer` may need to be synchronized.
56        /// - `argument_buffer` may be unretained, you must ensure it is kept alive while in use.
57        /// - `argument_buffer` contents should be of the correct type.
58        /// - `offset` might not be bounds-checked.
59        #[unsafe(method(setArgumentBuffer:offset:))]
60        #[unsafe(method_family = none)]
61        unsafe fn setArgumentBuffer_offset(
62            &self,
63            argument_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
64            offset: NSUInteger,
65        );
66
67        #[cfg(all(
68            feature = "MTLAllocation",
69            feature = "MTLBuffer",
70            feature = "MTLResource"
71        ))]
72        /// Sets the destination buffer, starting offset and specific array element arguments will be encoded into. arrayElement represents
73        /// the desired element of IAB array targetted by encoding
74        ///
75        /// # Safety
76        ///
77        /// - `argument_buffer` may need to be synchronized.
78        /// - `argument_buffer` may be unretained, you must ensure it is kept alive while in use.
79        /// - `argument_buffer` contents should be of the correct type.
80        /// - `startOffset` might not be bounds-checked.
81        #[unsafe(method(setArgumentBuffer:startOffset:arrayElement:))]
82        #[unsafe(method_family = none)]
83        unsafe fn setArgumentBuffer_startOffset_arrayElement(
84            &self,
85            argument_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
86            start_offset: NSUInteger,
87            array_element: NSUInteger,
88        );
89
90        #[cfg(all(
91            feature = "MTLAllocation",
92            feature = "MTLBuffer",
93            feature = "MTLResource"
94        ))]
95        /// Set a buffer at the given bind point index.
96        ///
97        /// # Safety
98        ///
99        /// - `buffer` may need to be synchronized.
100        /// - `buffer` may be unretained, you must ensure it is kept alive while in use.
101        /// - `buffer` contents should be of the correct type.
102        /// - `offset` might not be bounds-checked.
103        /// - `index` might not be bounds-checked.
104        #[unsafe(method(setBuffer:offset:atIndex:))]
105        #[unsafe(method_family = none)]
106        unsafe fn setBuffer_offset_atIndex(
107            &self,
108            buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
109            offset: NSUInteger,
110            index: NSUInteger,
111        );
112
113        #[cfg(all(
114            feature = "MTLAllocation",
115            feature = "MTLBuffer",
116            feature = "MTLResource"
117        ))]
118        /// Set an array of buffers at the given bind point index range.
119        ///
120        /// # Safety
121        ///
122        /// - `buffers` must be a valid pointer.
123        /// - `offsets` might not be bounds-checked.
124        /// - `offsets` must be a valid pointer.
125        /// - `range` might not be bounds-checked.
126        #[unsafe(method(setBuffers:offsets:withRange:))]
127        #[unsafe(method_family = none)]
128        unsafe fn setBuffers_offsets_withRange(
129            &self,
130            buffers: NonNull<*const ProtocolObject<dyn MTLBuffer>>,
131            offsets: NonNull<NSUInteger>,
132            range: NSRange,
133        );
134
135        #[cfg(all(
136            feature = "MTLAllocation",
137            feature = "MTLResource",
138            feature = "MTLTexture"
139        ))]
140        /// Set a texture at the given bind point index.
141        ///
142        /// # Safety
143        ///
144        /// - `texture` may need to be synchronized.
145        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
146        /// - `index` might not be bounds-checked.
147        #[unsafe(method(setTexture:atIndex:))]
148        #[unsafe(method_family = none)]
149        unsafe fn setTexture_atIndex(
150            &self,
151            texture: Option<&ProtocolObject<dyn MTLTexture>>,
152            index: NSUInteger,
153        );
154
155        #[cfg(all(
156            feature = "MTLAllocation",
157            feature = "MTLResource",
158            feature = "MTLTexture"
159        ))]
160        /// Set an array of textures at the given bind point index range.
161        ///
162        /// # Safety
163        ///
164        /// - `textures` must be a valid pointer.
165        /// - `range` might not be bounds-checked.
166        #[unsafe(method(setTextures:withRange:))]
167        #[unsafe(method_family = none)]
168        unsafe fn setTextures_withRange(
169            &self,
170            textures: NonNull<*const ProtocolObject<dyn MTLTexture>>,
171            range: NSRange,
172        );
173
174        #[cfg(feature = "MTLSampler")]
175        /// Set a sampler at the given bind point index.
176        ///
177        /// # Safety
178        ///
179        /// `index` might not be bounds-checked.
180        #[unsafe(method(setSamplerState:atIndex:))]
181        #[unsafe(method_family = none)]
182        unsafe fn setSamplerState_atIndex(
183            &self,
184            sampler: Option<&ProtocolObject<dyn MTLSamplerState>>,
185            index: NSUInteger,
186        );
187
188        #[cfg(feature = "MTLSampler")]
189        /// Set an array of samplers at the given bind point index range.
190        ///
191        /// # Safety
192        ///
193        /// - `samplers` must be a valid pointer.
194        /// - `range` might not be bounds-checked.
195        #[unsafe(method(setSamplerStates:withRange:))]
196        #[unsafe(method_family = none)]
197        unsafe fn setSamplerStates_withRange(
198            &self,
199            samplers: NonNull<*const ProtocolObject<dyn MTLSamplerState>>,
200            range: NSRange,
201        );
202
203        /// Returns a pointer to the constant data at the given bind point index.
204        ///
205        /// # Safety
206        ///
207        /// `index` might not be bounds-checked.
208        #[unsafe(method(constantDataAtIndex:))]
209        #[unsafe(method_family = none)]
210        unsafe fn constantDataAtIndex(&self, index: NSUInteger) -> NonNull<c_void>;
211
212        #[cfg(all(feature = "MTLAllocation", feature = "MTLRenderPipeline"))]
213        /// Sets a render pipeline state at a given bind point index
214        ///
215        /// # Safety
216        ///
217        /// `index` might not be bounds-checked.
218        #[unsafe(method(setRenderPipelineState:atIndex:))]
219        #[unsafe(method_family = none)]
220        unsafe fn setRenderPipelineState_atIndex(
221            &self,
222            pipeline: Option<&ProtocolObject<dyn MTLRenderPipelineState>>,
223            index: NSUInteger,
224        );
225
226        #[cfg(all(feature = "MTLAllocation", feature = "MTLRenderPipeline"))]
227        /// Set an array of render pipeline states at a given bind point index range
228        ///
229        /// # Safety
230        ///
231        /// - `pipelines` must be a valid pointer.
232        /// - `range` might not be bounds-checked.
233        #[unsafe(method(setRenderPipelineStates:withRange:))]
234        #[unsafe(method_family = none)]
235        unsafe fn setRenderPipelineStates_withRange(
236            &self,
237            pipelines: NonNull<*const ProtocolObject<dyn MTLRenderPipelineState>>,
238            range: NSRange,
239        );
240
241        #[cfg(all(feature = "MTLAllocation", feature = "MTLComputePipeline"))]
242        /// Sets a compute pipeline state at a given bind point index
243        ///
244        /// # Safety
245        ///
246        /// `index` might not be bounds-checked.
247        #[unsafe(method(setComputePipelineState:atIndex:))]
248        #[unsafe(method_family = none)]
249        unsafe fn setComputePipelineState_atIndex(
250            &self,
251            pipeline: Option<&ProtocolObject<dyn MTLComputePipelineState>>,
252            index: NSUInteger,
253        );
254
255        #[cfg(all(feature = "MTLAllocation", feature = "MTLComputePipeline"))]
256        /// Set an array of compute pipeline states at a given bind point index range
257        ///
258        /// # Safety
259        ///
260        /// - `pipelines` must be a valid pointer.
261        /// - `range` might not be bounds-checked.
262        #[unsafe(method(setComputePipelineStates:withRange:))]
263        #[unsafe(method_family = none)]
264        unsafe fn setComputePipelineStates_withRange(
265            &self,
266            pipelines: NonNull<*const ProtocolObject<dyn MTLComputePipelineState>>,
267            range: NSRange,
268        );
269
270        #[cfg(all(
271            feature = "MTLAllocation",
272            feature = "MTLIndirectCommandBuffer",
273            feature = "MTLResource"
274        ))]
275        /// Sets an indirect command buffer at a given bind point index
276        ///
277        /// # Safety
278        ///
279        /// - `indirect_command_buffer` may need to be synchronized.
280        /// - `indirect_command_buffer` may be unretained, you must ensure it is kept alive while in use.
281        /// - `index` might not be bounds-checked.
282        #[unsafe(method(setIndirectCommandBuffer:atIndex:))]
283        #[unsafe(method_family = none)]
284        unsafe fn setIndirectCommandBuffer_atIndex(
285            &self,
286            indirect_command_buffer: Option<&ProtocolObject<dyn MTLIndirectCommandBuffer>>,
287            index: NSUInteger,
288        );
289
290        #[cfg(all(
291            feature = "MTLAllocation",
292            feature = "MTLIndirectCommandBuffer",
293            feature = "MTLResource"
294        ))]
295        /// Set an array of indirect command buffers at the given bind point index range.
296        ///
297        /// # Safety
298        ///
299        /// - `buffers` must be a valid pointer.
300        /// - `range` might not be bounds-checked.
301        #[unsafe(method(setIndirectCommandBuffers:withRange:))]
302        #[unsafe(method_family = none)]
303        unsafe fn setIndirectCommandBuffers_withRange(
304            &self,
305            buffers: NonNull<*const ProtocolObject<dyn MTLIndirectCommandBuffer>>,
306            range: NSRange,
307        );
308
309        #[cfg(all(
310            feature = "MTLAccelerationStructure",
311            feature = "MTLAllocation",
312            feature = "MTLResource"
313        ))]
314        /// # Safety
315        ///
316        /// - `acceleration_structure` may need to be synchronized.
317        /// - `acceleration_structure` may be unretained, you must ensure it is kept alive while in use.
318        /// - `index` might not be bounds-checked.
319        #[unsafe(method(setAccelerationStructure:atIndex:))]
320        #[unsafe(method_family = none)]
321        unsafe fn setAccelerationStructure_atIndex(
322            &self,
323            acceleration_structure: Option<&ProtocolObject<dyn MTLAccelerationStructure>>,
324            index: NSUInteger,
325        );
326
327        /// Returns a pointer to a new MTLArgumentEncoder that can be used to encode the an argument buffer
328        /// in the buffer associated with a given index.
329        /// Returns nil if the resource at the given index is not an argument buffer.
330        ///
331        /// # Safety
332        ///
333        /// `index` might not be bounds-checked.
334        #[unsafe(method(newArgumentEncoderForBufferAtIndex:))]
335        #[unsafe(method_family = new)]
336        unsafe fn newArgumentEncoderForBufferAtIndex(
337            &self,
338            index: NSUInteger,
339        ) -> Option<Retained<ProtocolObject<dyn MTLArgumentEncoder>>>;
340
341        #[cfg(all(
342            feature = "MTLAllocation",
343            feature = "MTLResource",
344            feature = "MTLVisibleFunctionTable"
345        ))]
346        /// Set a visible function table at the given buffer index
347        ///
348        /// # Safety
349        ///
350        /// - `visible_function_table` may need to be synchronized.
351        /// - `visible_function_table` may be unretained, you must ensure it is kept alive while in use.
352        /// - `index` might not be bounds-checked.
353        #[unsafe(method(setVisibleFunctionTable:atIndex:))]
354        #[unsafe(method_family = none)]
355        unsafe fn setVisibleFunctionTable_atIndex(
356            &self,
357            visible_function_table: Option<&ProtocolObject<dyn MTLVisibleFunctionTable>>,
358            index: NSUInteger,
359        );
360
361        #[cfg(all(
362            feature = "MTLAllocation",
363            feature = "MTLResource",
364            feature = "MTLVisibleFunctionTable"
365        ))]
366        /// Set visible function tables at the given buffer index range
367        ///
368        /// # Safety
369        ///
370        /// - `visible_function_tables` must be a valid pointer.
371        /// - `range` might not be bounds-checked.
372        #[unsafe(method(setVisibleFunctionTables:withRange:))]
373        #[unsafe(method_family = none)]
374        unsafe fn setVisibleFunctionTables_withRange(
375            &self,
376            visible_function_tables: NonNull<*const ProtocolObject<dyn MTLVisibleFunctionTable>>,
377            range: NSRange,
378        );
379
380        #[cfg(all(
381            feature = "MTLAllocation",
382            feature = "MTLIntersectionFunctionTable",
383            feature = "MTLResource"
384        ))]
385        /// Set an intersection function table at the given buffer index
386        ///
387        /// # Safety
388        ///
389        /// - `intersection_function_table` may need to be synchronized.
390        /// - `intersection_function_table` may be unretained, you must ensure it is kept alive while in use.
391        /// - `index` might not be bounds-checked.
392        #[unsafe(method(setIntersectionFunctionTable:atIndex:))]
393        #[unsafe(method_family = none)]
394        unsafe fn setIntersectionFunctionTable_atIndex(
395            &self,
396            intersection_function_table: Option<&ProtocolObject<dyn MTLIntersectionFunctionTable>>,
397            index: NSUInteger,
398        );
399
400        #[cfg(all(
401            feature = "MTLAllocation",
402            feature = "MTLIntersectionFunctionTable",
403            feature = "MTLResource"
404        ))]
405        /// Set intersection function tables at the given buffer index range
406        ///
407        /// # Safety
408        ///
409        /// - `intersection_function_tables` must be a valid pointer.
410        /// - `range` might not be bounds-checked.
411        #[unsafe(method(setIntersectionFunctionTables:withRange:))]
412        #[unsafe(method_family = none)]
413        unsafe fn setIntersectionFunctionTables_withRange(
414            &self,
415            intersection_function_tables: NonNull<
416                *const ProtocolObject<dyn MTLIntersectionFunctionTable>,
417            >,
418            range: NSRange,
419        );
420
421        #[cfg(feature = "MTLDepthStencil")]
422        /// Sets a depth stencil state at a given bind point index
423        ///
424        /// # Safety
425        ///
426        /// `index` might not be bounds-checked.
427        #[unsafe(method(setDepthStencilState:atIndex:))]
428        #[unsafe(method_family = none)]
429        unsafe fn setDepthStencilState_atIndex(
430            &self,
431            depth_stencil_state: Option<&ProtocolObject<dyn MTLDepthStencilState>>,
432            index: NSUInteger,
433        );
434
435        #[cfg(feature = "MTLDepthStencil")]
436        /// Sets an array of depth stencil states at a given buffer index range
437        ///
438        /// # Safety
439        ///
440        /// - `depth_stencil_states` must be a valid pointer.
441        /// - `range` might not be bounds-checked.
442        #[unsafe(method(setDepthStencilStates:withRange:))]
443        #[unsafe(method_family = none)]
444        unsafe fn setDepthStencilStates_withRange(
445            &self,
446            depth_stencil_states: NonNull<*const ProtocolObject<dyn MTLDepthStencilState>>,
447            range: NSRange,
448        );
449    }
450);