@bloomengine/engine 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/native/tvos/metal-patched/Cargo.toml +178 -0
  2. package/native/tvos/metal-patched/LICENSE-APACHE +201 -0
  3. package/native/tvos/metal-patched/LICENSE-MIT +25 -0
  4. package/native/tvos/metal-patched/src/acceleration_structure.rs +667 -0
  5. package/native/tvos/metal-patched/src/acceleration_structure_pass.rs +108 -0
  6. package/native/tvos/metal-patched/src/argument.rs +366 -0
  7. package/native/tvos/metal-patched/src/blitpass.rs +102 -0
  8. package/native/tvos/metal-patched/src/buffer.rs +71 -0
  9. package/native/tvos/metal-patched/src/capturedescriptor.rs +76 -0
  10. package/native/tvos/metal-patched/src/capturemanager.rs +113 -0
  11. package/native/tvos/metal-patched/src/commandbuffer.rs +192 -0
  12. package/native/tvos/metal-patched/src/commandqueue.rs +44 -0
  13. package/native/tvos/metal-patched/src/computepass.rs +107 -0
  14. package/native/tvos/metal-patched/src/constants.rs +152 -0
  15. package/native/tvos/metal-patched/src/counters.rs +119 -0
  16. package/native/tvos/metal-patched/src/depthstencil.rs +190 -0
  17. package/native/tvos/metal-patched/src/device.rs +2134 -0
  18. package/native/tvos/metal-patched/src/drawable.rs +39 -0
  19. package/native/tvos/metal-patched/src/encoder.rs +2041 -0
  20. package/native/tvos/metal-patched/src/heap.rs +281 -0
  21. package/native/tvos/metal-patched/src/indirect_encoder.rs +344 -0
  22. package/native/tvos/metal-patched/src/lib.rs +657 -0
  23. package/native/tvos/metal-patched/src/library.rs +902 -0
  24. package/native/tvos/metal-patched/src/mps.rs +575 -0
  25. package/native/tvos/metal-patched/src/pipeline/compute.rs +475 -0
  26. package/native/tvos/metal-patched/src/pipeline/mod.rs +71 -0
  27. package/native/tvos/metal-patched/src/pipeline/render.rs +762 -0
  28. package/native/tvos/metal-patched/src/renderpass.rs +443 -0
  29. package/native/tvos/metal-patched/src/resource.rs +182 -0
  30. package/native/tvos/metal-patched/src/sampler.rs +165 -0
  31. package/native/tvos/metal-patched/src/sync.rs +178 -0
  32. package/native/tvos/metal-patched/src/texture.rs +352 -0
  33. package/native/tvos/metal-patched/src/types.rs +90 -0
  34. package/native/tvos/metal-patched/src/vertexdescriptor.rs +250 -0
  35. package/package.json +5 -1
@@ -0,0 +1,281 @@
1
+ // Copyright 2016 GFX developers
2
+ //
3
+ // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4
+ // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5
+ // http://opensource.org/licenses/MIT>, at your option. This file may not be
6
+ // copied, modified, or distributed except according to those terms.
7
+
8
+ use super::*;
9
+
10
+ /// Only available on macos(10.15), ios(13.0)
11
+ ///
12
+ /// See <https://developer.apple.com/documentation/metal/mtlheaptype/>
13
+ #[repr(u64)]
14
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
15
+ pub enum MTLHeapType {
16
+ Automatic = 0,
17
+ Placement = 1,
18
+ /// Only available on macos(11.0), macCatalyst(14.0)
19
+ Sparse = 2,
20
+ }
21
+
22
+ /// See <https://developer.apple.com/documentation/metal/mtlheap/>
23
+ pub enum MTLHeap {}
24
+
25
+ foreign_obj_type! {
26
+ type CType = MTLHeap;
27
+ pub struct Heap;
28
+ }
29
+
30
+ impl HeapRef {
31
+ pub fn device(&self) -> &DeviceRef {
32
+ unsafe { msg_send![self, device] }
33
+ }
34
+
35
+ pub fn label(&self) -> &str {
36
+ unsafe {
37
+ let label = msg_send![self, label];
38
+ crate::nsstring_as_str(label)
39
+ }
40
+ }
41
+
42
+ pub fn set_label(&self, label: &str) {
43
+ unsafe {
44
+ let nslabel = crate::nsstring_from_str(label);
45
+ let () = msg_send![self, setLabel: nslabel];
46
+ }
47
+ }
48
+
49
+ pub fn cpu_cache_mode(&self) -> MTLCPUCacheMode {
50
+ unsafe { msg_send![self, cpuCacheMode] }
51
+ }
52
+
53
+ pub fn storage_mode(&self) -> MTLStorageMode {
54
+ unsafe { msg_send![self, storageMode] }
55
+ }
56
+
57
+ /// Only available on macos(10.15), ios(13.0)
58
+ pub fn hazard_tracking_mode(&self) -> MTLHazardTrackingMode {
59
+ unsafe { msg_send![self, hazardTrackingMode] }
60
+ }
61
+
62
+ /// Only available on macos(10.15), ios(13.0)
63
+ pub fn resource_options(&self) -> MTLResourceOptions {
64
+ unsafe { msg_send![self, resourceOptions] }
65
+ }
66
+
67
+ pub fn set_purgeable_state(&self, state: MTLPurgeableState) -> MTLPurgeableState {
68
+ unsafe { msg_send![self, setPurgeableState: state] }
69
+ }
70
+
71
+ pub fn size(&self) -> NSUInteger {
72
+ unsafe { msg_send![self, size] }
73
+ }
74
+
75
+ pub fn used_size(&self) -> NSUInteger {
76
+ unsafe { msg_send![self, usedSize] }
77
+ }
78
+
79
+ /// Only available on macos(10.15), ios(13.0)
80
+ pub fn heap_type(&self) -> MTLHeapType {
81
+ unsafe { msg_send![self, type] }
82
+ }
83
+
84
+ /// Only available on macos(10.13), ios(11.0)
85
+ pub fn current_allocated_size(&self) -> NSUInteger {
86
+ unsafe { msg_send![self, currentAllocatedSize] }
87
+ }
88
+
89
+ pub fn max_available_size_with_alignment(&self, alignment: NSUInteger) -> NSUInteger {
90
+ unsafe { msg_send![self, maxAvailableSizeWithAlignment: alignment] }
91
+ }
92
+
93
+ pub fn new_buffer(&self, length: u64, options: MTLResourceOptions) -> Option<Buffer> {
94
+ unsafe {
95
+ let ptr: *mut MTLBuffer = msg_send![self, newBufferWithLength:length
96
+ options:options];
97
+ if !ptr.is_null() {
98
+ Some(Buffer::from_ptr(ptr))
99
+ } else {
100
+ None
101
+ }
102
+ }
103
+ }
104
+
105
+ pub fn new_texture(&self, descriptor: &TextureDescriptorRef) -> Option<Texture> {
106
+ unsafe {
107
+ let ptr: *mut MTLTexture = msg_send![self, newTextureWithDescriptor: descriptor];
108
+ if !ptr.is_null() {
109
+ Some(Texture::from_ptr(ptr))
110
+ } else {
111
+ None
112
+ }
113
+ }
114
+ }
115
+
116
+ /// Only available on macOS 10.15+ & iOS 13.0+
117
+ pub fn new_buffer_with_offset(
118
+ &self,
119
+ length: u64,
120
+ options: MTLResourceOptions,
121
+ offset: u64,
122
+ ) -> Option<Buffer> {
123
+ unsafe {
124
+ let ptr: *mut MTLBuffer = msg_send![self, newBufferWithLength:length
125
+ options:options
126
+ offset:offset];
127
+ if !ptr.is_null() {
128
+ Some(Buffer::from_ptr(ptr))
129
+ } else {
130
+ None
131
+ }
132
+ }
133
+ }
134
+
135
+ /// Only available on macOS 10.15+ & iOS 13.0+
136
+ pub fn new_texture_with_offset(
137
+ &self,
138
+ descriptor: &TextureDescriptorRef,
139
+ offset: u64,
140
+ ) -> Option<Texture> {
141
+ unsafe {
142
+ let ptr: *mut MTLTexture = msg_send![self, newTextureWithDescriptor:descriptor
143
+ offset:offset];
144
+ if !ptr.is_null() {
145
+ Some(Texture::from_ptr(ptr))
146
+ } else {
147
+ None
148
+ }
149
+ }
150
+ }
151
+
152
+ /// Only available on macOS 13.0+ & iOS 16.0+
153
+ pub fn new_acceleration_structure_with_descriptor(
154
+ &self,
155
+ descriptor: &AccelerationStructureDescriptorRef,
156
+ ) -> Option<AccelerationStructure> {
157
+ unsafe {
158
+ let ptr: *mut MTLAccelerationStructure =
159
+ msg_send![self, newAccelerationStructureWithDescriptor: descriptor];
160
+ if !ptr.is_null() {
161
+ Some(AccelerationStructure::from_ptr(ptr))
162
+ } else {
163
+ None
164
+ }
165
+ }
166
+ }
167
+
168
+ /// Only available on macOS 13.0+ & iOS 16.0+
169
+ pub fn new_acceleration_structure_with_descriptor_offset(
170
+ &self,
171
+ descriptor: &AccelerationStructureDescriptorRef,
172
+ offset: u64,
173
+ ) -> Option<AccelerationStructure> {
174
+ unsafe {
175
+ let ptr: *mut MTLAccelerationStructure = msg_send![self, newAccelerationStructureWithDescriptor:descriptor
176
+ offset:offset];
177
+ if !ptr.is_null() {
178
+ Some(AccelerationStructure::from_ptr(ptr))
179
+ } else {
180
+ None
181
+ }
182
+ }
183
+ }
184
+
185
+ /// Only available on macOS 13.0+ & iOS 16.0+
186
+ pub fn new_acceleration_structure_with_size(&self, size: u64) -> Option<AccelerationStructure> {
187
+ unsafe {
188
+ let ptr: *mut MTLAccelerationStructure =
189
+ msg_send![self, newAccelerationStructureWithSize:size];
190
+ if !ptr.is_null() {
191
+ Some(AccelerationStructure::from_ptr(ptr))
192
+ } else {
193
+ None
194
+ }
195
+ }
196
+ }
197
+
198
+ /// Only available on macOS 13.0+ & iOS 16.0+
199
+ pub fn new_acceleration_structure_with_size_offset(
200
+ &self,
201
+ size: u64,
202
+ offset: u64,
203
+ ) -> Option<AccelerationStructure> {
204
+ unsafe {
205
+ let ptr: *mut MTLAccelerationStructure = msg_send![self, newAccelerationStructureWithSize:size
206
+ offset:offset];
207
+ if !ptr.is_null() {
208
+ Some(AccelerationStructure::from_ptr(ptr))
209
+ } else {
210
+ None
211
+ }
212
+ }
213
+ }
214
+ }
215
+
216
+ /// See <https://developer.apple.com/documentation/metal/mtlheapdescriptor/>
217
+ pub enum MTLHeapDescriptor {}
218
+
219
+ foreign_obj_type! {
220
+ type CType = MTLHeapDescriptor;
221
+ pub struct HeapDescriptor;
222
+ }
223
+
224
+ impl HeapDescriptor {
225
+ pub fn new() -> Self {
226
+ unsafe {
227
+ let class = class!(MTLHeapDescriptor);
228
+ msg_send![class, new]
229
+ }
230
+ }
231
+ }
232
+
233
+ impl HeapDescriptorRef {
234
+ pub fn cpu_cache_mode(&self) -> MTLCPUCacheMode {
235
+ unsafe { msg_send![self, cpuCacheMode] }
236
+ }
237
+
238
+ pub fn set_cpu_cache_mode(&self, mode: MTLCPUCacheMode) {
239
+ unsafe { msg_send![self, setCpuCacheMode: mode] }
240
+ }
241
+
242
+ pub fn storage_mode(&self) -> MTLStorageMode {
243
+ unsafe { msg_send![self, storageMode] }
244
+ }
245
+
246
+ pub fn set_storage_mode(&self, mode: MTLStorageMode) {
247
+ unsafe { msg_send![self, setStorageMode: mode] }
248
+ }
249
+
250
+ pub fn size(&self) -> NSUInteger {
251
+ unsafe { msg_send![self, size] }
252
+ }
253
+
254
+ pub fn set_size(&self, size: NSUInteger) {
255
+ unsafe { msg_send![self, setSize: size] }
256
+ }
257
+
258
+ /// Only available on macos(10.15), ios(13.0)
259
+ pub fn hazard_tracking_mode(&self) -> MTLHazardTrackingMode {
260
+ unsafe { msg_send![self, hazardTrackingMode] }
261
+ }
262
+
263
+ /// Only available on macos(10.15), ios(13.0)
264
+ pub fn set_hazard_tracking_mode(&self, hazard_tracking_mode: MTLHazardTrackingMode) {
265
+ unsafe { msg_send![self, setHazardTrackingMode: hazard_tracking_mode] }
266
+ }
267
+
268
+ /// Only available on macos(10.15), ios(13.0)
269
+ pub fn resource_options(&self) -> MTLResourceOptions {
270
+ unsafe { msg_send![self, resourceOptions] }
271
+ }
272
+
273
+ /// Only available on macos(10.15), ios(13.0)
274
+ pub fn heap_type(&self) -> MTLHeapType {
275
+ unsafe { msg_send![self, type] }
276
+ }
277
+ /// Only available on macos(10.15), ios(13.0)
278
+ pub fn set_heap_type(&self, type_: MTLHeapType) {
279
+ unsafe { msg_send![self, setType: type_] }
280
+ }
281
+ }
@@ -0,0 +1,344 @@
1
+ use super::*;
2
+
3
+ bitflags::bitflags! {
4
+ /// See <https://developer.apple.com/documentation/metal/mtlindirectcommandtype/>
5
+ #[allow(non_upper_case_globals)]
6
+ #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
7
+ pub struct MTLIndirectCommandType: NSUInteger {
8
+ const Draw = 1 << 0;
9
+ const DrawIndexed = 1 << 1;
10
+ const DrawPatches = 1 << 2;
11
+ const DrawIndexedPatches = 1 << 3;
12
+ const ConcurrentDispatch = 1 << 4;
13
+ const ConcurrentDispatchThreads = 1 << 5;
14
+ }
15
+ }
16
+
17
+ /// See <https://developer.apple.com/documentation/metal/mtlindirectcommandbufferdescriptor/>
18
+ pub enum MTLIndirectCommandBufferDescriptor {}
19
+
20
+ foreign_obj_type! {
21
+ type CType = MTLIndirectCommandBufferDescriptor;
22
+ pub struct IndirectCommandBufferDescriptor;
23
+ }
24
+
25
+ impl IndirectCommandBufferDescriptor {
26
+ pub fn new() -> Self {
27
+ let class = class!(MTLIndirectCommandBufferDescriptor);
28
+ unsafe { msg_send![class, new] }
29
+ }
30
+ }
31
+
32
+ impl IndirectCommandBufferDescriptorRef {
33
+ pub fn command_types(&self) -> MTLIndirectCommandType {
34
+ unsafe { msg_send![self, commandTypes] }
35
+ }
36
+
37
+ pub fn set_command_types(&self, types: MTLIndirectCommandType) {
38
+ unsafe { msg_send![self, setCommandTypes: types] }
39
+ }
40
+
41
+ pub fn inherit_buffers(&self) -> bool {
42
+ unsafe { msg_send_bool![self, inheritBuffers] }
43
+ }
44
+
45
+ pub fn set_inherit_buffers(&self, inherit: bool) {
46
+ unsafe { msg_send![self, setInheritBuffers: inherit] }
47
+ }
48
+
49
+ pub fn inherit_pipeline_state(&self) -> bool {
50
+ unsafe { msg_send_bool![self, inheritPipelineState] }
51
+ }
52
+
53
+ pub fn set_inherit_pipeline_state(&self, inherit: bool) {
54
+ unsafe { msg_send![self, setInheritPipelineState: inherit] }
55
+ }
56
+
57
+ pub fn max_vertex_buffer_bind_count(&self) -> NSUInteger {
58
+ unsafe { msg_send![self, maxVertexBufferBindCount] }
59
+ }
60
+
61
+ pub fn set_max_vertex_buffer_bind_count(&self, count: NSUInteger) {
62
+ unsafe { msg_send![self, setMaxVertexBufferBindCount: count] }
63
+ }
64
+
65
+ pub fn max_fragment_buffer_bind_count(&self) -> NSUInteger {
66
+ unsafe { msg_send![self, maxFragmentBufferBindCount] }
67
+ }
68
+
69
+ pub fn set_max_fragment_buffer_bind_count(&self, count: NSUInteger) {
70
+ unsafe { msg_send![self, setMaxFragmentBufferBindCount: count] }
71
+ }
72
+
73
+ pub fn max_kernel_buffer_bind_count(&self) -> NSUInteger {
74
+ unsafe { msg_send![self, maxKernelBufferBindCount] }
75
+ }
76
+
77
+ pub fn set_max_kernel_buffer_bind_count(&self, count: NSUInteger) {
78
+ unsafe { msg_send![self, setMaxKernelBufferBindCount: count] }
79
+ }
80
+ }
81
+
82
+ /// See <https://developer.apple.com/documentation/metal/mtlindirectcommandbuffer/>
83
+ pub enum MTLIndirectCommandBuffer {}
84
+
85
+ foreign_obj_type! {
86
+ type CType = MTLIndirectCommandBuffer;
87
+ pub struct IndirectCommandBuffer;
88
+ type ParentType = Resource;
89
+ }
90
+
91
+ impl IndirectCommandBufferRef {
92
+ pub fn size(&self) -> NSUInteger {
93
+ unsafe { msg_send![self, size] }
94
+ }
95
+
96
+ pub fn indirect_render_command_at_index(&self, index: NSUInteger) -> &IndirectRenderCommandRef {
97
+ unsafe { msg_send![self, indirectRenderCommandAtIndex: index] }
98
+ }
99
+
100
+ pub fn indirect_compute_command_at_index(
101
+ &self,
102
+ index: NSUInteger,
103
+ ) -> &IndirectComputeCommandRef {
104
+ unsafe { msg_send![self, indirectComputeCommandAtIndex: index] }
105
+ }
106
+
107
+ pub fn reset_with_range(&self, range: crate::NSRange) {
108
+ unsafe { msg_send![self, resetWithRange: range] }
109
+ }
110
+ }
111
+
112
+ /// See <https://developer.apple.com/documentation/metal/mtlindirectrendercommand/>
113
+ pub enum MTLIndirectRenderCommand {}
114
+
115
+ foreign_obj_type! {
116
+ type CType = MTLIndirectRenderCommand;
117
+ pub struct IndirectRenderCommand;
118
+ }
119
+
120
+ impl IndirectRenderCommandRef {
121
+ pub fn set_render_pipeline_state(&self, pipeline_state: &RenderPipelineStateRef) {
122
+ unsafe { msg_send![self, setRenderPipelineState: pipeline_state] }
123
+ }
124
+
125
+ pub fn set_vertex_buffer(
126
+ &self,
127
+ index: NSUInteger,
128
+ buffer: Option<&BufferRef>,
129
+ offset: NSUInteger,
130
+ ) {
131
+ unsafe {
132
+ msg_send![self,
133
+ setVertexBuffer: buffer
134
+ offset: offset
135
+ atIndex: index
136
+ ]
137
+ }
138
+ }
139
+
140
+ pub fn set_fragment_buffer(
141
+ &self,
142
+ index: NSUInteger,
143
+ buffer: Option<&BufferRef>,
144
+ offset: NSUInteger,
145
+ ) {
146
+ unsafe {
147
+ msg_send![self,
148
+ setFragmentBuffer:buffer
149
+ offset:offset
150
+ atIndex:index
151
+ ]
152
+ }
153
+ }
154
+
155
+ pub fn draw_primitives(
156
+ &self,
157
+ primitive_type: MTLPrimitiveType,
158
+ vertex_start: NSUInteger,
159
+ vertex_count: NSUInteger,
160
+ instance_count: NSUInteger,
161
+ base_instance: NSUInteger,
162
+ ) {
163
+ unsafe {
164
+ msg_send![self,
165
+ drawPrimitives: primitive_type
166
+ vertexStart: vertex_start
167
+ vertexCount: vertex_count
168
+ instanceCount: instance_count
169
+ baseInstance: base_instance
170
+ ]
171
+ }
172
+ }
173
+
174
+ pub fn draw_indexed_primitives(
175
+ &self,
176
+ primitive_type: MTLPrimitiveType,
177
+ index_count: NSUInteger,
178
+ index_type: MTLIndexType,
179
+ index_buffer: &BufferRef,
180
+ index_buffer_offset: NSUInteger,
181
+ instance_count: NSUInteger,
182
+ base_vertex: NSUInteger,
183
+ base_instance: NSUInteger,
184
+ ) {
185
+ unsafe {
186
+ msg_send![self,
187
+ drawIndexedPrimitives: primitive_type
188
+ indexCount: index_count
189
+ indexType: index_type
190
+ indexBuffer: index_buffer
191
+ indexBufferOffset: index_buffer_offset
192
+ instanceCount: instance_count
193
+ baseVertex: base_vertex
194
+ baseInstance: base_instance
195
+ ]
196
+ }
197
+ }
198
+
199
+ pub fn draw_patches(
200
+ &self,
201
+ number_of_patch_control_points: NSUInteger,
202
+ patch_start: NSUInteger,
203
+ patch_count: NSUInteger,
204
+ patch_index_buffer: &BufferRef,
205
+ patch_index_buffer_offset: NSUInteger,
206
+ instance_count: NSUInteger,
207
+ base_instance: NSUInteger,
208
+ tesselation_factor_buffer: &BufferRef,
209
+ tesselation_factor_buffer_offset: NSUInteger,
210
+ tesselation_factor_buffer_instance_stride: NSUInteger,
211
+ ) {
212
+ unsafe {
213
+ msg_send![self,
214
+ drawPatches: number_of_patch_control_points
215
+ patchStart: patch_start
216
+ patchCount: patch_count
217
+ patchIndexBuffer: patch_index_buffer
218
+ patchIndexBufferOffset: patch_index_buffer_offset
219
+ instanceCount: instance_count
220
+ baseInstance: base_instance
221
+ tessellationFactorBuffer: tesselation_factor_buffer
222
+ tessellationFactorBufferOffset: tesselation_factor_buffer_offset
223
+ tessellationFactorBufferInstanceStride: tesselation_factor_buffer_instance_stride
224
+ ]
225
+ }
226
+ }
227
+
228
+ pub fn draw_indexed_patches(
229
+ &self,
230
+ number_of_patch_control_points: NSUInteger,
231
+ patch_start: NSUInteger,
232
+ patch_count: NSUInteger,
233
+ patch_index_buffer: &BufferRef,
234
+ patch_index_buffer_offset: NSUInteger,
235
+ control_point_index_buffer: &BufferRef,
236
+ control_point_index_buffer_offset: NSUInteger,
237
+ instance_count: NSUInteger,
238
+ base_instance: NSUInteger,
239
+ tesselation_factor_buffer: &BufferRef,
240
+ tesselation_factor_buffer_offset: NSUInteger,
241
+ tesselation_factor_buffer_instance_stride: NSUInteger,
242
+ ) {
243
+ unsafe {
244
+ msg_send![self,
245
+ drawIndexedPatches: number_of_patch_control_points
246
+ patchStart: patch_start
247
+ patchCount: patch_count
248
+ patchIndexBuffer: patch_index_buffer
249
+ patchIndexBufferOffset: patch_index_buffer_offset
250
+ controlPointIndexBuffer: control_point_index_buffer
251
+ controlPointIndexBufferOffset: control_point_index_buffer_offset
252
+ instanceCount: instance_count
253
+ baseInstance: base_instance
254
+ tessellationFactorBuffer: tesselation_factor_buffer
255
+ tessellationFactorBufferOffset: tesselation_factor_buffer_offset
256
+ tessellationFactorBufferInstanceStride: tesselation_factor_buffer_instance_stride
257
+ ]
258
+ }
259
+ }
260
+
261
+ pub fn reset(&self) {
262
+ unsafe { msg_send![self, reset] }
263
+ }
264
+ }
265
+
266
+ /// See <https://developer.apple.com/documentation/metal/mtlindirectcomputecommand/>
267
+ pub enum MTLIndirectComputeCommand {}
268
+
269
+ foreign_obj_type! {
270
+ type CType = MTLIndirectComputeCommand;
271
+ pub struct IndirectComputeCommand;
272
+ }
273
+
274
+ impl IndirectComputeCommandRef {
275
+ pub fn set_compute_pipeline_state(&self, state: &ComputePipelineStateRef) {
276
+ unsafe { msg_send![self, setComputePipelineState: state] }
277
+ }
278
+
279
+ pub fn set_kernel_buffer(
280
+ &self,
281
+ index: NSUInteger,
282
+ buffer: Option<&BufferRef>,
283
+ offset: NSUInteger,
284
+ ) {
285
+ unsafe {
286
+ msg_send![self,
287
+ setKernelBuffer: buffer
288
+ offset: offset
289
+ atIndex: index
290
+ ]
291
+ }
292
+ }
293
+
294
+ pub fn set_threadgroup_memory_length(&self, index: NSUInteger, length: NSUInteger) {
295
+ unsafe {
296
+ msg_send![self,
297
+ setThreadgroupMemoryLength: length
298
+ atIndex: index
299
+ ]
300
+ }
301
+ }
302
+
303
+ pub fn set_stage_in_region(&self, region: MTLRegion) {
304
+ unsafe { msg_send![self, setStageInRegion: region] }
305
+ }
306
+
307
+ pub fn set_barrier(&self) {
308
+ unsafe { msg_send![self, setBarrier] }
309
+ }
310
+
311
+ pub fn clear_barrier(&self) {
312
+ unsafe { msg_send![self, clearBarrier] }
313
+ }
314
+
315
+ pub fn concurrent_dispatch_threadgroups(
316
+ &self,
317
+ thread_groups_per_grid: MTLSize,
318
+ threads_per_threadgroup: MTLSize,
319
+ ) {
320
+ unsafe {
321
+ msg_send![self,
322
+ concurrentDispatchThreadgroups: thread_groups_per_grid
323
+ threadsPerThreadgroup: threads_per_threadgroup
324
+ ]
325
+ }
326
+ }
327
+
328
+ pub fn concurrent_dispatch_threads(
329
+ &self,
330
+ thread_groups_per_grid: MTLSize,
331
+ threads_per_threadgroup: MTLSize,
332
+ ) {
333
+ unsafe {
334
+ msg_send![self,
335
+ concurrentDispatchThreads: thread_groups_per_grid
336
+ threadsPerThreadgroup: threads_per_threadgroup
337
+ ]
338
+ }
339
+ }
340
+
341
+ pub fn reset(&self) {
342
+ unsafe { msg_send![self, reset] }
343
+ }
344
+ }