objc2_metal/generated/
MTLIndirectCommandBuffer.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/// A bitfield of commands that may be performed indirectly.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlindirectcommandtype?language=objc)
13// NS_OPTIONS
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct MTLIndirectCommandType(pub NSUInteger);
17bitflags::bitflags! {
18    impl MTLIndirectCommandType: NSUInteger {
19        #[doc(alias = "MTLIndirectCommandTypeDraw")]
20        const Draw = 1<<0;
21        #[doc(alias = "MTLIndirectCommandTypeDrawIndexed")]
22        const DrawIndexed = 1<<1;
23        #[doc(alias = "MTLIndirectCommandTypeDrawPatches")]
24        const DrawPatches = 1<<2;
25        #[doc(alias = "MTLIndirectCommandTypeDrawIndexedPatches")]
26        const DrawIndexedPatches = 1<<3;
27        #[doc(alias = "MTLIndirectCommandTypeConcurrentDispatch")]
28        const ConcurrentDispatch = 1<<5;
29        #[doc(alias = "MTLIndirectCommandTypeConcurrentDispatchThreads")]
30        const ConcurrentDispatchThreads = 1<<6;
31        #[doc(alias = "MTLIndirectCommandTypeDrawMeshThreadgroups")]
32        const DrawMeshThreadgroups = 1<<7;
33        #[doc(alias = "MTLIndirectCommandTypeDrawMeshThreads")]
34        const DrawMeshThreads = 1<<8;
35    }
36}
37
38unsafe impl Encode for MTLIndirectCommandType {
39    const ENCODING: Encoding = NSUInteger::ENCODING;
40}
41
42unsafe impl RefEncode for MTLIndirectCommandType {
43    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
44}
45
46/// The data layout required for specifying an indirect command buffer execution range.
47///
48/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlindirectcommandbufferexecutionrange?language=objc)
49#[repr(C)]
50#[derive(Clone, Copy, Debug, PartialEq)]
51pub struct MTLIndirectCommandBufferExecutionRange {
52    pub location: u32,
53    pub length: u32,
54}
55
56unsafe impl Encode for MTLIndirectCommandBufferExecutionRange {
57    const ENCODING: Encoding = Encoding::Struct("?", &[<u32>::ENCODING, <u32>::ENCODING]);
58}
59
60unsafe impl RefEncode for MTLIndirectCommandBufferExecutionRange {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64impl MTLIndirectCommandBufferExecutionRange {
65    // TODO: pub fn MTLIndirectCommandBufferExecutionRangeMake(location: u32,length: u32,) -> MTLIndirectCommandBufferExecutionRange;
66}
67
68extern_class!(
69    /// Describes the limits and features that can be used in an indirect command
70    ///
71    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlindirectcommandbufferdescriptor?language=objc)
72    #[unsafe(super(NSObject))]
73    #[derive(Debug, PartialEq, Eq, Hash)]
74    pub struct MTLIndirectCommandBufferDescriptor;
75);
76
77extern_conformance!(
78    unsafe impl NSCopying for MTLIndirectCommandBufferDescriptor {}
79);
80
81unsafe impl CopyingHelper for MTLIndirectCommandBufferDescriptor {
82    type Result = Self;
83}
84
85extern_conformance!(
86    unsafe impl NSObjectProtocol for MTLIndirectCommandBufferDescriptor {}
87);
88
89impl MTLIndirectCommandBufferDescriptor {
90    extern_methods!(
91        /// A bitfield of the command types that be encoded.
92        ///
93        /// MTLCommandTypeDispatch cannot be mixed with any other command type.
94        #[unsafe(method(commandTypes))]
95        #[unsafe(method_family = none)]
96        pub fn commandTypes(&self) -> MTLIndirectCommandType;
97
98        /// Setter for [`commandTypes`][Self::commandTypes].
99        #[unsafe(method(setCommandTypes:))]
100        #[unsafe(method_family = none)]
101        pub fn setCommandTypes(&self, command_types: MTLIndirectCommandType);
102
103        /// Whether the render or compute pipeline are inherited from the encoder
104        #[unsafe(method(inheritPipelineState))]
105        #[unsafe(method_family = none)]
106        pub fn inheritPipelineState(&self) -> bool;
107
108        /// Setter for [`inheritPipelineState`][Self::inheritPipelineState].
109        #[unsafe(method(setInheritPipelineState:))]
110        #[unsafe(method_family = none)]
111        pub fn setInheritPipelineState(&self, inherit_pipeline_state: bool);
112
113        /// Whether the render or compute pipeline can set arguments.
114        #[unsafe(method(inheritBuffers))]
115        #[unsafe(method_family = none)]
116        pub fn inheritBuffers(&self) -> bool;
117
118        /// Setter for [`inheritBuffers`][Self::inheritBuffers].
119        #[unsafe(method(setInheritBuffers:))]
120        #[unsafe(method_family = none)]
121        pub fn setInheritBuffers(&self, inherit_buffers: bool);
122
123        /// Configures whether the indirect command buffer inherits the depth stencil state from the encoder.
124        ///
125        /// The property's default value is
126        /// <doc
127        /// ://com.apple.documentation/documentation/swift/true>.
128        #[unsafe(method(inheritDepthStencilState))]
129        #[unsafe(method_family = none)]
130        pub fn inheritDepthStencilState(&self) -> bool;
131
132        /// Setter for [`inheritDepthStencilState`][Self::inheritDepthStencilState].
133        #[unsafe(method(setInheritDepthStencilState:))]
134        #[unsafe(method_family = none)]
135        pub fn setInheritDepthStencilState(&self, inherit_depth_stencil_state: bool);
136
137        /// Configures whether the indirect command buffer inherits the depth bias from the encoder.
138        ///
139        /// The property's default value is
140        /// <doc
141        /// ://com.apple.documentation/documentation/swift/true>.
142        #[unsafe(method(inheritDepthBias))]
143        #[unsafe(method_family = none)]
144        pub fn inheritDepthBias(&self) -> bool;
145
146        /// Setter for [`inheritDepthBias`][Self::inheritDepthBias].
147        #[unsafe(method(setInheritDepthBias:))]
148        #[unsafe(method_family = none)]
149        pub fn setInheritDepthBias(&self, inherit_depth_bias: bool);
150
151        /// Configures whether the indirect command buffer inherits the depth clip mode from the encoder.
152        ///
153        /// The property's default value is
154        /// <doc
155        /// ://com.apple.documentation/documentation/swift/true>.
156        #[unsafe(method(inheritDepthClipMode))]
157        #[unsafe(method_family = none)]
158        pub fn inheritDepthClipMode(&self) -> bool;
159
160        /// Setter for [`inheritDepthClipMode`][Self::inheritDepthClipMode].
161        #[unsafe(method(setInheritDepthClipMode:))]
162        #[unsafe(method_family = none)]
163        pub fn setInheritDepthClipMode(&self, inherit_depth_clip_mode: bool);
164
165        /// Configures whether the indirect command buffer inherits the cull mode from the encoder.
166        ///
167        /// The property's default value is
168        /// <doc
169        /// ://com.apple.documentation/documentation/swift/true>.
170        #[unsafe(method(inheritCullMode))]
171        #[unsafe(method_family = none)]
172        pub fn inheritCullMode(&self) -> bool;
173
174        /// Setter for [`inheritCullMode`][Self::inheritCullMode].
175        #[unsafe(method(setInheritCullMode:))]
176        #[unsafe(method_family = none)]
177        pub fn setInheritCullMode(&self, inherit_cull_mode: bool);
178
179        /// Configures whether the indirect command buffer inherits the front facing winding from the encoder.
180        ///
181        /// The property's default value is
182        /// <doc
183        /// ://com.apple.documentation/documentation/swift/true>.
184        #[unsafe(method(inheritFrontFacingWinding))]
185        #[unsafe(method_family = none)]
186        pub fn inheritFrontFacingWinding(&self) -> bool;
187
188        /// Setter for [`inheritFrontFacingWinding`][Self::inheritFrontFacingWinding].
189        #[unsafe(method(setInheritFrontFacingWinding:))]
190        #[unsafe(method_family = none)]
191        pub fn setInheritFrontFacingWinding(&self, inherit_front_facing_winding: bool);
192
193        /// Configures whether the indirect command buffer inherits the triangle fill mode from the encoder.
194        ///
195        /// The property's default value is
196        /// <doc
197        /// ://com.apple.documentation/documentation/swift/true>.
198        #[unsafe(method(inheritTriangleFillMode))]
199        #[unsafe(method_family = none)]
200        pub fn inheritTriangleFillMode(&self) -> bool;
201
202        /// Setter for [`inheritTriangleFillMode`][Self::inheritTriangleFillMode].
203        #[unsafe(method(setInheritTriangleFillMode:))]
204        #[unsafe(method_family = none)]
205        pub fn setInheritTriangleFillMode(&self, inherit_triangle_fill_mode: bool);
206
207        /// The maximum bind index of vertex argument buffers that can be set per command.
208        #[unsafe(method(maxVertexBufferBindCount))]
209        #[unsafe(method_family = none)]
210        pub fn maxVertexBufferBindCount(&self) -> NSUInteger;
211
212        /// Setter for [`maxVertexBufferBindCount`][Self::maxVertexBufferBindCount].
213        #[unsafe(method(setMaxVertexBufferBindCount:))]
214        #[unsafe(method_family = none)]
215        pub fn setMaxVertexBufferBindCount(&self, max_vertex_buffer_bind_count: NSUInteger);
216
217        /// The maximum bind index of fragment argument buffers that can be set per command.
218        #[unsafe(method(maxFragmentBufferBindCount))]
219        #[unsafe(method_family = none)]
220        pub fn maxFragmentBufferBindCount(&self) -> NSUInteger;
221
222        /// Setter for [`maxFragmentBufferBindCount`][Self::maxFragmentBufferBindCount].
223        #[unsafe(method(setMaxFragmentBufferBindCount:))]
224        #[unsafe(method_family = none)]
225        pub fn setMaxFragmentBufferBindCount(&self, max_fragment_buffer_bind_count: NSUInteger);
226
227        /// The maximum bind index of kernel (or tile) argument buffers that can be set per command.
228        #[unsafe(method(maxKernelBufferBindCount))]
229        #[unsafe(method_family = none)]
230        pub fn maxKernelBufferBindCount(&self) -> NSUInteger;
231
232        /// Setter for [`maxKernelBufferBindCount`][Self::maxKernelBufferBindCount].
233        #[unsafe(method(setMaxKernelBufferBindCount:))]
234        #[unsafe(method_family = none)]
235        pub fn setMaxKernelBufferBindCount(&self, max_kernel_buffer_bind_count: NSUInteger);
236
237        /// The maximum bind index of kernel (or tile) threadgroup memory that can be set per command.
238        /// The default value is 31.
239        #[unsafe(method(maxKernelThreadgroupMemoryBindCount))]
240        #[unsafe(method_family = none)]
241        pub fn maxKernelThreadgroupMemoryBindCount(&self) -> NSUInteger;
242
243        /// Setter for [`maxKernelThreadgroupMemoryBindCount`][Self::maxKernelThreadgroupMemoryBindCount].
244        ///
245        /// # Safety
246        ///
247        /// This might not be bounds-checked.
248        #[unsafe(method(setMaxKernelThreadgroupMemoryBindCount:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn setMaxKernelThreadgroupMemoryBindCount(
251            &self,
252            max_kernel_threadgroup_memory_bind_count: NSUInteger,
253        );
254
255        /// The maximum bind index of object stage buffers that can be set per render command.
256        #[unsafe(method(maxObjectBufferBindCount))]
257        #[unsafe(method_family = none)]
258        pub fn maxObjectBufferBindCount(&self) -> NSUInteger;
259
260        /// Setter for [`maxObjectBufferBindCount`][Self::maxObjectBufferBindCount].
261        ///
262        /// # Safety
263        ///
264        /// This might not be bounds-checked.
265        #[unsafe(method(setMaxObjectBufferBindCount:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn setMaxObjectBufferBindCount(&self, max_object_buffer_bind_count: NSUInteger);
268
269        /// The maximum bind index of mesh stage buffers that can be set per render command.
270        #[unsafe(method(maxMeshBufferBindCount))]
271        #[unsafe(method_family = none)]
272        pub fn maxMeshBufferBindCount(&self) -> NSUInteger;
273
274        /// Setter for [`maxMeshBufferBindCount`][Self::maxMeshBufferBindCount].
275        ///
276        /// # Safety
277        ///
278        /// This might not be bounds-checked.
279        #[unsafe(method(setMaxMeshBufferBindCount:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn setMaxMeshBufferBindCount(&self, max_mesh_buffer_bind_count: NSUInteger);
282
283        /// The maximum bind index of object threadgroup memory that can be set per render command.
284        /// The default value is 0.
285        #[unsafe(method(maxObjectThreadgroupMemoryBindCount))]
286        #[unsafe(method_family = none)]
287        pub fn maxObjectThreadgroupMemoryBindCount(&self) -> NSUInteger;
288
289        /// Setter for [`maxObjectThreadgroupMemoryBindCount`][Self::maxObjectThreadgroupMemoryBindCount].
290        ///
291        /// # Safety
292        ///
293        /// This might not be bounds-checked.
294        #[unsafe(method(setMaxObjectThreadgroupMemoryBindCount:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn setMaxObjectThreadgroupMemoryBindCount(
297            &self,
298            max_object_threadgroup_memory_bind_count: NSUInteger,
299        );
300
301        /// Whether the render or compute commands can use ray tracing. Default value is NO.
302        #[unsafe(method(supportRayTracing))]
303        #[unsafe(method_family = none)]
304        pub fn supportRayTracing(&self) -> bool;
305
306        /// Setter for [`supportRayTracing`][Self::supportRayTracing].
307        #[unsafe(method(setSupportRayTracing:))]
308        #[unsafe(method_family = none)]
309        pub fn setSupportRayTracing(&self, support_ray_tracing: bool);
310
311        /// allows binding pipelines that have at least one MTLBufferLayout with a
312        /// stride of `MTLBufferLayoutStrideDynamic`
313        ///
314        /// will allow setting attributeStride in `setVertexBuffer` / `setKernelBuffer`
315        /// calls
316        #[unsafe(method(supportDynamicAttributeStride))]
317        #[unsafe(method_family = none)]
318        pub fn supportDynamicAttributeStride(&self) -> bool;
319
320        /// Setter for [`supportDynamicAttributeStride`][Self::supportDynamicAttributeStride].
321        #[unsafe(method(setSupportDynamicAttributeStride:))]
322        #[unsafe(method_family = none)]
323        pub fn setSupportDynamicAttributeStride(&self, support_dynamic_attribute_stride: bool);
324
325        /// Specifies if the indirect command buffer should support color attachment mapping.
326        #[unsafe(method(supportColorAttachmentMapping))]
327        #[unsafe(method_family = none)]
328        pub fn supportColorAttachmentMapping(&self) -> bool;
329
330        /// Setter for [`supportColorAttachmentMapping`][Self::supportColorAttachmentMapping].
331        #[unsafe(method(setSupportColorAttachmentMapping:))]
332        #[unsafe(method_family = none)]
333        pub fn setSupportColorAttachmentMapping(&self, support_color_attachment_mapping: bool);
334    );
335}
336
337/// Methods declared on superclass `NSObject`.
338impl MTLIndirectCommandBufferDescriptor {
339    extern_methods!(
340        #[unsafe(method(init))]
341        #[unsafe(method_family = init)]
342        pub fn init(this: Allocated<Self>) -> Retained<Self>;
343
344        #[unsafe(method(new))]
345        #[unsafe(method_family = new)]
346        pub fn new() -> Retained<Self>;
347    );
348}
349
350impl DefaultRetained for MTLIndirectCommandBufferDescriptor {
351    #[inline]
352    fn default_retained() -> Retained<Self> {
353        Self::new()
354    }
355}
356
357extern_protocol!(
358    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlindirectcommandbuffer?language=objc)
359    #[cfg(all(feature = "MTLAllocation", feature = "MTLResource"))]
360    pub unsafe trait MTLIndirectCommandBuffer: MTLResource {
361        #[unsafe(method(size))]
362        #[unsafe(method_family = none)]
363        fn size(&self) -> NSUInteger;
364
365        #[cfg(feature = "MTLTypes")]
366        /// Handle of the GPU resource suitable for storing in an Argument Buffer
367        #[unsafe(method(gpuResourceID))]
368        #[unsafe(method_family = none)]
369        fn gpuResourceID(&self) -> MTLResourceID;
370
371        /// # Safety
372        ///
373        /// `range` might not be bounds-checked.
374        #[unsafe(method(resetWithRange:))]
375        #[unsafe(method_family = none)]
376        unsafe fn resetWithRange(&self, range: NSRange);
377
378        #[cfg(feature = "MTLIndirectCommandEncoder")]
379        /// # Safety
380        ///
381        /// `commandIndex` might not be bounds-checked.
382        #[unsafe(method(indirectRenderCommandAtIndex:))]
383        #[unsafe(method_family = none)]
384        unsafe fn indirectRenderCommandAtIndex(
385            &self,
386            command_index: NSUInteger,
387        ) -> Retained<ProtocolObject<dyn MTLIndirectRenderCommand>>;
388
389        #[cfg(feature = "MTLIndirectCommandEncoder")]
390        /// # Safety
391        ///
392        /// `commandIndex` might not be bounds-checked.
393        #[unsafe(method(indirectComputeCommandAtIndex:))]
394        #[unsafe(method_family = none)]
395        unsafe fn indirectComputeCommandAtIndex(
396            &self,
397            command_index: NSUInteger,
398        ) -> Retained<ProtocolObject<dyn MTLIndirectComputeCommand>>;
399    }
400);