1use mtl_foundation::{Integer, UInteger};
6
7#[repr(transparent)]
11#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
12pub struct CommandQueueError(pub Integer);
13
14impl CommandQueueError {
15 pub const NONE: Self = Self(0);
17
18 pub const TIMEOUT: Self = Self(1);
20
21 pub const NOT_PERMITTED: Self = Self(2);
23
24 pub const OUT_OF_MEMORY: Self = Self(3);
26
27 pub const DEVICE_REMOVED: Self = Self(4);
29
30 pub const ACCESS_REVOKED: Self = Self(5);
32
33 pub const INTERNAL: Self = Self(6);
35}
36
37#[repr(transparent)]
45#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
46pub struct AlphaToOneState(pub Integer);
47
48impl AlphaToOneState {
49 pub const DISABLED: Self = Self(0);
51
52 pub const ENABLED: Self = Self(1);
54}
55
56#[repr(transparent)]
60#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
61pub struct AlphaToCoverageState(pub Integer);
62
63impl AlphaToCoverageState {
64 pub const DISABLED: Self = Self(0);
66
67 pub const ENABLED: Self = Self(1);
69}
70
71#[repr(transparent)]
75#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
76pub struct BlendState(pub Integer);
77
78impl BlendState {
79 pub const DISABLED: Self = Self(0);
81
82 pub const ENABLED: Self = Self(1);
84
85 pub const UNSPECIALIZED: Self = Self(2);
87}
88
89#[repr(transparent)]
93#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
94pub struct IndirectCommandBufferSupportState(pub Integer);
95
96impl IndirectCommandBufferSupportState {
97 pub const DISABLED: Self = Self(0);
99
100 pub const ENABLED: Self = Self(1);
102}
103
104#[repr(transparent)]
108#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
109pub struct ShaderReflection(pub UInteger);
110
111impl ShaderReflection {
112 pub const NONE: Self = Self(0);
114
115 pub const BINDING_INFO: Self = Self(1);
117
118 pub const BUFFER_TYPE_INFO: Self = Self(1 << 1);
120
121 #[inline]
123 pub const fn union(self, other: Self) -> Self {
124 Self(self.0 | other.0)
125 }
126
127 #[inline]
129 pub const fn contains(self, other: Self) -> bool {
130 (self.0 & other.0) == other.0
131 }
132}
133
134impl std::ops::BitOr for ShaderReflection {
135 type Output = Self;
136 fn bitor(self, rhs: Self) -> Self {
137 Self(self.0 | rhs.0)
138 }
139}
140
141impl std::ops::BitAnd for ShaderReflection {
142 type Output = Self;
143 fn bitand(self, rhs: Self) -> Self {
144 Self(self.0 & rhs.0)
145 }
146}
147
148#[repr(transparent)]
152#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
153pub struct LogicalToPhysicalColorAttachmentMappingState(pub Integer);
154
155impl LogicalToPhysicalColorAttachmentMappingState {
156 pub const IDENTITY: Self = Self(0);
158
159 pub const INHERITED: Self = Self(1);
161}
162
163#[repr(transparent)]
171#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
172pub struct CompilerTaskStatus(pub Integer);
173
174impl CompilerTaskStatus {
175 pub const NONE: Self = Self(0);
177
178 pub const SCHEDULED: Self = Self(1);
180
181 pub const COMPILING: Self = Self(2);
183
184 pub const FINISHED: Self = Self(3);
186}
187
188#[repr(transparent)]
192#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
193pub struct BinaryFunctionOptions(pub UInteger);
194
195impl BinaryFunctionOptions {
196 pub const NONE: Self = Self(0);
198
199 pub const PIPELINE_INDEPENDENT: Self = Self(1 << 1);
201
202 #[inline]
204 pub const fn union(self, other: Self) -> Self {
205 Self(self.0 | other.0)
206 }
207
208 #[inline]
210 pub const fn contains(self, other: Self) -> bool {
211 (self.0 & other.0) == other.0
212 }
213}
214
215impl std::ops::BitOr for BinaryFunctionOptions {
216 type Output = Self;
217 fn bitor(self, rhs: Self) -> Self {
218 Self(self.0 | rhs.0)
219 }
220}
221
222impl std::ops::BitAnd for BinaryFunctionOptions {
223 type Output = Self;
224 fn bitand(self, rhs: Self) -> Self {
225 Self(self.0 & rhs.0)
226 }
227}
228
229#[repr(transparent)]
233#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
234pub struct PipelineDataSetSerializerConfiguration(pub UInteger);
235
236impl PipelineDataSetSerializerConfiguration {
237 pub const CAPTURE_DESCRIPTORS: Self = Self(1);
239
240 pub const CAPTURE_BINARIES: Self = Self(1 << 1);
242
243 #[inline]
245 pub const fn union(self, other: Self) -> Self {
246 Self(self.0 | other.0)
247 }
248
249 #[inline]
251 pub const fn contains(self, other: Self) -> bool {
252 (self.0 & other.0) == other.0
253 }
254}
255
256impl std::ops::BitOr for PipelineDataSetSerializerConfiguration {
257 type Output = Self;
258 fn bitor(self, rhs: Self) -> Self {
259 Self(self.0 | rhs.0)
260 }
261}
262
263impl std::ops::BitAnd for PipelineDataSetSerializerConfiguration {
264 type Output = Self;
265 fn bitand(self, rhs: Self) -> Self {
266 Self(self.0 & rhs.0)
267 }
268}
269
270#[repr(transparent)]
278#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
279pub struct VisibilityOptions(pub UInteger);
280
281impl VisibilityOptions {
282 pub const NONE: Self = Self(0);
284
285 pub const DEVICE: Self = Self(1);
287
288 pub const RESOURCE_ALIAS: Self = Self(1 << 1);
290
291 #[inline]
293 pub const fn union(self, other: Self) -> Self {
294 Self(self.0 | other.0)
295 }
296
297 #[inline]
299 pub const fn contains(self, other: Self) -> bool {
300 (self.0 & other.0) == other.0
301 }
302}
303
304impl std::ops::BitOr for VisibilityOptions {
305 type Output = Self;
306 fn bitor(self, rhs: Self) -> Self {
307 Self(self.0 | rhs.0)
308 }
309}
310
311impl std::ops::BitAnd for VisibilityOptions {
312 type Output = Self;
313 fn bitand(self, rhs: Self) -> Self {
314 Self(self.0 & rhs.0)
315 }
316}
317
318#[repr(transparent)]
322#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
323pub struct RenderEncoderOptions(pub UInteger);
324
325impl RenderEncoderOptions {
326 pub const NONE: Self = Self(0);
328
329 pub const SUSPENDING: Self = Self(1);
331
332 pub const RESUMING: Self = Self(1 << 1);
334
335 #[inline]
337 pub const fn union(self, other: Self) -> Self {
338 Self(self.0 | other.0)
339 }
340
341 #[inline]
343 pub const fn contains(self, other: Self) -> bool {
344 (self.0 & other.0) == other.0
345 }
346}
347
348impl std::ops::BitOr for RenderEncoderOptions {
349 type Output = Self;
350 fn bitor(self, rhs: Self) -> Self {
351 Self(self.0 | rhs.0)
352 }
353}
354
355impl std::ops::BitAnd for RenderEncoderOptions {
356 type Output = Self;
357 fn bitand(self, rhs: Self) -> Self {
358 Self(self.0 & rhs.0)
359 }
360}
361
362#[cfg(test)]
363mod tests {
364 use super::*;
365
366 #[test]
367 fn test_command_queue_error_values() {
368 assert_eq!(CommandQueueError::NONE.0, 0);
369 assert_eq!(CommandQueueError::TIMEOUT.0, 1);
370 assert_eq!(CommandQueueError::NOT_PERMITTED.0, 2);
371 assert_eq!(CommandQueueError::OUT_OF_MEMORY.0, 3);
372 assert_eq!(CommandQueueError::DEVICE_REMOVED.0, 4);
373 assert_eq!(CommandQueueError::ACCESS_REVOKED.0, 5);
374 assert_eq!(CommandQueueError::INTERNAL.0, 6);
375 }
376
377 #[test]
378 fn test_alpha_to_one_state_values() {
379 assert_eq!(AlphaToOneState::DISABLED.0, 0);
380 assert_eq!(AlphaToOneState::ENABLED.0, 1);
381 }
382
383 #[test]
384 fn test_alpha_to_coverage_state_values() {
385 assert_eq!(AlphaToCoverageState::DISABLED.0, 0);
386 assert_eq!(AlphaToCoverageState::ENABLED.0, 1);
387 }
388
389 #[test]
390 fn test_blend_state_values() {
391 assert_eq!(BlendState::DISABLED.0, 0);
392 assert_eq!(BlendState::ENABLED.0, 1);
393 assert_eq!(BlendState::UNSPECIALIZED.0, 2);
394 }
395
396 #[test]
397 fn test_indirect_command_buffer_support_state_values() {
398 assert_eq!(IndirectCommandBufferSupportState::DISABLED.0, 0);
399 assert_eq!(IndirectCommandBufferSupportState::ENABLED.0, 1);
400 }
401
402 #[test]
403 fn test_shader_reflection_values() {
404 assert_eq!(ShaderReflection::NONE.0, 0);
405 assert_eq!(ShaderReflection::BINDING_INFO.0, 1);
406 assert_eq!(ShaderReflection::BUFFER_TYPE_INFO.0, 2);
407
408 let combined = ShaderReflection::BINDING_INFO | ShaderReflection::BUFFER_TYPE_INFO;
409 assert_eq!(combined.0, 3);
410 assert!(combined.contains(ShaderReflection::BINDING_INFO));
411 assert!(combined.contains(ShaderReflection::BUFFER_TYPE_INFO));
412 }
413
414 #[test]
415 fn test_color_attachment_mapping_state_values() {
416 assert_eq!(LogicalToPhysicalColorAttachmentMappingState::IDENTITY.0, 0);
417 assert_eq!(LogicalToPhysicalColorAttachmentMappingState::INHERITED.0, 1);
418 }
419
420 #[test]
421 fn test_compiler_task_status_values() {
422 assert_eq!(CompilerTaskStatus::NONE.0, 0);
423 assert_eq!(CompilerTaskStatus::SCHEDULED.0, 1);
424 assert_eq!(CompilerTaskStatus::COMPILING.0, 2);
425 assert_eq!(CompilerTaskStatus::FINISHED.0, 3);
426 }
427
428 #[test]
429 fn test_binary_function_options_values() {
430 assert_eq!(BinaryFunctionOptions::NONE.0, 0);
431 assert_eq!(BinaryFunctionOptions::PIPELINE_INDEPENDENT.0, 2);
432 }
433
434 #[test]
435 fn test_pipeline_data_set_serializer_configuration_values() {
436 assert_eq!(
437 PipelineDataSetSerializerConfiguration::CAPTURE_DESCRIPTORS.0,
438 1
439 );
440 assert_eq!(
441 PipelineDataSetSerializerConfiguration::CAPTURE_BINARIES.0,
442 2
443 );
444
445 let combined = PipelineDataSetSerializerConfiguration::CAPTURE_DESCRIPTORS
446 | PipelineDataSetSerializerConfiguration::CAPTURE_BINARIES;
447 assert_eq!(combined.0, 3);
448 }
449
450 #[test]
451 fn test_visibility_options_values() {
452 assert_eq!(VisibilityOptions::NONE.0, 0);
453 assert_eq!(VisibilityOptions::DEVICE.0, 1);
454 assert_eq!(VisibilityOptions::RESOURCE_ALIAS.0, 2);
455
456 let combined = VisibilityOptions::DEVICE | VisibilityOptions::RESOURCE_ALIAS;
457 assert_eq!(combined.0, 3);
458 assert!(combined.contains(VisibilityOptions::DEVICE));
459 assert!(combined.contains(VisibilityOptions::RESOURCE_ALIAS));
460 }
461
462 #[test]
463 fn test_render_encoder_options_values() {
464 assert_eq!(RenderEncoderOptions::NONE.0, 0);
465 assert_eq!(RenderEncoderOptions::SUSPENDING.0, 1);
466 assert_eq!(RenderEncoderOptions::RESUMING.0, 2);
467
468 let combined = RenderEncoderOptions::SUSPENDING | RenderEncoderOptions::RESUMING;
469 assert_eq!(combined.0, 3);
470 assert!(combined.contains(RenderEncoderOptions::SUSPENDING));
471 assert!(combined.contains(RenderEncoderOptions::RESUMING));
472 }
473}