Skip to main content

euv_engine/renderer/descriptor/
enum.rs

1use super::*;
2
3/// A single binding entry inside a `BindGroupDescriptor`.
4#[derive(Clone, Debug)]
5pub enum BindGroupEntry {
6    /// A uniform / storage buffer binding.
7    ///
8    /// In WGSL terms, the buffer's `usage` must include `UNIFORM` for
9    /// `var<uniform>` bindings and `STORAGE` for `var<storage>` bindings.
10    Buffer {
11        /// The binding slot (matches `@binding(N)` in the shader).
12        binding: u32,
13        /// The `GpuBuffer` handle.
14        buffer: JsValue,
15        /// The byte offset into the buffer where the binding starts.
16        offset: u64,
17        /// The size in bytes of the binding. `None` means "until the end
18        /// of the buffer".
19        size: Option<u64>,
20    },
21    /// A read-write storage texture binding.
22    ///
23    /// The `GpuTexture` must have been created with `STORAGE_BINDING`
24    /// in its `usage` flag. Combine with `view` (a `GpuTextureView`)
25    /// obtained from `GpuTexture.createView()`.
26    StorageTexture {
27        /// The binding slot.
28        binding: u32,
29        /// The `GpuTextureView` handle.
30        view: JsValue,
31        /// `true` for `texture_storage_2d<format, read>` bindings,
32        /// `false` for `texture_storage_2d<format, read_write>` bindings.
33        read_only: bool,
34    },
35    /// A sampled texture binding.
36    Texture {
37        /// The binding slot.
38        binding: u32,
39        /// The `GpuTextureView` handle.
40        view: JsValue,
41    },
42    /// A sampler binding.
43    Sampler {
44        /// The binding slot.
45        binding: u32,
46        /// The `GpuSampler` handle.
47        sampler: JsValue,
48    },
49}
50
51/// The resource kind bound at a single slot of a `BindGroupLayoutEntry`.
52#[derive(Clone, Debug)]
53pub enum BindGroupEntryType {
54    /// `GpuBufferBindingLayout { type: "uniform" }`.
55    UniformBuffer,
56    /// `GpuBufferBindingLayout { type: "storage" | "read-only-storage" }`.
57    StorageBuffer {
58        /// `true` → `"read-only-storage"`, `false` → `"storage"`.
59        read_only: bool,
60    },
61    /// `GpuTextureBindingLayout`.
62    SampledTexture {
63        /// One of `"float"`, `"unfilterable-float"`, `"depth"`, `"sint"`, `"uint"`.
64        sample_type: String,
65        /// `true` if the bound texture is multisampled (matches MSAA render-target sampling).
66        multisampled: bool,
67    },
68    /// `GpuStorageTextureBindingLayout`.
69    StorageTexture {
70        /// `true` → `"read-only"`, `false` → `"read-write"`.
71        read_only: bool,
72        /// Texture format string (e.g. `"rgba8unorm"`, `"r32float"`).
73        format: String,
74    },
75    /// `GpuSamplerBindingLayout`.
76    Sampler {
77        /// `true` for filtering samplers (linear interpolation).
78        filtering: bool,
79        /// `true` for comparison samplers (depth-texture sampling).
80        comparison: bool,
81    },
82}