Skip to main content

molgfx_gpu/descriptors/
buffer.rs

1//! Buffer descriptors.
2
3bitflags::bitflags! {
4    /// How a buffer may be used. Buffers are typed by usage and allocated
5    /// once; there is deliberately no per-frame creation convenience.
6    #[derive(Clone, Copy, PartialEq, Eq, Debug)]
7    pub struct BufferUsage: u32 {
8        /// Bound as a vertex buffer.
9        const VERTEX = 1;
10        /// Bound as an index buffer.
11        const INDEX = 1 << 1;
12        /// Bound as a uniform buffer.
13        const UNIFORM = 1 << 2;
14        /// Bound as a storage buffer.
15        const STORAGE = 1 << 3;
16        /// Source of indirect draw or dispatch arguments.
17        const INDIRECT = 1 << 4;
18        /// Source of GPU-to-GPU copies.
19        const COPY_SRC = 1 << 5;
20        /// Destination of uploads and GPU-to-GPU copies.
21        const COPY_DST = 1 << 6;
22        /// Mappable for reading back to the host. Off the frame path only:
23        /// golden-image capture, picking, export.
24        const MAP_READ = 1 << 7;
25        /// Destination for resolved GPU timestamp or occlusion queries.
26        const QUERY_RESOLVE = 1 << 8;
27        /// Procedural or triangle input consumed while building a BLAS.
28        const BLAS_INPUT = 1 << 9;
29    }
30}
31
32/// Everything needed to create a buffer.
33#[derive(Clone, Copy, Debug)]
34pub struct BufferDesc {
35    /// Debug label, surfaced in captures and validation messages.
36    pub label: &'static str,
37    /// Size in bytes.
38    pub size: u64,
39    /// Permitted usages.
40    pub usage: BufferUsage,
41}