aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stockton-render/src/level.rs44
-rw-r--r--stockton-render/src/ui.rs20
-rw-r--r--stockton-skeleton/src/builders/renderpass.rs35
3 files changed, 62 insertions, 37 deletions
diff --git a/stockton-render/src/level.rs b/stockton-render/src/level.rs
index fc5111e..0c88a0b 100644
--- a/stockton-render/src/level.rs
+++ b/stockton-render/src/level.rs
@@ -10,8 +10,8 @@ use stockton_skeleton::{
image::{BoundImageView, ImageSpec, DEPTH_RESOURCES},
},
builders::{
- CompletePipeline, PipelineSpecBuilder, RenderpassSpec, ShaderDesc, VertexBufferSpec,
- VertexPrimitiveAssemblerSpec,
+ AttachmentSpec, CompletePipeline, PipelineSpecBuilder, RenderpassSpec, ShaderDesc,
+ VertexBufferSpec, VertexPrimitiveAssemblerSpec,
},
context::RenderingContext,
draw_passes::{util::TargetSpecificResources, DrawPass, IntoDrawPass, PassPosition},
@@ -354,22 +354,32 @@ where
})
.push_constants(vec![(ShaderStageFlags::VERTEX, 0..64)])
.renderpass(RenderpassSpec {
- colors: vec![Attachment {
- format: Some(context.target_chain().properties().format),
- samples: 1,
- ops: P::attachment_ops(),
- stencil_ops: P::attachment_ops(),
- layouts: P::layout_as_range(),
+ colors: vec![AttachmentSpec {
+ attachment: Attachment {
+ format: Some(context.target_chain().properties().format),
+ samples: 1,
+ ops: P::attachment_ops(),
+ stencil_ops: P::attachment_ops(),
+ layouts: P::layout_as_range(),
+ },
+
+ used_layout: Layout::ColorAttachmentOptimal,
}],
- depth: Some(Attachment {
- format: Some(context.target_chain().properties().depth_format),
- samples: 1,
- ops: AttachmentOps::new(AttachmentLoadOp::Clear, AttachmentStoreOp::DontCare),
- stencil_ops: AttachmentOps::new(
- AttachmentLoadOp::DontCare,
- AttachmentStoreOp::DontCare,
- ),
- layouts: Layout::Undefined..Layout::DepthStencilAttachmentOptimal,
+ depth: Some(AttachmentSpec {
+ attachment: Attachment {
+ format: Some(context.target_chain().properties().depth_format),
+ samples: 1,
+ ops: AttachmentOps::new(
+ AttachmentLoadOp::Clear,
+ AttachmentStoreOp::DontCare,
+ ),
+ stencil_ops: AttachmentOps::new(
+ AttachmentLoadOp::DontCare,
+ AttachmentStoreOp::DontCare,
+ ),
+ layouts: Layout::Undefined..Layout::DepthStencilAttachmentOptimal,
+ },
+ used_layout: Layout::DepthStencilAttachmentOptimal,
}),
inputs: vec![],
resolves: vec![],
diff --git a/stockton-render/src/ui.rs b/stockton-render/src/ui.rs
index ad53d80..0d53c4f 100644
--- a/stockton-render/src/ui.rs
+++ b/stockton-render/src/ui.rs
@@ -4,8 +4,8 @@ use crate::window::UiState;
use stockton_skeleton::{
buffers::draw::DrawBuffers,
builders::{
- CompletePipeline, PipelineSpecBuilder, RenderpassSpec, ShaderDesc, VertexBufferSpec,
- VertexPrimitiveAssemblerSpec,
+ AttachmentSpec, CompletePipeline, PipelineSpecBuilder, RenderpassSpec, ShaderDesc,
+ VertexBufferSpec, VertexPrimitiveAssemblerSpec,
},
context::RenderingContext,
draw_passes::{util::TargetSpecificResources, DrawPass, IntoDrawPass, PassPosition},
@@ -33,6 +33,7 @@ use hal::{
buffer::SubRange,
command::{ClearColor, ClearValue, RenderAttachmentInfo, SubpassContents},
format::Format,
+ image::Layout,
pass::Attachment,
pso::{
BlendDesc, BlendOp, BlendState, ColorBlendDesc, ColorMask, DepthStencilDesc, Face, Factor,
@@ -261,12 +262,15 @@ impl<'a, P: PassPosition> IntoDrawPass<UiDrawPass<'a>, P> for () {
})
.push_constants(vec![(ShaderStageFlags::VERTEX, 0..8)])
.renderpass(RenderpassSpec {
- colors: vec![Attachment {
- format: Some(context.target_chain().properties().format),
- samples: 1,
- ops: P::attachment_ops(),
- stencil_ops: P::attachment_ops(),
- layouts: P::layout_as_range(),
+ colors: vec![AttachmentSpec {
+ attachment: Attachment {
+ format: Some(context.target_chain().properties().format),
+ samples: 1,
+ ops: P::attachment_ops(),
+ stencil_ops: P::attachment_ops(),
+ layouts: P::layout_as_range(),
+ },
+ used_layout: Layout::ColorAttachmentOptimal,
}],
depth: None,
inputs: vec![],
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())? })