Skip to main content

spirv_webgpu_transform/
correction.rs

1use super::*;
2
3// Q: Hey what happens when you stack corrections?
4// A: I don't want to think about it... I will start thinking after a refactor...
5
6#[repr(u16)]
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub enum CorrectionType {
9    /// A combined image sampler has been split, a new `sampler` object should be inserted.
10    SplitCombined = 0,
11    /// A mixed depth texture / sampler has been duplicated, insert the same object again with a `Regular` bind type.
12    SplitDrefRegular = 1,
13    /// A mixed depth texture / sampler has been duplicated, insert the same object again with a
14    /// `Comparison` bind type.
15    SplitDrefComparison = 2,
16    /// A storage cube texture has been converted into a storage texture 2D array, change the dimension.
17    ConvertStorageCube = 3,
18}
19
20#[derive(Debug, Clone, Default, PartialEq, Eq)]
21pub struct CorrectionBinding {
22    /// In order, what additional bindings have been appended to this one.
23    pub corrections: Vec<CorrectionType>,
24}
25
26#[derive(Debug, Clone, Default, PartialEq, Eq)]
27pub struct CorrectionSet {
28    pub bindings: HashMap<u32, CorrectionBinding>,
29}
30
31/// Lookup a set and a binding for a list of [`CorrectionType`].
32/// In order, insert a new variable for each, see [`CorrectionType`] for what type of object should
33/// be inserted for each variant.
34#[derive(Debug, Clone, Default, PartialEq, Eq)]
35pub struct CorrectionMap {
36    pub sets: HashMap<u32, CorrectionSet>,
37}