objc2_metal/generated/MTL4CommandQueue.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// Enumeration of kinds of errors that committing an array of command buffers instances can produce.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4commandqueueerror?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct MTL4CommandQueueError(pub NSInteger);
19impl MTL4CommandQueueError {
20 /// Indicates the absence of any problems.
21 #[doc(alias = "MTL4CommandQueueErrorNone")]
22 pub const None: Self = Self(0);
23 /// Indicates the workload takes longer to execute than the system allows.
24 #[doc(alias = "MTL4CommandQueueErrorTimeout")]
25 pub const Timeout: Self = Self(1);
26 /// Indicates a process doesn’t have access to a GPU device.
27 #[doc(alias = "MTL4CommandQueueErrorNotPermitted")]
28 pub const NotPermitted: Self = Self(2);
29 /// Indicates the GPU doesn’t have sufficient memory to execute a command buffer.
30 #[doc(alias = "MTL4CommandQueueErrorOutOfMemory")]
31 pub const OutOfMemory: Self = Self(3);
32 /// Indicates the physical removal of the GPU before the command buffer completed.
33 #[doc(alias = "MTL4CommandQueueErrorDeviceRemoved")]
34 pub const DeviceRemoved: Self = Self(4);
35 /// Indicates that the system revokes GPU access because it’s responsible for too many timeouts or hangs.
36 #[doc(alias = "MTL4CommandQueueErrorAccessRevoked")]
37 pub const AccessRevoked: Self = Self(5);
38 /// Indicates an internal problem in the Metal framework.
39 #[doc(alias = "MTL4CommandQueueErrorInternal")]
40 pub const Internal: Self = Self(6);
41}
42
43unsafe impl Encode for MTL4CommandQueueError {
44 const ENCODING: Encoding = NSInteger::ENCODING;
45}
46
47unsafe impl RefEncode for MTL4CommandQueueError {
48 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
49}
50
51extern "C" {
52 /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4commandqueueerrordomain?language=objc)
53 pub static MTL4CommandQueueErrorDomain: &'static NSErrorDomain;
54}
55
56extern_class!(
57 /// Represents options to configure a commit operation on a command queue.
58 ///
59 /// You pass these options as a parameter when you call ``MTL4CommandQueue/commit:count:options:``.
60 ///
61 /// - Note Instances of this class are not thread-safe. If your app modifies a shared commit options instance from
62 /// multiple threads simultaneously, you are responsible for providing external synchronization.
63 ///
64 /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4commitoptions?language=objc)
65 #[unsafe(super(NSObject))]
66 #[derive(Debug, PartialEq, Eq, Hash)]
67 pub struct MTL4CommitOptions;
68);
69
70extern_conformance!(
71 unsafe impl NSObjectProtocol for MTL4CommitOptions {}
72);
73
74impl MTL4CommitOptions {
75 extern_methods!(
76 #[cfg(all(feature = "MTL4CommitFeedback", feature = "block2"))]
77 /// Registers a commit feedback handler that Metal calls with feedback data when available.
78 ///
79 /// - Parameter block: ``MTL4CommitFeedbackHandler`` that Metal invokes.
80 ///
81 /// # Safety
82 ///
83 /// `block` must be a valid pointer.
84 #[unsafe(method(addFeedbackHandler:))]
85 #[unsafe(method_family = none)]
86 pub unsafe fn addFeedbackHandler(&self, block: MTL4CommitFeedbackHandler);
87 );
88}
89
90/// Methods declared on superclass `NSObject`.
91impl MTL4CommitOptions {
92 extern_methods!(
93 #[unsafe(method(init))]
94 #[unsafe(method_family = init)]
95 pub fn init(this: Allocated<Self>) -> Retained<Self>;
96
97 #[unsafe(method(new))]
98 #[unsafe(method_family = new)]
99 pub fn new() -> Retained<Self>;
100 );
101}
102
103impl DefaultRetained for MTL4CommitOptions {
104 #[inline]
105 fn default_retained() -> Retained<Self> {
106 Self::new()
107 }
108}
109
110extern_class!(
111 /// Groups together parameters for the creation of a new command queue.
112 ///
113 /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4commandqueuedescriptor?language=objc)
114 #[unsafe(super(NSObject))]
115 #[derive(Debug, PartialEq, Eq, Hash)]
116 pub struct MTL4CommandQueueDescriptor;
117);
118
119extern_conformance!(
120 unsafe impl NSCopying for MTL4CommandQueueDescriptor {}
121);
122
123unsafe impl CopyingHelper for MTL4CommandQueueDescriptor {
124 type Result = Self;
125}
126
127extern_conformance!(
128 unsafe impl NSObjectProtocol for MTL4CommandQueueDescriptor {}
129);
130
131impl MTL4CommandQueueDescriptor {
132 extern_methods!(
133 /// Assigns an optional label to the command queue instance for debugging purposes.
134 #[unsafe(method(label))]
135 #[unsafe(method_family = none)]
136 pub fn label(&self) -> Option<Retained<NSString>>;
137
138 /// Setter for [`label`][Self::label].
139 ///
140 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
141 #[unsafe(method(setLabel:))]
142 #[unsafe(method_family = none)]
143 pub fn setLabel(&self, label: Option<&NSString>);
144
145 #[cfg(feature = "dispatch2")]
146 /// Assigns a dispatch queue to which Metal submits feedback notification blocks.
147 ///
148 /// When you assign a dispatch queue via this method, Metal requires that the queue parameter you provide is a serial queue.
149 ///
150 /// If you set the value of property to `nil`, the default, Metal allocates an internal dispatch queue to service feedback
151 /// notifications.
152 ///
153 /// # Safety
154 ///
155 /// This is not retained internally, you must ensure the object is still alive.
156 #[unsafe(method(feedbackQueue))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn feedbackQueue(&self) -> Option<Retained<DispatchQueue>>;
159
160 #[cfg(feature = "dispatch2")]
161 /// Setter for [`feedbackQueue`][Self::feedbackQueue].
162 ///
163 /// # Safety
164 ///
165 /// - `feedback_queue` possibly has additional threading requirements.
166 /// - This is unretained, you must ensure the object is kept alive while in use.
167 #[unsafe(method(setFeedbackQueue:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn setFeedbackQueue(&self, feedback_queue: Option<&DispatchQueue>);
170 );
171}
172
173/// Methods declared on superclass `NSObject`.
174impl MTL4CommandQueueDescriptor {
175 extern_methods!(
176 #[unsafe(method(init))]
177 #[unsafe(method_family = init)]
178 pub fn init(this: Allocated<Self>) -> Retained<Self>;
179
180 #[unsafe(method(new))]
181 #[unsafe(method_family = new)]
182 pub fn new() -> Retained<Self>;
183 );
184}
185
186impl DefaultRetained for MTL4CommandQueueDescriptor {
187 #[inline]
188 fn default_retained() -> Retained<Self> {
189 Self::new()
190 }
191}
192
193/// Groups together arguments for an operation to update a sparse texture mapping.
194///
195/// When performing a sparse mapping update, you are responsible for issuing a barrier against stage `MTLStageResourceState`.
196///
197/// You can determine the sparse texture tier by calling ``MTLTexture/sparseTextureTier``.
198///
199/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4updatesparsetexturemappingoperation?language=objc)
200#[cfg(all(feature = "MTLResourceStateCommandEncoder", feature = "MTLTypes"))]
201#[repr(C)]
202#[derive(Clone, Copy, Debug, PartialEq)]
203pub struct MTL4UpdateSparseTextureMappingOperation {
204 /// The mode of the mapping operation to perform.
205 ///
206 /// When mode is ``MTLSparseTextureMappingMode/MTLSparseTextureMappingModeMap``,
207 /// Metal walks the tiles in the region in X, Y, then Z order, assigning the next
208 /// tile from the heap in increasing order, starting at ``heapOffset``.
209 ///
210 /// When mode is ``MTLSparseTextureMappingMode/MTLSparseTextureMappingModeUnmap``,
211 /// Metal unmaps the tiles in the region, ignoring the contents of member ``heapOffset``.
212 pub mode: MTLSparseTextureMappingMode,
213 /// The region in the texture to update, in tiles.
214 ///
215 /// When ``textureLevel`` is equal to the texture's ``MTLTexture/firstMipmapInTail``,
216 /// set `origin.y` to `0` and `size.height` to `1`.
217 pub textureRegion: MTLRegion,
218 /// The index of the mipmap level in the texture to update.
219 ///
220 /// Provide a value between `0` and the texture's ``MTLTexture/firstMipmapInTail``.
221 pub textureLevel: NSUInteger,
222 /// The index of the array slice in the texture to update.
223 ///
224 /// Provide `0` in this member if the texture type is not an array.
225 pub textureSlice: NSUInteger,
226 /// The starting offset in the heap, in tiles.
227 pub heapOffset: NSUInteger,
228}
229
230#[cfg(all(feature = "MTLResourceStateCommandEncoder", feature = "MTLTypes"))]
231unsafe impl Encode for MTL4UpdateSparseTextureMappingOperation {
232 const ENCODING: Encoding = Encoding::Struct(
233 "?",
234 &[
235 <MTLSparseTextureMappingMode>::ENCODING,
236 <MTLRegion>::ENCODING,
237 <NSUInteger>::ENCODING,
238 <NSUInteger>::ENCODING,
239 <NSUInteger>::ENCODING,
240 ],
241 );
242}
243
244#[cfg(all(feature = "MTLResourceStateCommandEncoder", feature = "MTLTypes"))]
245unsafe impl RefEncode for MTL4UpdateSparseTextureMappingOperation {
246 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
247}
248
249/// Groups together arguments for an operation to copy a sparse texture mapping.
250///
251/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4copysparsetexturemappingoperation?language=objc)
252#[cfg(feature = "MTLTypes")]
253#[repr(C)]
254#[derive(Clone, Copy, Debug, PartialEq)]
255pub struct MTL4CopySparseTextureMappingOperation {
256 /// The region in the source texture, in tiles.
257 ///
258 /// The tiles remain mapped in the source texture.
259 ///
260 /// When ``sourceLevel`` is equal to the source texture's ``MTLTexture/firstMipmapInTail``,
261 /// set `origin.y` to `0` and `size.height` to `1`.
262 pub sourceRegion: MTLRegion,
263 /// The index of the mipmap level in the source texture.
264 ///
265 /// Provide a value between `0` and the source texture's ``MTLTexture/firstMipmapInTail``.
266 ///
267 /// When ``sourceLevel`` is equal to the source texture's ``MTLTexture/firstMipmapInTail``,
268 /// set ``destinationLevel`` to the destination texture's ``MTLTexture/firstMipmapInTail``.
269 pub sourceLevel: NSUInteger,
270 /// The index of the array slice in the texture source of the copy operation.
271 ///
272 /// Provide `0` in this member if the texture type is not an array.
273 pub sourceSlice: NSUInteger,
274 /// The origin in the destination texture to copy into, in tiles.
275 ///
276 /// The X, Y and Z coordinates of the tiles relative to the origin match the same
277 /// coordinates in the source region.
278 ///
279 /// When ``destinationLevel`` is equal to the destination texture's ``MTLTexture/firstMipmapInTail``,
280 /// set `destinationOrigin.y` to `0`.
281 pub destinationOrigin: MTLOrigin,
282 /// The index of the mipmap level in the destination texture.
283 ///
284 /// Provide a value between `0` and the destination texture's ``MTLTexture/firstMipmapInTail``.
285 ///
286 /// When ``sourceLevel`` is equal to the source texture's ``MTLTexture/firstMipmapInTail``,
287 /// set ``destinationLevel`` to the destination texture's ``MTLTexture/firstMipmapInTail``.
288 pub destinationLevel: NSUInteger,
289 /// The index of the array slice in the destination texture to copy into.
290 ///
291 /// Provide `0` in this member if the texture type is not an array.
292 pub destinationSlice: NSUInteger,
293}
294
295#[cfg(feature = "MTLTypes")]
296unsafe impl Encode for MTL4CopySparseTextureMappingOperation {
297 const ENCODING: Encoding = Encoding::Struct(
298 "?",
299 &[
300 <MTLRegion>::ENCODING,
301 <NSUInteger>::ENCODING,
302 <NSUInteger>::ENCODING,
303 <MTLOrigin>::ENCODING,
304 <NSUInteger>::ENCODING,
305 <NSUInteger>::ENCODING,
306 ],
307 );
308}
309
310#[cfg(feature = "MTLTypes")]
311unsafe impl RefEncode for MTL4CopySparseTextureMappingOperation {
312 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
313}
314
315/// Groups together arguments for an operation to update a sparse buffer mapping.
316///
317/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4updatesparsebuffermappingoperation?language=objc)
318#[cfg(feature = "MTLResourceStateCommandEncoder")]
319#[repr(C)]
320#[derive(Clone, Copy, Debug, PartialEq)]
321pub struct MTL4UpdateSparseBufferMappingOperation {
322 /// The mode of the mapping operation to perform.
323 ///
324 /// When mode is ``MTLSparseTextureMappingMode/MTLSparseTextureMappingModeMap``,
325 /// Metal walks the tiles in the range in buffer offset order, assigning the
326 /// next tile from the heap in increasing order, starting at ``heapOffset``.
327 ///
328 /// When mode is ``MTLSparseTextureMappingMode/MTLSparseTextureMappingModeUnmap``,
329 /// Metal unmaps the tiles in the range, and ignores the value of member ``heapOffset``.
330 pub mode: MTLSparseTextureMappingMode,
331 /// The range in the buffer, in tiles.
332 pub bufferRange: NSRange,
333 /// The starting offset in the heap, in tiles.
334 pub heapOffset: NSUInteger,
335}
336
337#[cfg(feature = "MTLResourceStateCommandEncoder")]
338unsafe impl Encode for MTL4UpdateSparseBufferMappingOperation {
339 const ENCODING: Encoding = Encoding::Struct(
340 "?",
341 &[
342 <MTLSparseTextureMappingMode>::ENCODING,
343 <NSRange>::ENCODING,
344 <NSUInteger>::ENCODING,
345 ],
346 );
347}
348
349#[cfg(feature = "MTLResourceStateCommandEncoder")]
350unsafe impl RefEncode for MTL4UpdateSparseBufferMappingOperation {
351 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
352}
353
354/// Groups together arguments for an operation to copy a sparse buffer mapping.
355///
356/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4copysparsebuffermappingoperation?language=objc)
357#[repr(C)]
358#[derive(Clone, Copy, Debug, PartialEq)]
359pub struct MTL4CopySparseBufferMappingOperation {
360 /// The range in the source buffer, in tiles.
361 ///
362 /// The tiles remain mapped in the source buffer.
363 pub sourceRange: NSRange,
364 /// The origin in the destination buffer, in tiles.
365 pub destinationOffset: NSUInteger,
366}
367
368unsafe impl Encode for MTL4CopySparseBufferMappingOperation {
369 const ENCODING: Encoding =
370 Encoding::Struct("?", &[<NSRange>::ENCODING, <NSUInteger>::ENCODING]);
371}
372
373unsafe impl RefEncode for MTL4CopySparseBufferMappingOperation {
374 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
375}
376
377extern_protocol!(
378 /// An abstraction representing a command queue that you use commit and synchronize command buffers and to
379 /// perform other GPU operations.
380 ///
381 /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4commandqueue?language=objc)
382 pub unsafe trait MTL4CommandQueue: NSObjectProtocol + Send + Sync {
383 #[cfg(feature = "MTLDevice")]
384 /// Returns the GPU device that the command queue belongs to.
385 #[unsafe(method(device))]
386 #[unsafe(method_family = none)]
387 fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
388
389 /// Obtains this queue's optional label for debugging purposes.
390 #[unsafe(method(label))]
391 #[unsafe(method_family = none)]
392 fn label(&self) -> Option<Retained<NSString>>;
393
394 #[cfg(feature = "MTL4CommandBuffer")]
395 /// Enqueues an array of command buffers for execution.
396 ///
397 /// The order in which you sort the command buffers in the array is meaningful, especially when it contains suspending/resuming
398 /// render passes. A suspending/resuming render pass is a render pass you create by calling
399 /// ``MTL4CommandBuffer/renderCommandEncoderWithDescriptor:options:``,
400 /// and provide `MTL4RenderEncoderOptionSuspending` or `MTL4RenderEncoderOptionResuming` for the `options` parameter.
401 ///
402 /// If your command buffers contain suspend/resume render passes, ensure that the first command buffer only suspends,
403 /// and the last one only resumes. Additionally, make sure that all intermediate command buffers are both suspending
404 /// and resuming.
405 ///
406 /// - Parameters:
407 /// - commandBuffers: an array of ``MTL4CommandBuffer``.
408 /// - count: the number of ``MTL4CommandBuffer`` instances in the `commandBuffers` array.
409 ///
410 /// # Safety
411 ///
412 /// - `command_buffers` must be a valid pointer.
413 /// - `count` might not be bounds-checked.
414 #[unsafe(method(commit:count:))]
415 #[unsafe(method_family = none)]
416 unsafe fn commit_count(
417 &self,
418 command_buffers: NonNull<NonNull<ProtocolObject<dyn MTL4CommandBuffer>>>,
419 count: NSUInteger,
420 );
421
422 #[cfg(feature = "MTL4CommandBuffer")]
423 /// Enqueues an array of command buffer instances for execution with a set of options.
424 ///
425 /// Provide an ``MTL4CommitOptions`` instance to configure the commit operation.
426 ///
427 /// The order in which you sort the command buffers in the array is meaningful, especially when it contains suspending/resuming
428 /// render passes. A suspending/resuming render pass is a render pass you create by calling
429 /// ``MTL4CommandBuffer/renderCommandEncoderWithDescriptor:options:``,
430 /// and provide `MTL4RenderEncoderOptionSuspending` or `MTL4RenderEncoderOptionResuming` for the `options` parameter.
431 ///
432 /// If your command buffers contain suspend/resume render passes, ensure that the first command buffer only suspends,
433 /// and the last one only resumes. Additionally, make sure that all intermediate command buffers are both suspending
434 /// and resuming.
435 ///
436 /// When you commit work from multiple threads, modifying and reusing the same options instance,
437 /// you are responsible for externally synchronizing access to it.
438 ///
439 /// - Parameters:
440 /// - commandBuffers: an array of ``MTL4CommandBuffer``.
441 /// - count: the number of ``MTL4CommandBuffer`` instances in the `commandBuffers` array.
442 /// - options: an instance of ``MTL4CommitOptions`` that configures the commit operation.
443 ///
444 /// # Safety
445 ///
446 /// - `command_buffers` must be a valid pointer.
447 /// - `count` might not be bounds-checked.
448 #[unsafe(method(commit:count:options:))]
449 #[unsafe(method_family = none)]
450 unsafe fn commit_count_options(
451 &self,
452 command_buffers: NonNull<NonNull<ProtocolObject<dyn MTL4CommandBuffer>>>,
453 count: NSUInteger,
454 options: &MTL4CommitOptions,
455 );
456
457 #[cfg(feature = "MTLEvent")]
458 /// Schedules an operation to signal a GPU event with a specific value after all GPU work prior to this point is complete.
459 ///
460 /// - Parameters:
461 /// - event: ``MTLEvent`` to signal.
462 /// - value: the value to signal the ``MTLEvent`` with.
463 #[unsafe(method(signalEvent:value:))]
464 #[unsafe(method_family = none)]
465 fn signalEvent_value(&self, event: &ProtocolObject<dyn MTLEvent>, value: u64);
466
467 #[cfg(feature = "MTLEvent")]
468 /// Schedules an operation to wait for a GPU event of a specific value before continuing to execute any future GPU work.
469 ///
470 /// - Parameters:
471 /// - event: ``MTLEvent`` to wait on.
472 /// - value: the specific value to wait for.
473 #[unsafe(method(waitForEvent:value:))]
474 #[unsafe(method_family = none)]
475 fn waitForEvent_value(&self, event: &ProtocolObject<dyn MTLEvent>, value: u64);
476
477 #[cfg(feature = "MTLDrawable")]
478 /// Schedules a signal operation on the command queue to indicate when rendering to a Metal drawable is complete.
479 ///
480 /// Signaling when rendering to a ``MTLDrawable`` instance is complete indicates that it's safe to present it to the
481 /// display.
482 ///
483 /// You are responsible for calling this method after committing all command buffers that contain commands targeting
484 /// this drawable, and before calling ``MTLDrawable/present``, ``MTLDrawable/presentAtTime:``, or
485 /// ``MTLDrawable/presentAfterMinimumDuration:``.
486 ///
487 /// - Note: This method doesn't trigger the presentation of the drawable, and fails if you call it after any of the
488 /// present methods, or if you call it multiple times.
489 ///
490 /// Metal doesn't guarantee that command buffers you commit to the command queue after calling this method execute
491 /// before presentation.
492 ///
493 /// - Parameters:
494 /// - drawable: ``MTLDrawable`` instance to signal.
495 #[unsafe(method(signalDrawable:))]
496 #[unsafe(method_family = none)]
497 fn signalDrawable(&self, drawable: &ProtocolObject<dyn MTLDrawable>);
498
499 #[cfg(feature = "MTLDrawable")]
500 /// Schedules a wait operation on the command queue to ensure the display is no longer using a specific Metal drawable.
501 ///
502 /// Use this method to ensure the display is no longer using a ``MTLDrawable`` instance before executing any subsequent
503 /// commands.
504 ///
505 /// This method returns immediately and doesn't perform any synchronization on the current thread. You are responsible
506 /// for calling this method before committing any command buffers containing commands that target this drawable.
507 ///
508 /// Call this method multiple times if you commit your command buffers to multiple command queues.
509 ///
510 /// - Parameters:
511 /// - drawable: ``MTLDrawable`` instance to signal.
512 #[unsafe(method(waitForDrawable:))]
513 #[unsafe(method_family = none)]
514 fn waitForDrawable(&self, drawable: &ProtocolObject<dyn MTLDrawable>);
515
516 #[cfg(feature = "MTLResidencySet")]
517 /// Marks a residency set as part of this command queue.
518 ///
519 /// Ensures that Metal makes the residency set resident during the execution of all command buffers you commit to this
520 /// command queue.
521 ///
522 /// Each command queue supports up to 32 unique residency set instances.
523 ///
524 /// - Parameter residencySet: ``MTLResidencySet`` to add to the command queue.
525 #[unsafe(method(addResidencySet:))]
526 #[unsafe(method_family = none)]
527 fn addResidencySet(&self, residency_set: &ProtocolObject<dyn MTLResidencySet>);
528
529 #[cfg(feature = "MTLResidencySet")]
530 /// Marks an array of residency sets as part of this command queue.
531 ///
532 /// Ensures that Metal makes the residency set resident during the execution of all command buffers you commit to this
533 /// command queue.
534 ///
535 /// Each command queue supports up to 32 unique residency set instances.
536 ///
537 /// - Parameters:
538 /// - residencySets: Array of ``MTLResidencySet`` instances to add to the command queue.
539 /// - count: Number of ``MTLResidencySet`` instances in the array.
540 ///
541 /// # Safety
542 ///
543 /// - `residency_sets` must be a valid pointer.
544 /// - `count` might not be bounds-checked.
545 #[unsafe(method(addResidencySets:count:))]
546 #[unsafe(method_family = none)]
547 unsafe fn addResidencySets_count(
548 &self,
549 residency_sets: NonNull<NonNull<ProtocolObject<dyn MTLResidencySet>>>,
550 count: NSUInteger,
551 );
552
553 #[cfg(feature = "MTLResidencySet")]
554 /// Removes a residency set from the command queue.
555 ///
556 /// After calling this method ensures only the remaining residency sets remain resident during the execution of the
557 /// command buffers you commit this command queue.
558 ///
559 /// - Parameter residencySet: ``MTLResidencySet`` instance to remove from the command queue.
560 #[unsafe(method(removeResidencySet:))]
561 #[unsafe(method_family = none)]
562 fn removeResidencySet(&self, residency_set: &ProtocolObject<dyn MTLResidencySet>);
563
564 #[cfg(feature = "MTLResidencySet")]
565 /// Removes multiple residency sets from the command queue.
566 ///
567 /// After calling this method ensures only the remaining residency sets remain resident during the execution of the
568 /// command buffers you commit this command queue.
569 ///
570 /// - Parameters:
571 /// - residencySets: Array of ``MTLResidencySet`` instances to remove from the command queue.
572 /// - count: Number of ``MTLResidencySet`` instances in the array.
573 ///
574 /// # Safety
575 ///
576 /// - `residency_sets` must be a valid pointer.
577 /// - `count` might not be bounds-checked.
578 #[unsafe(method(removeResidencySets:count:))]
579 #[unsafe(method_family = none)]
580 unsafe fn removeResidencySets_count(
581 &self,
582 residency_sets: NonNull<NonNull<ProtocolObject<dyn MTLResidencySet>>>,
583 count: NSUInteger,
584 );
585
586 #[cfg(all(
587 feature = "MTLAllocation",
588 feature = "MTLHeap",
589 feature = "MTLResource",
590 feature = "MTLResourceStateCommandEncoder",
591 feature = "MTLTexture",
592 feature = "MTLTypes"
593 ))]
594 /// Updates multiple regions within a placement sparse texture to alias specific tiles of a Metal heap.
595 ///
596 /// You can provide a `nil` parameter to the `heap` argument only if when you perform unmap operations. Otherwise, you are
597 /// responsible for ensuring the heap is non-nil and has a
598 /// ``MTLHeapDescriptor/maxCompatiblePlacementSparsePageSize`` of at least the texture's
599 /// ``MTLTextureDescriptor/placementSparsePageSize``.
600 ///
601 /// When performing a sparse mapping update, you are responsible for issuing a barrier against stage `MTLStageResourceState`.
602 ///
603 /// You can determine the sparse texture tier by calling `MTLTexture/sparseTextureTier`.
604 ///
605 /// - Parameters:
606 /// - texture: A placement sparse ``MTLTexture``.
607 /// - heap: ``MTLHeap`` you allocate with type ``MTLHeapType/MTLHeapTypePlacement``.
608 /// - operations: An array of ``MTL4UpdateSparseTextureMappingOperation`` instances to perform.
609 /// - count: Number of operations to perform.
610 ///
611 /// # Safety
612 ///
613 /// - `texture` may need to be synchronized.
614 /// - `texture` may be unretained, you must ensure it is kept alive while in use.
615 /// - `operations` must be a valid pointer.
616 /// - `count` might not be bounds-checked.
617 #[unsafe(method(updateTextureMappings:heap:operations:count:))]
618 #[unsafe(method_family = none)]
619 unsafe fn updateTextureMappings_heap_operations_count(
620 &self,
621 texture: &ProtocolObject<dyn MTLTexture>,
622 heap: Option<&ProtocolObject<dyn MTLHeap>>,
623 operations: NonNull<MTL4UpdateSparseTextureMappingOperation>,
624 count: NSUInteger,
625 );
626
627 #[cfg(all(
628 feature = "MTLAllocation",
629 feature = "MTLResource",
630 feature = "MTLTexture",
631 feature = "MTLTypes"
632 ))]
633 /// Copies multiple regions within a source placement sparse texture to a destination placement sparse texture.
634 ///
635 /// You are responsible for ensuring the source and destination textures have the same
636 /// ``MTLTextureDescriptor/placementSparsePageSize``.
637 ///
638 /// Additionally, you are responsible for ensuring that the source and destination textures don't use the same aliased tiles
639 /// at the same time.
640 ///
641 /// - Note: If a sparse texture and a sparse buffer share the same backing tiles, these don't provide you
642 /// you with meaningful views of the other resource’s data.
643 ///
644 /// - Parameters:
645 /// - sourceTexture: The source placement sparse ``MTLTexture``.
646 /// - destinationTexture: The destination placement sparse ``MTLTexture``.
647 /// - operations: An array of ``MTL4CopySparseTextureMappingOperation`` instances to perform.
648 /// - count: Number of operations to perform.
649 ///
650 /// # Safety
651 ///
652 /// - `source_texture` may need to be synchronized.
653 /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
654 /// - `destination_texture` may need to be synchronized.
655 /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
656 /// - `operations` must be a valid pointer.
657 /// - `count` might not be bounds-checked.
658 #[unsafe(method(copyTextureMappingsFromTexture:toTexture:operations:count:))]
659 #[unsafe(method_family = none)]
660 unsafe fn copyTextureMappingsFromTexture_toTexture_operations_count(
661 &self,
662 source_texture: &ProtocolObject<dyn MTLTexture>,
663 destination_texture: &ProtocolObject<dyn MTLTexture>,
664 operations: NonNull<MTL4CopySparseTextureMappingOperation>,
665 count: NSUInteger,
666 );
667
668 #[cfg(all(
669 feature = "MTLAllocation",
670 feature = "MTLBuffer",
671 feature = "MTLHeap",
672 feature = "MTLResource",
673 feature = "MTLResourceStateCommandEncoder"
674 ))]
675 /// Updates multiple regions within a placement sparse buffer to alias specific tiles from a Metal heap.
676 ///
677 /// You can provide a `nil` parameter to the `heap` argument only when you perform unmap operations. Otherwise, you are
678 /// responsible for ensuring parameter `heap` references an ``MTLHeap`` that has a ``MTLHeapDescriptor/maxCompatiblePlacementSparsePageSize``
679 /// of at least the buffer's `placementSparsePageSize` you assign when creating the sparse buffer via
680 /// ``MTLDevice/newBufferWithLength:options:placementSparsePageSize:``.
681 ///
682 /// - Parameters:
683 /// - buffer: A placement sparse ``MTLBuffer``.
684 /// - heap: An ``MTLHeap`` you allocate with type ``MTLHeapType/MTLHeapTypePlacement``.
685 /// - operations: An array of ``MTL4UpdateSparseBufferMappingOperation`` instances to perform.
686 /// - count: Number of operations to perform.
687 ///
688 /// # Safety
689 ///
690 /// - `buffer` may need to be synchronized.
691 /// - `buffer` may be unretained, you must ensure it is kept alive while in use.
692 /// - `buffer` contents should be of the correct type.
693 /// - `operations` must be a valid pointer.
694 /// - `count` might not be bounds-checked.
695 #[unsafe(method(updateBufferMappings:heap:operations:count:))]
696 #[unsafe(method_family = none)]
697 unsafe fn updateBufferMappings_heap_operations_count(
698 &self,
699 buffer: &ProtocolObject<dyn MTLBuffer>,
700 heap: Option<&ProtocolObject<dyn MTLHeap>>,
701 operations: NonNull<MTL4UpdateSparseBufferMappingOperation>,
702 count: NSUInteger,
703 );
704
705 #[cfg(all(
706 feature = "MTLAllocation",
707 feature = "MTLBuffer",
708 feature = "MTLResource"
709 ))]
710 /// Copies multiple offsets within a source placement sparse buffer to a destination placement sparse buffer.
711 ///
712 /// You are responsible for ensuring the source destination sparse buffers have the same `placementSparsePageSize` when
713 /// you create them via ``MTLDevice/newBufferWithLength:options:placementSparsePageSize:``.
714 ///
715 /// Additionally, you are responsible for ensuring both the source and destination sparse buffers don't use the same aliased
716 /// tiles at the same time.
717 ///
718 /// - Note: If a sparse texture and a sparse buffer share the same backing tiles, these don't provide you
719 /// with meaningful views of the other resource’s data.
720 ///
721 /// - Parameters:
722 /// - sourceBuffer: The source placement sparse ``MTLBuffer``.
723 /// - destinationBuffer: The destination placement sparse ``MTLBuffer``.
724 /// - operations: An array of ``MTL4CopySparseBufferMappingOperation`` instances to perform.
725 /// - count: Number of operations to perform.
726 ///
727 /// # Safety
728 ///
729 /// - `source_buffer` may need to be synchronized.
730 /// - `source_buffer` may be unretained, you must ensure it is kept alive while in use.
731 /// - `source_buffer` contents should be of the correct type.
732 /// - `destination_buffer` may need to be synchronized.
733 /// - `destination_buffer` may be unretained, you must ensure it is kept alive while in use.
734 /// - `destination_buffer` contents should be of the correct type.
735 /// - `operations` must be a valid pointer.
736 /// - `count` might not be bounds-checked.
737 #[unsafe(method(copyBufferMappingsFromBuffer:toBuffer:operations:count:))]
738 #[unsafe(method_family = none)]
739 unsafe fn copyBufferMappingsFromBuffer_toBuffer_operations_count(
740 &self,
741 source_buffer: &ProtocolObject<dyn MTLBuffer>,
742 destination_buffer: &ProtocolObject<dyn MTLBuffer>,
743 operations: NonNull<MTL4CopySparseBufferMappingOperation>,
744 count: NSUInteger,
745 );
746 }
747);