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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_MAKE_VERSION.html>"] pub const fn make_version(major: u32, minor: u32, patch: u32) -> u32 { (major << 22) | (minor << 12) | patch } #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_VERSION_MAJOR.html>"] pub const fn version_major(version: u32) -> u32 { version >> 22 } #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_VERSION_MINOR.html>"] pub const fn version_minor(version: u32) -> u32 { (version >> 12) & 0x3ff } #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_VERSION_PATCH.html>"] pub const fn version_patch(version: u32) -> u32 { version & 0xfff } #[macro_export] macro_rules! vk_bitflags_wrapped { ( $ name : ident , $ all : expr , $ flag_type : ty ) => { impl Default for $name { fn default() -> $name { $name(0) } } impl $name { #[inline] pub const fn empty() -> $name { $name(0) } #[inline] pub const fn all() -> $name { $name($all) } #[inline] pub const fn from_raw(x: $flag_type) -> Self { $name(x) } #[inline] pub const fn as_raw(self) -> $flag_type { self.0 } #[inline] pub fn is_empty(self) -> bool { self == $name::empty() } #[inline] pub fn is_all(self) -> bool { self & $name::all() == $name::all() } #[inline] pub fn intersects(self, other: $name) -> bool { self & other != $name::empty() } #[doc = r" Returns whether `other` is a subset of `self`"] #[inline] pub fn contains(self, other: $name) -> bool { self & other == other } } impl ::std::ops::BitOr for $name { type Output = $name; #[inline] fn bitor(self, rhs: $name) -> $name { $name(self.0 | rhs.0) } } impl ::std::ops::BitOrAssign for $name { #[inline] fn bitor_assign(&mut self, rhs: $name) { *self = *self | rhs } } impl ::std::ops::BitAnd for $name { type Output = $name; #[inline] fn bitand(self, rhs: $name) -> $name { $name(self.0 & rhs.0) } } impl ::std::ops::BitAndAssign for $name { #[inline] fn bitand_assign(&mut self, rhs: $name) { *self = *self & rhs } } impl ::std::ops::BitXor for $name { type Output = $name; #[inline] fn bitxor(self, rhs: $name) -> $name { $name(self.0 ^ rhs.0) } } impl ::std::ops::BitXorAssign for $name { #[inline] fn bitxor_assign(&mut self, rhs: $name) { *self = *self ^ rhs } } impl ::std::ops::Sub for $name { type Output = $name; #[inline] fn sub(self, rhs: $name) -> $name { self & !rhs } } impl ::std::ops::SubAssign for $name { #[inline] fn sub_assign(&mut self, rhs: $name) { *self = *self - rhs } } impl ::std::ops::Not for $name { type Output = $name; #[inline] fn not(self) -> $name { self ^ $name::all() } } }; } #[macro_export] macro_rules! handle_nondispatchable { ( $ name : ident , $ ty : ident ) => { handle_nondispatchable!($name, $ty, doc = ""); }; ( $ name : ident , $ ty : ident , $ doc_link : meta ) => { #[repr(transparent)] #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Default)] #[$doc_link] pub struct $name(u64); impl Handle for $name { const TYPE: ObjectType = ObjectType::$ty; fn as_raw(self) -> u64 { self.0 as u64 } fn from_raw(x: u64) -> Self { $name(x as _) } } impl $name { pub const fn null() -> $name { $name(0) } } impl fmt::Pointer for $name { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "0x{:x}", self.0) } } impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "0x{:x}", self.0) } } }; } #[macro_export] macro_rules! define_handle { ( $ name : ident , $ ty : ident ) => { define_handle!($name, $ty, doc = ""); }; ( $ name : ident , $ ty : ident , $ doc_link : meta ) => { #[repr(transparent)] #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash)] #[$doc_link] pub struct $name(*mut u8); impl Default for $name { fn default() -> $name { $name::null() } } impl Handle for $name { const TYPE: ObjectType = ObjectType::$ty; fn as_raw(self) -> u64 { self.0 as u64 } fn from_raw(x: u64) -> Self { $name(x as _) } } unsafe impl Send for $name {} unsafe impl Sync for $name {} impl $name { pub const fn null() -> Self { $name(::std::ptr::null_mut()) } } impl fmt::Pointer for $name { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.0, f) } } impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&self.0, f) } } }; }