Take old RenderTarget by reference

This commit is contained in:
hodasemi 2023-01-21 17:00:41 +01:00
parent e4deefae99
commit d33f89be02

View file

@ -8,19 +8,19 @@ use std::sync::{
pub mod sub_pass;
use sub_pass::{AttachmentInfo, AttachmentInfoUsage, SubPass};
pub struct RenderTargetBuilder {
old_render_target: Option<RenderTarget>,
pub struct RenderTargetBuilder<'a> {
old_render_target: Option<&'a RenderTarget>,
sub_passes: Vec<SubPass>,
}
impl RenderTargetBuilder {
impl<'a> RenderTargetBuilder<'a> {
pub fn add_sub_pass(mut self, sub_pass: SubPass) -> Self {
self.sub_passes.push(sub_pass);
self
}
pub fn preserve_old_render_pass(mut self, render_target: RenderTarget) -> Self {
pub fn preserve_old_render_pass(mut self, render_target: &'a RenderTarget) -> Self {
self.old_render_target = Some(render_target);
self
@ -55,7 +55,7 @@ impl RenderTargetBuilder {
));
}
old_render_target.render_pass
old_render_target.render_pass.clone()
}
None => {
// gather attachment descriptions
@ -236,9 +236,9 @@ impl RenderTargetBuilder {
}
#[inline]
fn map_attachment<'a, F>(&'a self, mut f: F)
fn map_attachment<'b, F>(&'b self, mut f: F)
where
F: FnMut(&'a AttachmentInfo) -> (),
F: FnMut(&'b AttachmentInfo) -> (),
{
for sub_pass in self.sub_passes.iter() {
for attachment in sub_pass.attachments().iter() {
@ -274,7 +274,7 @@ pub struct RenderTarget {
}
impl RenderTarget {
pub fn builder() -> RenderTargetBuilder {
pub fn builder<'a>() -> RenderTargetBuilder<'a> {
RenderTargetBuilder {
old_render_target: None,
sub_passes: Vec::new(),