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
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)
}
}