aboutsummaryrefslogtreecommitdiff
path: root/stockton-skeleton/src/draw_passes/mod.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:23 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:23 +0100
commit0353181306702c40ad0fe482b5c2b159b46794a4 (patch)
tree33acc6a9e8ea4705884cf93b78cf869008f71832 /stockton-skeleton/src/draw_passes/mod.rs
parent664f0b0777ba96298b29f0c753d52a81cbb233f1 (diff)
refactor(all): rename some crates
Diffstat (limited to 'stockton-skeleton/src/draw_passes/mod.rs')
-rw-r--r--stockton-skeleton/src/draw_passes/mod.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/stockton-skeleton/src/draw_passes/mod.rs b/stockton-skeleton/src/draw_passes/mod.rs
new file mode 100644
index 0000000..a0dbba5
--- /dev/null
+++ b/stockton-skeleton/src/draw_passes/mod.rs
@@ -0,0 +1,47 @@
+//! Traits and common draw passes.
+use super::{queue_negotiator::QueueNegotiator, RenderingContext};
+use crate::types::*;
+use stockton_types::Session;
+
+use anyhow::Result;
+
+mod cons;
+pub mod util;
+
+pub use cons::ConsDrawPass;
+
+/// One of several 'passes' that draw on each frame.
+pub trait DrawPass {
+ /// Queue any necessary draw commands to cmd_buffer
+ /// This should assume the command buffer isn't in the middle of a renderpass, and should leave it as such.
+ fn queue_draw(
+ &mut self,
+ session: &Session,
+ img_view: &ImageViewT,
+ cmd_buffer: &mut CommandBufferT,
+ ) -> Result<()>;
+
+ /// Called just after the surface changes (probably a resize).
+ fn handle_surface_change(
+ &mut self,
+ session: &Session,
+ context: &mut RenderingContext,
+ ) -> Result<()>;
+
+ /// Deactivate any vulkan parts that need to be deactivated
+ fn deactivate(self, context: &mut RenderingContext) -> Result<()>;
+}
+
+/// A type that can be made into a specific draw pass type.
+/// This allows extra data to be used in initialisation without the Renderer needing to worry about it.
+pub trait IntoDrawPass<T: DrawPass> {
+ fn init(self, session: &mut Session, context: &mut RenderingContext) -> Result<T>;
+
+ /// This function should ask the queue negotatior to find families for any auxilary operations this draw pass needs to perform
+ /// For example, .find(&TexLoadQueue)
+ /// It should return then call .family_spec for each queue type negotiated and return the results.
+ fn find_aux_queues<'a>(
+ adapter: &'a Adapter,
+ queue_negotiator: &mut QueueNegotiator,
+ ) -> Result<Vec<(&'a QueueFamilyT, Vec<f32>)>>;
+}