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,
pub device_coherent_amd: bool,
pub device_uncached_amd: 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; }
if src.device_coherent_amd { *dst |= 0x00000040; }
if src.device_uncached_amd { *dst |= 0x00000080; }
}
}
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,
device_coherent_amd: (src & 0x00000040) != 0,
device_uncached_amd: (src & 0x00000080) != 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,
device_coherent_amd: false,
device_uncached_amd: 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,
device_coherent_amd: false,
device_uncached_amd: false,
}
}
pub fn all() -> Self {
VkMemoryPropertyFlags {
device_local: true,
host_visible: true,
host_coherent: true,
host_cached: true,
lazily_allocated: true,
protected: true,
device_coherent_amd: true,
device_uncached_amd: 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 }
+ if self.device_coherent_amd { 0x00000040 } else { 0 }
+ if self.device_uncached_amd { 0x00000080 } 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,
device_coherent_amd: value & 0x00000040 > 0,
device_uncached_amd: value & 0x00000080 > 0,
}
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! VkMemoryPropertyFlags {
( $( $x:ident ),* ) => {
VkMemoryPropertyFlags {
$($x: true,)*
..VkMemoryPropertyFlags::none()
}
}
}