use {
super::{Bind, Binding, RenderGraph, Resolver, SwapchainImageNode, Unbind},
crate::driver::swapchain::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()
}
}