objc2_metal/generated/MTLResourceStateCommandEncoder.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::*;
6
7use crate::*;
8
9/// Type of mapping operation for sparse texture
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlsparsetexturemappingmode?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct MTLSparseTextureMappingMode(pub NSUInteger);
16impl MTLSparseTextureMappingMode {
17 #[doc(alias = "MTLSparseTextureMappingModeMap")]
18 pub const Map: Self = Self(0);
19 #[doc(alias = "MTLSparseTextureMappingModeUnmap")]
20 pub const Unmap: Self = Self(1);
21}
22
23unsafe impl Encode for MTLSparseTextureMappingMode {
24 const ENCODING: Encoding = NSUInteger::ENCODING;
25}
26
27unsafe impl RefEncode for MTLSparseTextureMappingMode {
28 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
29}
30
31/// Structure describing indirect mapping region. This structure is used to populate a buffer for the method 'MTLResourceStateCommandEncoder updateTextureMapping:indirectBuffer:indirectBufferOffset:'
32///
33/// The correct data format for the buffer used in 'MTLResourceStateCommandEncoder updateTextureMapping:indirectBuffer:indirectBufferOffset: is the following:
34///
35/// struct MTLMapIndirectBufferFormat{
36/// uint32_t numMappings;
37/// MTLMapIndirectArguments mappings[numMappings];
38/// }
39///
40/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlmapindirectarguments?language=objc)
41#[repr(C)]
42#[derive(Clone, Copy, Debug, PartialEq)]
43pub struct MTLMapIndirectArguments {
44 pub regionOriginX: u32,
45 pub regionOriginY: u32,
46 pub regionOriginZ: u32,
47 pub regionSizeWidth: u32,
48 pub regionSizeHeight: u32,
49 pub regionSizeDepth: u32,
50 pub mipMapLevel: u32,
51 pub sliceId: u32,
52}
53
54unsafe impl Encode for MTLMapIndirectArguments {
55 const ENCODING: Encoding = Encoding::Struct(
56 "?",
57 &[
58 <u32>::ENCODING,
59 <u32>::ENCODING,
60 <u32>::ENCODING,
61 <u32>::ENCODING,
62 <u32>::ENCODING,
63 <u32>::ENCODING,
64 <u32>::ENCODING,
65 <u32>::ENCODING,
66 ],
67 );
68}
69
70unsafe impl RefEncode for MTLMapIndirectArguments {
71 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74extern_protocol!(
75 /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlresourcestatecommandencoder?language=objc)
76 #[cfg(feature = "MTLCommandEncoder")]
77 pub unsafe trait MTLResourceStateCommandEncoder: MTLCommandEncoder {
78 #[cfg(all(
79 feature = "MTLAllocation",
80 feature = "MTLResource",
81 feature = "MTLTexture",
82 feature = "MTLTypes"
83 ))]
84 /// Updates multiple regions within a sparse texture.
85 ///
86 /// # Safety
87 ///
88 /// - `texture` may need to be synchronized.
89 /// - `texture` may be unretained, you must ensure it is kept alive while in use.
90 /// - `regions` must be a valid pointer.
91 /// - `mip_levels` must be a valid pointer.
92 /// - `slices` must be a valid pointer.
93 #[optional]
94 #[unsafe(method(updateTextureMappings:mode:regions:mipLevels:slices:numRegions:))]
95 #[unsafe(method_family = none)]
96 unsafe fn updateTextureMappings_mode_regions_mipLevels_slices_numRegions(
97 &self,
98 texture: &ProtocolObject<dyn MTLTexture>,
99 mode: MTLSparseTextureMappingMode,
100 regions: NonNull<MTLRegion>,
101 mip_levels: NonNull<NSUInteger>,
102 slices: NonNull<NSUInteger>,
103 num_regions: NSUInteger,
104 );
105
106 #[cfg(all(
107 feature = "MTLAllocation",
108 feature = "MTLResource",
109 feature = "MTLTexture",
110 feature = "MTLTypes"
111 ))]
112 /// Updates mapping for given sparse texture
113 ///
114 /// # Safety
115 ///
116 /// - `texture` may need to be synchronized.
117 /// - `texture` may be unretained, you must ensure it is kept alive while in use.
118 #[optional]
119 #[unsafe(method(updateTextureMapping:mode:region:mipLevel:slice:))]
120 #[unsafe(method_family = none)]
121 unsafe fn updateTextureMapping_mode_region_mipLevel_slice(
122 &self,
123 texture: &ProtocolObject<dyn MTLTexture>,
124 mode: MTLSparseTextureMappingMode,
125 region: MTLRegion,
126 mip_level: NSUInteger,
127 slice: NSUInteger,
128 );
129
130 #[cfg(all(
131 feature = "MTLAllocation",
132 feature = "MTLBuffer",
133 feature = "MTLResource",
134 feature = "MTLTexture"
135 ))]
136 /// Updates mapping for given sparse texture. Updates are driven via a MTLBuffer with the structure format defined by MTLMapIndirectBufferFormat.
137 ///
138 /// struct MTLMapIndirectBufferFormat{
139 /// uint32_t numMappings;
140 /// MTLMapIndirectArguments mappings[numMappings];
141 /// }
142 ///
143 /// # Safety
144 ///
145 /// - `texture` may need to be synchronized.
146 /// - `texture` may be unretained, you must ensure it is kept alive while in use.
147 /// - `indirect_buffer` may need to be synchronized.
148 /// - `indirect_buffer` may be unretained, you must ensure it is kept alive while in use.
149 /// - `indirect_buffer` contents should be of the correct type.
150 /// - `indirectBufferOffset` might not be bounds-checked.
151 #[optional]
152 #[unsafe(method(updateTextureMapping:mode:indirectBuffer:indirectBufferOffset:))]
153 #[unsafe(method_family = none)]
154 unsafe fn updateTextureMapping_mode_indirectBuffer_indirectBufferOffset(
155 &self,
156 texture: &ProtocolObject<dyn MTLTexture>,
157 mode: MTLSparseTextureMappingMode,
158 indirect_buffer: &ProtocolObject<dyn MTLBuffer>,
159 indirect_buffer_offset: NSUInteger,
160 );
161
162 #[cfg(feature = "MTLFence")]
163 /// Update the fence to capture all GPU work so far enqueued by this encoder.
164 ///
165 /// The fence is updated at kernel submission to maintain global order and prevent deadlock.
166 /// Drivers may delay fence updates until the end of the encoder. Drivers may also wait on fences at the beginning of an encoder. It is therefore illegal to wait on a fence after it has been updated in the same encoder.
167 #[optional]
168 #[unsafe(method(updateFence:))]
169 #[unsafe(method_family = none)]
170 fn updateFence(&self, fence: &ProtocolObject<dyn MTLFence>);
171
172 #[cfg(feature = "MTLFence")]
173 /// Prevent further GPU work until the fence is reached.
174 ///
175 /// The fence is evaluated at kernel submission to maintain global order and prevent deadlock.
176 /// Drivers may delay fence updates until the end of the encoder. Drivers may also wait on fences at the beginning of an encoder. It is therefore illegal to wait on a fence after it has been updated in the same encoder.
177 #[optional]
178 #[unsafe(method(waitForFence:))]
179 #[unsafe(method_family = none)]
180 fn waitForFence(&self, fence: &ProtocolObject<dyn MTLFence>);
181
182 #[cfg(all(
183 feature = "MTLAllocation",
184 feature = "MTLResource",
185 feature = "MTLTexture",
186 feature = "MTLTypes"
187 ))]
188 /// Move sparse page mappings from one sparse texture to another from the same heap.
189 ///
190 /// The tile mapping is moved from the source texture only if the destination texture tile is unmapped. The textures must also have matching a texture format,
191 /// texture type, sample count, usage and resource options.
192 ///
193 /// # Safety
194 ///
195 /// - `source_texture` may need to be synchronized.
196 /// - `source_texture` may be unretained, you must ensure it is kept alive while in use.
197 /// - `sourceSize` might not be bounds-checked.
198 /// - `destination_texture` may need to be synchronized.
199 /// - `destination_texture` may be unretained, you must ensure it is kept alive while in use.
200 #[optional]
201 #[unsafe(method(moveTextureMappingsFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:))]
202 #[unsafe(method_family = none)]
203 unsafe fn moveTextureMappingsFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(
204 &self,
205 source_texture: &ProtocolObject<dyn MTLTexture>,
206 source_slice: NSUInteger,
207 source_level: NSUInteger,
208 source_origin: MTLOrigin,
209 source_size: MTLSize,
210 destination_texture: &ProtocolObject<dyn MTLTexture>,
211 destination_slice: NSUInteger,
212 destination_level: NSUInteger,
213 destination_origin: MTLOrigin,
214 );
215 }
216);