gpu_alloc_types/types.rs
1bitflags::bitflags! {
2 /// Memory properties type.
3 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4 #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5 pub struct MemoryPropertyFlags: u8 {
6 /// This flag is set for device-local memory types.
7 /// Device-local memory is situated "close" to the GPU cores
8 /// and allows for fast access.
9 const DEVICE_LOCAL = 0x01;
10
11 /// This flag is set for host-visible memory types.
12 /// Host-visible memory can be mapped to the host memory range.
13 const HOST_VISIBLE = 0x02;
14
15 /// This flag is set for host-coherent memory types.
16 /// Host-coherent memory does not requires manual invalidation for
17 /// modifications on GPU to become visible on host;
18 /// nor flush for modification on host to become visible on GPU.
19 /// Access synchronization is still required.
20 const HOST_COHERENT = 0x04;
21
22 /// This flag is set for host-cached memory types.
23 /// Host-cached memory uses cache in host memory for faster reads from host.
24 const HOST_CACHED = 0x08;
25
26 /// This flag is set for lazily-allocated memory types.
27 /// Lazily-allocated memory must be used (and only) for transient image attachments.
28 const LAZILY_ALLOCATED = 0x10;
29
30 /// This flag is set for protected memory types.
31 /// Protected memory can be used for writing by protected operations
32 /// and can be read only by protected operations.
33 /// Protected memory cannot be host-visible.
34 /// Implementation must guarantee that there is no way for data to flow
35 /// from protected to unprotected memory.
36 const PROTECTED = 0x20;
37 }
38}
39
40/// Defines memory type.
41#[derive(Clone, Copy, Debug)]
42pub struct MemoryType {
43 /// Heap index of the memory type.
44 pub heap: u32,
45
46 /// Property flags of the memory type.
47 pub props: MemoryPropertyFlags,
48}
49
50/// Defines memory heap.
51#[derive(Clone, Copy, Debug)]
52pub struct MemoryHeap {
53 /// Size of memory heap in bytes.
54 pub size: u64,
55}