Debian Codegraph @

third_party/rust/metal/src/types.rs

raw
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::NSUInteger;
9 use std::default::Default;
10
11 /// See <https://developer.apple.com/documentation/metal/mtlorigin>
12 #[repr(C)]
13 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
14 pub struct MTLOrigin {
15 pub x: NSUInteger,
16 pub y: NSUInteger,
17 pub z: NSUInteger,
18 }
19
20 /// See <https://developer.apple.com/documentation/metal/mtlsize>
21 #[repr(C)]
22 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
23 pub struct MTLSize {
24 pub width: NSUInteger,
25 pub height: NSUInteger,
26 pub depth: NSUInteger,
27 }
28
29 impl MTLSize {
30 pub fn new(width: NSUInteger, height: NSUInteger, depth: NSUInteger) -> Self {
31 Self {
32 width,
33 height,
34 depth,
35 }
36 }
37 }
38
39 /// See <https://developer.apple.com/documentation/metal/mtlregion>
40 #[repr(C)]
41 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
42 pub struct MTLRegion {
43 pub origin: MTLOrigin,
44 pub size: MTLSize,
45 }
46
47 impl MTLRegion {
48 #[inline]
49 pub fn new_1d(x: NSUInteger, width: NSUInteger) -> Self {
50 Self::new_2d(x, 0, width, 1)
51 }
52
53 #[inline]
54 pub fn new_2d(x: NSUInteger, y: NSUInteger, width: NSUInteger, height: NSUInteger) -> Self {
55 Self::new_3d(x, y, 0, width, height, 1)
56 }
57
58 #[inline]
59 pub fn new_3d(
60 x: NSUInteger,
61 y: NSUInteger,
62 z: NSUInteger,
63 width: NSUInteger,
64 height: NSUInteger,
65 depth: NSUInteger,
66 ) -> Self {
67 Self {
68 origin: MTLOrigin { x, y, z },
69 size: MTLSize {
70 width,
71 height,
72 depth,
73 },
74 }
75 }
76 }
77
78 /// See <https://developer.apple.com/documentation/metal/mtlsampleposition>
79 #[repr(C)]
80 #[derive(Copy, Clone, Debug, PartialEq, Default)]
81 pub struct MTLSamplePosition {
82 pub x: f32,
83 pub y: f32,
84 }
85
86 #[repr(C)]
87 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
88 pub struct MTLResourceID {
89 pub _impl: u64,
90 }