objc2_metal/generated/
MTLResidencySet.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
10extern_class!(
11    /// Specifies the parameters for MTLResidencySet creation.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlresidencysetdescriptor?language=objc)
14    #[unsafe(super(NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    pub struct MTLResidencySetDescriptor;
17);
18
19extern_conformance!(
20    unsafe impl NSCopying for MTLResidencySetDescriptor {}
21);
22
23unsafe impl CopyingHelper for MTLResidencySetDescriptor {
24    type Result = Self;
25}
26
27extern_conformance!(
28    unsafe impl NSObjectProtocol for MTLResidencySetDescriptor {}
29);
30
31impl MTLResidencySetDescriptor {
32    extern_methods!(
33        /// An optional label for the MTLResidencySet.
34        #[unsafe(method(label))]
35        #[unsafe(method_family = none)]
36        pub fn label(&self) -> Option<Retained<NSString>>;
37
38        /// Setter for [`label`][Self::label].
39        ///
40        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
41        #[unsafe(method(setLabel:))]
42        #[unsafe(method_family = none)]
43        pub fn setLabel(&self, label: Option<&NSString>);
44
45        /// If non-zero, defines the number of allocations for which to initialize the internal arrays. Defaults to zero.
46        #[unsafe(method(initialCapacity))]
47        #[unsafe(method_family = none)]
48        pub fn initialCapacity(&self) -> NSUInteger;
49
50        /// Setter for [`initialCapacity`][Self::initialCapacity].
51        ///
52        /// # Safety
53        ///
54        /// This might not be bounds-checked.
55        #[unsafe(method(setInitialCapacity:))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn setInitialCapacity(&self, initial_capacity: NSUInteger);
58    );
59}
60
61/// Methods declared on superclass `NSObject`.
62impl MTLResidencySetDescriptor {
63    extern_methods!(
64        #[unsafe(method(init))]
65        #[unsafe(method_family = init)]
66        pub fn init(this: Allocated<Self>) -> Retained<Self>;
67
68        #[unsafe(method(new))]
69        #[unsafe(method_family = new)]
70        pub fn new() -> Retained<Self>;
71    );
72}
73
74impl DefaultRetained for MTLResidencySetDescriptor {
75    #[inline]
76    fn default_retained() -> Retained<Self> {
77        Self::new()
78    }
79}
80
81extern_protocol!(
82    /// A residency set is responsible for managing resource and heap residency and is referenced
83    /// by a command buffer or command queue in order to ensure that resources and heaps are resident.
84    /// Resources and heaps are added and removed uncommitted and a subsequent commit call applies all
85    /// of the changes in bulk.
86    ///
87    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlresidencyset?language=objc)
88    pub unsafe trait MTLResidencySet: NSObjectProtocol {
89        #[cfg(feature = "MTLDevice")]
90        /// The device that created the residency set
91        #[unsafe(method(device))]
92        #[unsafe(method_family = none)]
93        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
94
95        /// The label specified at creation.
96        #[unsafe(method(label))]
97        #[unsafe(method_family = none)]
98        fn label(&self) -> Option<Retained<NSString>>;
99
100        /// The memory footprint of the set in bytes at the last commit operation. This may include internal allocations as well.
101        #[unsafe(method(allocatedSize))]
102        #[unsafe(method_family = none)]
103        fn allocatedSize(&self) -> u64;
104
105        /// Requests that the set and all the committed resources and heaps are made resident.
106        #[unsafe(method(requestResidency))]
107        #[unsafe(method_family = none)]
108        fn requestResidency(&self);
109
110        /// Requests that the set and all the committed resources and heaps are made non-resident.
111        #[unsafe(method(endResidency))]
112        #[unsafe(method_family = none)]
113        fn endResidency(&self);
114
115        #[cfg(feature = "MTLAllocation")]
116        /// Adds one allocation to the set, leaving it uncommitted until commit is called.
117        #[unsafe(method(addAllocation:))]
118        #[unsafe(method_family = none)]
119        fn addAllocation(&self, allocation: &ProtocolObject<dyn MTLAllocation>);
120
121        #[cfg(feature = "MTLAllocation")]
122        /// Adds allocations to the set, leaving them uncommitted until commit is called.
123        ///
124        /// # Safety
125        ///
126        /// - `allocations` must be a valid pointer.
127        /// - `count` might not be bounds-checked.
128        #[unsafe(method(addAllocations:count:))]
129        #[unsafe(method_family = none)]
130        unsafe fn addAllocations_count(
131            &self,
132            allocations: NonNull<NonNull<ProtocolObject<dyn MTLAllocation>>>,
133            count: NSUInteger,
134        );
135
136        #[cfg(feature = "MTLAllocation")]
137        /// Marks an allocation to be removed from the set on the next commit call.
138        #[unsafe(method(removeAllocation:))]
139        #[unsafe(method_family = none)]
140        fn removeAllocation(&self, allocation: &ProtocolObject<dyn MTLAllocation>);
141
142        #[cfg(feature = "MTLAllocation")]
143        /// Marks allocations to be removed from the set on the next commit call.
144        ///
145        /// # Safety
146        ///
147        /// - `allocations` must be a valid pointer.
148        /// - `count` might not be bounds-checked.
149        #[unsafe(method(removeAllocations:count:))]
150        #[unsafe(method_family = none)]
151        unsafe fn removeAllocations_count(
152            &self,
153            allocations: NonNull<NonNull<ProtocolObject<dyn MTLAllocation>>>,
154            count: NSUInteger,
155        );
156
157        /// Marks all allocations to be removed from the set on the next commit call.
158        #[unsafe(method(removeAllAllocations))]
159        #[unsafe(method_family = none)]
160        fn removeAllAllocations(&self);
161
162        #[cfg(feature = "MTLAllocation")]
163        /// Returns a boolean indicating whether the allocation is present in the set or not.
164        ///
165        /// This check includes non-committed allocations in the set.
166        #[unsafe(method(containsAllocation:))]
167        #[unsafe(method_family = none)]
168        fn containsAllocation(&self, an_allocation: &ProtocolObject<dyn MTLAllocation>) -> bool;
169
170        #[cfg(feature = "MTLAllocation")]
171        /// Array of all allocations associated with the set.
172        ///
173        /// This property includes non-committed allocations in the set.
174        #[unsafe(method(allAllocations))]
175        #[unsafe(method_family = none)]
176        fn allAllocations(&self) -> Retained<NSArray<ProtocolObject<dyn MTLAllocation>>>;
177
178        /// Returns the current number of unique allocations present in the set.
179        ///
180        /// This property includes non-committed allocations in the set.
181        #[unsafe(method(allocationCount))]
182        #[unsafe(method_family = none)]
183        fn allocationCount(&self) -> NSUInteger;
184
185        /// Commits any pending adds/removes.
186        ///
187        /// If the residency set is resident, this will try to make added resources and heaps resident instantly, and make removed resources and heaps non-resident.
188        #[unsafe(method(commit))]
189        #[unsafe(method_family = none)]
190        fn commit(&self);
191    }
192);