memkit_gpu/memory.rs
1//! GPU memory types.
2
3/// GPU memory type classification.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum MkMemoryType {
6 /// Device-local memory (fastest for GPU, not CPU-accessible).
7 DeviceLocal,
8
9 /// Host-visible memory (CPU can read/write, slower for GPU).
10 HostVisible,
11
12 /// Host-cached memory (CPU-cached, good for readback).
13 HostCached,
14
15 /// Unified memory (shared between CPU and GPU, if available).
16 Unified,
17}
18
19impl Default for MkMemoryType {
20 fn default() -> Self {
21 Self::DeviceLocal
22 }
23}
24
25impl MkMemoryType {
26 /// Check if this memory type is CPU-accessible.
27 pub fn is_host_accessible(&self) -> bool {
28 matches!(self, Self::HostVisible | Self::HostCached | Self::Unified)
29 }
30
31 /// Check if this memory type is device-local.
32 pub fn is_device_local(&self) -> bool {
33 matches!(self, Self::DeviceLocal | Self::Unified)
34 }
35}