aboutsummaryrefslogtreecommitdiff
path: root/stockton-skeleton/src
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:24 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:24 +0100
commit1d0dbcd1750cb1dd0060fc8dfa3ba8a64b7f8afe (patch)
treea4bc4fe9f3b4113dc523473af14db89653168991 /stockton-skeleton/src
parent5360fe6a337145b2640ec1e5727c97fd9bbeacd9 (diff)
fix(skeleton): add used_layout to renderpass
fixes validation errors
Diffstat (limited to 'stockton-skeleton/src')
-rw-r--r--stockton-skeleton/src/builders/renderpass.rs35
1 files changed, 23 insertions, 12 deletions
diff --git a/stockton-skeleton/src/builders/renderpass.rs b/stockton-skeleton/src/builders/renderpass.rs
index 43f0eb2..7a01412 100644
--- a/stockton-skeleton/src/builders/renderpass.rs
+++ b/stockton-skeleton/src/builders/renderpass.rs
@@ -3,14 +3,24 @@ use crate::types::*;
use std::iter::{empty, once};
use anyhow::Result;
-use hal::pass::{Attachment, AttachmentRef, SubpassDesc};
+use hal::pass::{Attachment, AttachmentLayout, AttachmentRef, SubpassDesc};
+
+/// An attachment for a renderpass
+#[derive(Debug, Clone)]
+pub struct AttachmentSpec {
+ /// The attachment description for gfx-hal
+ pub attachment: Attachment,
+
+ /// The layout that the image should be transitioned to while this pass is in use.
+ pub used_layout: AttachmentLayout,
+}
#[derive(Debug, Clone)]
pub struct RenderpassSpec {
- pub colors: Vec<Attachment>,
- pub depth: Option<Attachment>,
- pub inputs: Vec<Attachment>,
- pub resolves: Vec<Attachment>,
+ pub colors: Vec<AttachmentSpec>,
+ pub depth: Option<AttachmentSpec>,
+ pub inputs: Vec<AttachmentSpec>,
+ pub resolves: Vec<AttachmentSpec>,
pub preserves: Vec<Attachment>,
}
@@ -22,11 +32,11 @@ impl RenderpassSpec {
.colors
.iter()
.enumerate()
- .map(|(i, a)| (next_offset + i, a.layouts.end))
+ .map(|(i, a)| (next_offset + i, a.used_layout))
.collect();
next_offset = colors.len();
- let depth_stencil = self.depth.as_ref().map(|x| (next_offset, x.layouts.end));
+ let depth_stencil = self.depth.as_ref().map(|x| (next_offset, x.used_layout));
if depth_stencil.is_some() {
next_offset += 1;
}
@@ -35,7 +45,7 @@ impl RenderpassSpec {
.inputs
.iter()
.enumerate()
- .map(|(i, a)| (next_offset + i, a.layouts.end))
+ .map(|(i, a)| (next_offset + i, a.used_layout))
.collect();
next_offset += inputs.len();
@@ -43,7 +53,7 @@ impl RenderpassSpec {
.resolves
.iter()
.enumerate()
- .map(|(i, a)| (next_offset + i, a.layouts.end))
+ .map(|(i, a)| (next_offset + i, a.used_layout))
.collect();
next_offset += resolves.len();
@@ -65,9 +75,10 @@ impl RenderpassSpec {
let all_attachments = self
.colors
.into_iter()
- .chain(self.depth.into_iter())
- .chain(self.inputs.into_iter())
- .chain(self.resolves.into_iter())
+ .map(|x| x.attachment)
+ .chain(self.depth.into_iter().map(|x| x.attachment))
+ .chain(self.inputs.into_iter().map(|x| x.attachment))
+ .chain(self.resolves.into_iter().map(|x| x.attachment))
.chain(self.preserves.into_iter());
Ok(unsafe { device.create_render_pass(all_attachments, once(sp_desc), empty())? })