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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub enum CorrectionType {
8 /// A combined image sampler has been split, a new `sampler` object should be inserted.
9 SplitCombined,
10 /// A mixed depth texture / sampler has been duplicated, insert the same object again with a `Regular` bind type.
11 SplitDrefRegular,
12 /// A mixed depth texture / sampler has been duplicated, insert the same object again with a
13 /// `Comparison` bind type.
14 SplitDrefComparison,
15 /// A storage cube texture has been converted into a storage texture 2D array, change the dimension.
16 ConvertStorageCube,
17 /// A binding array has been split into new variables. Insert the same resource again.
18 /// For an `N` sized array, expect `N-1` entries.
19 SplitBindingArray,
20}
21
22#[derive(Debug, Clone, Default, PartialEq, Eq)]
23pub struct CorrectionBinding {
24 /// In order, what additional bindings have been appended to this one.
25 pub corrections: Vec<CorrectionType>,
26}
27
28#[derive(Debug, Clone, Default, PartialEq, Eq)]
29pub struct CorrectionSet {
30 pub bindings: HashMap<u32, CorrectionBinding>,
31}
32
33/// Lookup a set and a binding for a list of [`CorrectionType`].
34/// In order, insert a new variable for each, see [`CorrectionType`] for what type of object should
35/// be inserted for each variant.
36#[derive(Debug, Clone, Default, PartialEq, Eq)]
37pub struct CorrectionMap {
38 pub sets: HashMap<u32, CorrectionSet>,
39}