1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
use crate::format::Format;
use crate::image;
use crate::pso::PipelineStage;
use crate::Backend;
use std::ops::Range;
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum AttachmentLoadOp {
Load,
Clear,
DontCare,
}
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum AttachmentStoreOp {
Store,
DontCare,
}
pub type AttachmentLayout = image::Layout;
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct AttachmentOps {
pub load: AttachmentLoadOp,
pub store: AttachmentStoreOp,
}
impl AttachmentOps {
pub const DONT_CARE: Self = AttachmentOps {
load: AttachmentLoadOp::DontCare,
store: AttachmentStoreOp::DontCare,
};
pub const PRESERVE: Self = AttachmentOps {
load: AttachmentLoadOp::Load,
store: AttachmentStoreOp::Store,
};
pub fn new(load: AttachmentLoadOp, store: AttachmentStoreOp) -> Self {
AttachmentOps { load, store }
}
#[cfg(feature = "serde")]
fn whatever() -> Self {
Self::DONT_CARE
}
}
#[derive(Clone, Debug, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Attachment {
pub format: Option<Format>,
pub samples: image::NumSamples,
pub ops: AttachmentOps,
#[cfg_attr(feature = "serde", serde(default = "AttachmentOps::whatever"))]
pub stencil_ops: AttachmentOps,
pub layouts: Range<AttachmentLayout>,
}
impl Attachment {
pub fn has_clears(&self) -> bool {
self.ops.load == AttachmentLoadOp::Clear || self.stencil_ops.load == AttachmentLoadOp::Clear
}
}
pub type AttachmentId = usize;
pub type AttachmentRef = (AttachmentId, AttachmentLayout);
#[derive(Copy, Clone, Debug, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum SubpassRef {
External,
Pass(usize),
}
#[derive(Clone, Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct SubpassDependency {
pub passes: Range<SubpassRef>,
pub stages: Range<PipelineStage>,
pub accesses: Range<image::Access>,
}
#[derive(Debug)]
pub struct SubpassDesc<'a> {
pub colors: &'a [AttachmentRef],
pub depth_stencil: Option<&'a AttachmentRef>,
pub inputs: &'a [AttachmentRef],
pub resolves: &'a [AttachmentRef],
pub preserves: &'a [AttachmentId],
}
pub type SubpassId = usize;
#[derive(Debug)]
pub struct Subpass<'a, B: Backend> {
pub index: SubpassId,
pub main_pass: &'a B::RenderPass,
}
impl<'a, B: Backend> Clone for Subpass<'a, B> {
fn clone(&self) -> Self {
Subpass {
index: self.index,
main_pass: self.main_pass,
}
}
}
impl<'a, B: Backend> PartialEq for Subpass<'a, B> {
fn eq(&self, other: &Self) -> bool {
self.index == other.index && self.main_pass as *const _ == other.main_pass as *const _
}
}
impl<'a, B: Backend> Copy for Subpass<'a, B> {}
impl<'a, B: Backend> Eq for Subpass<'a, B> {}