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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
use utils::vk_traits::*;
#[derive(Debug, Clone)]
pub struct VkMemoryPropertyFlags {
pub device_local: bool,
pub host_visible: bool,
pub host_coherent: bool,
pub host_cached: bool,
pub lazily_allocated: bool,
pub protected: bool,
}
#[doc(hidden)]
pub type RawVkMemoryPropertyFlags = u32;
impl VkWrappedType<RawVkMemoryPropertyFlags> for VkMemoryPropertyFlags {
fn vk_to_raw(src: &VkMemoryPropertyFlags, dst: &mut RawVkMemoryPropertyFlags) {
*dst = 0;
if src.device_local { *dst |= 0x00000001; }
if src.host_visible { *dst |= 0x00000002; }
if src.host_coherent { *dst |= 0x00000004; }
if src.host_cached { *dst |= 0x00000008; }
if src.lazily_allocated { *dst |= 0x00000010; }
if src.protected { *dst |= 0x00000020; }
}
}
impl VkRawType<VkMemoryPropertyFlags> for RawVkMemoryPropertyFlags {
fn vk_to_wrapped(src: &RawVkMemoryPropertyFlags) -> VkMemoryPropertyFlags {
VkMemoryPropertyFlags {
device_local: (src & 0x00000001) != 0,
host_visible: (src & 0x00000002) != 0,
host_coherent: (src & 0x00000004) != 0,
host_cached: (src & 0x00000008) != 0,
lazily_allocated: (src & 0x00000010) != 0,
protected: (src & 0x00000020) != 0,
}
}
}
impl Default for VkMemoryPropertyFlags {
fn default() -> VkMemoryPropertyFlags {
VkMemoryPropertyFlags {
device_local: false,
host_visible: false,
host_coherent: false,
host_cached: false,
lazily_allocated: false,
protected: false,
}
}
}
impl VkMemoryPropertyFlags {
pub fn none() -> Self {
VkMemoryPropertyFlags {
device_local: false,
host_visible: false,
host_coherent: false,
host_cached: false,
lazily_allocated: false,
protected: false,
}
}
pub fn all() -> Self {
VkMemoryPropertyFlags {
device_local: true,
host_visible: true,
host_coherent: true,
host_cached: true,
lazily_allocated: true,
protected: true,
}
}
pub fn to_u32(&self) -> u32 {
0
+ if self.device_local { 0x00000001 } else { 0 }
+ if self.host_visible { 0x00000002 } else { 0 }
+ if self.host_coherent { 0x00000004 } else { 0 }
+ if self.host_cached { 0x00000008 } else { 0 }
+ if self.lazily_allocated { 0x00000010 } else { 0 }
+ if self.protected { 0x00000020 } else { 0 }
}
pub fn from_u32(value: u32) -> Self {
VkMemoryPropertyFlags {
device_local: value & 0x00000001 > 0,
host_visible: value & 0x00000002 > 0,
host_coherent: value & 0x00000004 > 0,
host_cached: value & 0x00000008 > 0,
lazily_allocated: value & 0x00000010 > 0,
protected: value & 0x00000020 > 0,
}
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! VkMemoryPropertyFlags {
( $( $x:ident ),* ) => {
VkMemoryPropertyFlags {
$($x: true,)*
..VkMemoryPropertyFlags::none()
}
}
}