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
use {
super::{Bind, Binding, RenderGraph, Resolver, SwapchainImageNode, Unbind},
crate::driver::SwapchainImage,
archery::SharedPointerKind,
std::{fmt::Debug, mem::replace},
vk_sync::AccessType,
};
#[derive(Debug)]
pub struct SwapchainImageBinding<P>
where
P: SharedPointerKind,
{
pub(super) item: SwapchainImage<P>,
pub(super) access: AccessType,
}
impl<P> SwapchainImageBinding<P>
where
P: SharedPointerKind,
{
pub(super) fn new(item: SwapchainImage<P>) -> Self {
Self::new_unbind(item, AccessType::Nothing)
}
pub(super) fn new_unbind(item: SwapchainImage<P>, access: AccessType) -> Self {
Self { item, access }
}
pub(super) fn access_mut(&mut self, access: AccessType) -> AccessType {
replace(&mut self.access, access)
}
}
impl<P> Bind<&mut RenderGraph<P>, SwapchainImageNode<P>, P> for SwapchainImage<P>
where
P: SharedPointerKind,
{
fn bind(self, graph: &mut RenderGraph<P>) -> SwapchainImageNode<P> {
let res = SwapchainImageNode::new(graph.bindings.len());
let binding = Binding::SwapchainImage(SwapchainImageBinding::new(self), true);
graph.bindings.push(binding);
res
}
}
impl<P> Bind<&mut RenderGraph<P>, SwapchainImageNode<P>, P> for SwapchainImageBinding<P>
where
P: SharedPointerKind,
{
fn bind(self, graph: &mut RenderGraph<P>) -> SwapchainImageNode<P> {
let res = SwapchainImageNode::new(graph.bindings.len());
graph.bindings.push(Binding::SwapchainImage(self, true));
res
}
}
impl<P> Binding<P>
where
P: SharedPointerKind,
{
pub(super) fn as_swapchain_image(&self) -> Option<&SwapchainImageBinding<P>> {
if let Self::SwapchainImage(binding, true) = self {
Some(binding)
} else if let Self::SwapchainImage(_, false) = self {
None
} else {
unreachable!();
}
}
}
impl<P> Unbind<Resolver<P>, SwapchainImage<P>> for SwapchainImageNode<P>
where
P: SharedPointerKind + Send,
{
fn unbind(self, graph: &mut Resolver<P>) -> SwapchainImage<P> {
graph.graph.bindings[self.idx]
.as_swapchain_image()
.unwrap()
.item
.clone()
}
}