use crate::backend::MkGpuBackend;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MkBufferUsage(u32);
impl MkBufferUsage {
pub const TRANSFER_SRC: Self = Self(0x0001);
pub const TRANSFER_DST: Self = Self(0x0002);
pub const UNIFORM: Self = Self(0x0010);
pub const STORAGE: Self = Self(0x0020);
pub const VERTEX: Self = Self(0x0080);
pub const INDEX: Self = Self(0x0040);
pub const fn or(self, other: Self) -> Self {
Self(self.0 | other.0)
}
pub const fn contains(self, other: Self) -> bool {
(self.0 & other.0) == other.0
}
}
impl std::ops::BitOr for MkBufferUsage {
type Output = Self;
fn bitor(self, rhs: Self) -> Self::Output {
Self(self.0 | rhs.0)
}
}
pub struct MkDeviceBuffer<B: MkGpuBackend> {
handle: B::BufferHandle,
size: usize,
usage: MkBufferUsage,
}
impl<B: MkGpuBackend> MkDeviceBuffer<B> {
pub(crate) fn new(handle: B::BufferHandle, size: usize, usage: MkBufferUsage) -> Self {
Self { handle, size, usage }
}
pub fn size(&self) -> usize {
self.size
}
pub fn usage(&self) -> MkBufferUsage {
self.usage
}
pub fn handle(&self) -> &B::BufferHandle {
&self.handle
}
}