use crate::{AtomSize, Size};
#[derive(Debug)]
pub struct Memory<B: hal::Backend> {
raw: B::Memory,
size: Size,
properties: hal::memory::Properties,
pub(crate) non_coherent_atom_size: Option<AtomSize>,
}
impl<B: hal::Backend> Memory<B> {
pub fn properties(&self) -> hal::memory::Properties {
self.properties
}
pub fn size(&self) -> Size {
self.size
}
pub fn raw(&self) -> &B::Memory {
&self.raw
}
pub fn into_raw(self) -> B::Memory {
self.raw
}
pub unsafe fn from_raw(
raw: B::Memory,
size: Size,
properties: hal::memory::Properties,
non_coherent_atom_size: Option<AtomSize>,
) -> Self {
debug_assert_eq!(
non_coherent_atom_size.is_some(),
crate::is_non_coherent_visible(properties),
);
Memory {
properties,
raw,
size,
non_coherent_atom_size,
}
}
pub fn is_mappable(&self) -> bool {
self.properties
.contains(hal::memory::Properties::CPU_VISIBLE)
}
}