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
use {
super::{Bind, Binding, RenderGraph, Resolver, SwapchainImageNode, Unbind},
crate::driver::SwapchainImage,
};
impl Bind<&mut RenderGraph, SwapchainImageNode> for SwapchainImage {
fn bind(self, graph: &mut RenderGraph) -> SwapchainImageNode {
let res = SwapchainImageNode::new(graph.bindings.len());
let binding = Binding::SwapchainImage(Box::new(self), true);
graph.bindings.push(binding);
res
}
}
impl Binding {
pub(super) fn as_swapchain_image(&self) -> Option<&SwapchainImage> {
if let Self::SwapchainImage(binding, true) = self {
Some(binding)
} else if let Self::SwapchainImage(_, false) = self {
None
} else {
unreachable!();
}
}
}
impl Unbind<Resolver, SwapchainImage> for SwapchainImageNode {
fn unbind(self, graph: &mut Resolver) -> SwapchainImage {
graph.graph.bindings[self.idx]
.as_swapchain_image()
.unwrap()
.clone()
}
}