1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright 2016 GFX developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use super::NSUInteger;
use std::default::Default;
/// See <https://developer.apple.com/documentation/metal/mtlorigin>
#[repr(C)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
pub struct MTLOrigin {
pub x: NSUInteger,
pub y: NSUInteger,
pub z: NSUInteger,
}
/// See <https://developer.apple.com/documentation/metal/mtlsize>
#[repr(C)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
pub struct MTLSize {
pub width: NSUInteger,
pub height: NSUInteger,
pub depth: NSUInteger,
}
impl MTLSize {
pub fn new(width: NSUInteger, height: NSUInteger, depth: NSUInteger) -> Self {
Self {
width,
height,
depth,
}
}
}
/// See <https://developer.apple.com/documentation/metal/mtlregion>
#[repr(C)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
pub struct MTLRegion {
pub origin: MTLOrigin,
pub size: MTLSize,
}
impl MTLRegion {
#[inline]
pub fn new_1d(x: NSUInteger, width: NSUInteger) -> Self {
Self::new_2d(x, 0, width, 1)
}
#[inline]
pub fn new_2d(x: NSUInteger, y: NSUInteger, width: NSUInteger, height: NSUInteger) -> Self {
Self::new_3d(x, y, 0, width, height, 1)
}
#[inline]
pub fn new_3d(
x: NSUInteger,
y: NSUInteger,
z: NSUInteger,
width: NSUInteger,
height: NSUInteger,
depth: NSUInteger,
) -> Self {
Self {
origin: MTLOrigin { x, y, z },
size: MTLSize {
width,
height,
depth,
},
}
}
}
/// See <https://developer.apple.com/documentation/metal/mtlsampleposition>
#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq, Default)]
pub struct MTLSamplePosition {
pub x: f32,
pub y: f32,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
pub struct MTLResourceID {
pub _impl: u64,
}
|