screen_13/graph/
swapchain.rs

1use {
2    super::{Bind, Binding, RenderGraph, SwapchainImageNode},
3    crate::driver::swapchain::SwapchainImage,
4};
5
6impl Bind<&mut RenderGraph, SwapchainImageNode> for SwapchainImage {
7    fn bind(self, graph: &mut RenderGraph) -> SwapchainImageNode {
8        // We will return a new node
9        let res = SwapchainImageNode::new(graph.bindings.len());
10
11        //trace!("Node {}: {:?}", res.idx, &self);
12
13        let binding = Binding::SwapchainImage(Box::new(self), true);
14        graph.bindings.push(binding);
15
16        res
17    }
18}
19
20impl Binding {
21    pub(super) fn as_swapchain_image(&self) -> Option<&SwapchainImage> {
22        if let Self::SwapchainImage(binding, true) = self {
23            Some(binding)
24        } else if let Self::SwapchainImage(_, false) = self {
25            // User code might try this - but it is a programmer error
26            // to access a binding after it has been unbound so dont
27            None
28        } else {
29            // The private code in this module should prevent this branch
30            unreachable!();
31        }
32    }
33}