1use crate::backend::MkGpuBackend;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct MkBufferUsage(u32);
8
9impl MkBufferUsage {
10 pub const TRANSFER_SRC: Self = Self(0x0001);
11 pub const TRANSFER_DST: Self = Self(0x0002);
12 pub const UNIFORM: Self = Self(0x0010);
13 pub const STORAGE: Self = Self(0x0020);
14 pub const VERTEX: Self = Self(0x0080);
15 pub const INDEX: Self = Self(0x0040);
16
17 pub const fn or(self, other: Self) -> Self {
19 Self(self.0 | other.0)
20 }
21
22 pub const fn contains(self, other: Self) -> bool {
24 (self.0 & other.0) == other.0
25 }
26}
27
28impl std::ops::BitOr for MkBufferUsage {
29 type Output = Self;
30
31 fn bitor(self, rhs: Self) -> Self::Output {
32 Self(self.0 | rhs.0)
33 }
34}
35
36pub struct MkDeviceBuffer<B: MkGpuBackend> {
38 handle: B::BufferHandle,
39 size: usize,
40 usage: MkBufferUsage,
41}
42
43impl<B: MkGpuBackend> MkDeviceBuffer<B> {
44 pub(crate) fn new(handle: B::BufferHandle, size: usize, usage: MkBufferUsage) -> Self {
46 Self { handle, size, usage }
47 }
48
49 pub fn size(&self) -> usize {
51 self.size
52 }
53
54 pub fn usage(&self) -> MkBufferUsage {
56 self.usage
57 }
58
59 pub fn handle(&self) -> &B::BufferHandle {
61 &self.handle
62 }
63}