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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLIndirectCommandType(pub NSUInteger);
bitflags::bitflags! {
    impl MTLIndirectCommandType: NSUInteger {
        #[doc(alias = "MTLIndirectCommandTypeDraw")]
        const Draw = 1<<0;
        #[doc(alias = "MTLIndirectCommandTypeDrawIndexed")]
        const DrawIndexed = 1<<1;
        #[doc(alias = "MTLIndirectCommandTypeDrawPatches")]
        const DrawPatches = 1<<2;
        #[doc(alias = "MTLIndirectCommandTypeDrawIndexedPatches")]
        const DrawIndexedPatches = 1<<3;
        #[doc(alias = "MTLIndirectCommandTypeConcurrentDispatch")]
        const ConcurrentDispatch = 1<<5;
        #[doc(alias = "MTLIndirectCommandTypeConcurrentDispatchThreads")]
        const ConcurrentDispatchThreads = 1<<6;
        #[doc(alias = "MTLIndirectCommandTypeDrawMeshThreadgroups")]
        const DrawMeshThreadgroups = 1<<7;
        #[doc(alias = "MTLIndirectCommandTypeDrawMeshThreads")]
        const DrawMeshThreads = 1<<8;
    }
}

unsafe impl Encode for MTLIndirectCommandType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MTLIndirectCommandType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MTLIndirectCommandBufferExecutionRange {
    pub location: u32,
    pub length: u32,
}

unsafe impl Encode for MTLIndirectCommandBufferExecutionRange {
    const ENCODING: Encoding = Encoding::Struct("?", &[<u32>::ENCODING, <u32>::ENCODING]);
}

unsafe impl RefEncode for MTLIndirectCommandBufferExecutionRange {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// TODO: pub fn MTLIndirectCommandBufferExecutionRangeMake(location: u32,length: u32,) -> MTLIndirectCommandBufferExecutionRange;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTLIndirectCommandBufferDescriptor;

    unsafe impl ClassType for MTLIndirectCommandBufferDescriptor {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSCopying for MTLIndirectCommandBufferDescriptor {}

unsafe impl NSObjectProtocol for MTLIndirectCommandBufferDescriptor {}

extern_methods!(
    unsafe impl MTLIndirectCommandBufferDescriptor {
        #[method(commandTypes)]
        pub fn commandTypes(&self) -> MTLIndirectCommandType;

        #[method(setCommandTypes:)]
        pub fn setCommandTypes(&self, command_types: MTLIndirectCommandType);

        #[method(inheritPipelineState)]
        pub fn inheritPipelineState(&self) -> bool;

        #[method(setInheritPipelineState:)]
        pub fn setInheritPipelineState(&self, inherit_pipeline_state: bool);

        #[method(inheritBuffers)]
        pub fn inheritBuffers(&self) -> bool;

        #[method(setInheritBuffers:)]
        pub fn setInheritBuffers(&self, inherit_buffers: bool);

        #[method(maxVertexBufferBindCount)]
        pub fn maxVertexBufferBindCount(&self) -> NSUInteger;

        #[method(setMaxVertexBufferBindCount:)]
        pub fn setMaxVertexBufferBindCount(&self, max_vertex_buffer_bind_count: NSUInteger);

        #[method(maxFragmentBufferBindCount)]
        pub fn maxFragmentBufferBindCount(&self) -> NSUInteger;

        #[method(setMaxFragmentBufferBindCount:)]
        pub fn setMaxFragmentBufferBindCount(&self, max_fragment_buffer_bind_count: NSUInteger);

        #[method(maxKernelBufferBindCount)]
        pub fn maxKernelBufferBindCount(&self) -> NSUInteger;

        #[method(setMaxKernelBufferBindCount:)]
        pub fn setMaxKernelBufferBindCount(&self, max_kernel_buffer_bind_count: NSUInteger);

        #[method(maxKernelThreadgroupMemoryBindCount)]
        pub unsafe fn maxKernelThreadgroupMemoryBindCount(&self) -> NSUInteger;

        #[method(setMaxKernelThreadgroupMemoryBindCount:)]
        pub unsafe fn setMaxKernelThreadgroupMemoryBindCount(
            &self,
            max_kernel_threadgroup_memory_bind_count: NSUInteger,
        );

        #[method(maxObjectBufferBindCount)]
        pub unsafe fn maxObjectBufferBindCount(&self) -> NSUInteger;

        #[method(setMaxObjectBufferBindCount:)]
        pub unsafe fn setMaxObjectBufferBindCount(&self, max_object_buffer_bind_count: NSUInteger);

        #[method(maxMeshBufferBindCount)]
        pub unsafe fn maxMeshBufferBindCount(&self) -> NSUInteger;

        #[method(setMaxMeshBufferBindCount:)]
        pub unsafe fn setMaxMeshBufferBindCount(&self, max_mesh_buffer_bind_count: NSUInteger);

        #[method(maxObjectThreadgroupMemoryBindCount)]
        pub unsafe fn maxObjectThreadgroupMemoryBindCount(&self) -> NSUInteger;

        #[method(setMaxObjectThreadgroupMemoryBindCount:)]
        pub unsafe fn setMaxObjectThreadgroupMemoryBindCount(
            &self,
            max_object_threadgroup_memory_bind_count: NSUInteger,
        );

        #[method(supportRayTracing)]
        pub unsafe fn supportRayTracing(&self) -> bool;

        #[method(setSupportRayTracing:)]
        pub unsafe fn setSupportRayTracing(&self, support_ray_tracing: bool);

        #[method(supportDynamicAttributeStride)]
        pub unsafe fn supportDynamicAttributeStride(&self) -> bool;

        #[method(setSupportDynamicAttributeStride:)]
        pub unsafe fn setSupportDynamicAttributeStride(
            &self,
            support_dynamic_attribute_stride: bool,
        );
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl MTLIndirectCommandBufferDescriptor {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern_protocol!(
    #[cfg(feature = "MTLResource")]
    pub unsafe trait MTLIndirectCommandBuffer: MTLResource + IsRetainable {
        #[method(size)]
        fn size(&self) -> NSUInteger;

        #[cfg(feature = "MTLTypes")]
        #[method(gpuResourceID)]
        unsafe fn gpuResourceID(&self) -> MTLResourceID;

        #[method(resetWithRange:)]
        unsafe fn resetWithRange(&self, range: NSRange);

        #[cfg(feature = "MTLIndirectCommandEncoder")]
        #[method_id(@__retain_semantics Other indirectRenderCommandAtIndex:)]
        unsafe fn indirectRenderCommandAtIndex(
            &self,
            command_index: NSUInteger,
        ) -> Retained<ProtocolObject<dyn MTLIndirectRenderCommand>>;

        #[cfg(feature = "MTLIndirectCommandEncoder")]
        #[method_id(@__retain_semantics Other indirectComputeCommandAtIndex:)]
        unsafe fn indirectComputeCommandAtIndex(
            &self,
            command_index: NSUInteger,
        ) -> Retained<ProtocolObject<dyn MTLIndirectComputeCommand>>;
    }

    #[cfg(feature = "MTLResource")]
    unsafe impl ProtocolType for dyn MTLIndirectCommandBuffer {}
);