From e1cc0e9a9d191bcd3a634be46fd3555d430b07a8 Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:23 +0100 Subject: feat(skeleton): draw pass aware of position --- stockton-render/src/camera.rs | 7 +++++-- stockton-render/src/level.rs | 24 +++++++++++------------- stockton-render/src/ui.rs | 18 +++++++----------- stockton-render/src/window.rs | 11 +++++++---- 4 files changed, 30 insertions(+), 30 deletions(-) (limited to 'stockton-render/src') diff --git a/stockton-render/src/camera.rs b/stockton-render/src/camera.rs index dcc9d93..6abc183 100644 --- a/stockton-render/src/camera.rs +++ b/stockton-render/src/camera.rs @@ -7,7 +7,10 @@ use stockton_types::{ Vector3, }; -use stockton_skeleton::{draw_passes::DrawPass, Renderer}; +use stockton_skeleton::{ + draw_passes::{DrawPass, Singular}, + Renderer, +}; fn euler_to_direction(euler: &Vector3) -> Vector3 { let pitch = euler.x; @@ -23,7 +26,7 @@ fn euler_to_direction(euler: &Vector3) -> Vector3 { #[system(for_each)] #[filter(maybe_changed::() | maybe_changed::())] -pub fn calc_vp_matrix( +pub fn calc_vp_matrix + 'static>( transform: &Transform, settings: &CameraSettings, matrix: &mut CameraVPMatrix, diff --git a/stockton-render/src/level.rs b/stockton-render/src/level.rs index 6c74211..0352ff7 100644 --- a/stockton-render/src/level.rs +++ b/stockton-render/src/level.rs @@ -13,7 +13,7 @@ use stockton_skeleton::{ VertexPrimitiveAssemblerSpec, }, context::RenderingContext, - draw_passes::{util::TargetSpecificResources, DrawPass, IntoDrawPass}, + draw_passes::{util::TargetSpecificResources, DrawPass, IntoDrawPass, PassPosition}, error::{EnvironmentError, LevelError, LockPoisoned}, queue_negotiator::QueueNegotiator, texture::{resolver::TextureResolver, TexLoadQueue, TextureLoadConfig, TextureRepo}, @@ -67,7 +67,7 @@ pub struct LevelDrawPass<'a, M> { _d: PhantomData, } -impl<'a, M> DrawPass for LevelDrawPass<'a, M> +impl<'a, M, P: PassPosition> DrawPass

for LevelDrawPass<'a, M> where M: for<'b> MinRenderFeatures<'b> + 'static, { @@ -269,10 +269,11 @@ pub struct LevelDrawPassConfig { pub tex_resolver: R, } -impl<'a, M, R> IntoDrawPass> for LevelDrawPassConfig +impl<'a, M, R, P> IntoDrawPass, P> for LevelDrawPassConfig where M: for<'b> MinRenderFeatures<'b> + 'static, R: TextureResolver + Send + Sync + 'static, + P: PassPosition, { fn init( self, @@ -303,12 +304,12 @@ where mask: ColorMask::ALL, blend: Some(BlendState { color: BlendOp::Add { - src: Factor::One, - dst: Factor::Zero, + src: Factor::SrcAlpha, + dst: Factor::OneMinusSrcAlpha, }, alpha: BlendOp::Add { - src: Factor::One, - dst: Factor::Zero, + src: Factor::SrcAlpha, + dst: Factor::OneMinusSrcAlpha, }, }), }], @@ -335,12 +336,9 @@ where colors: vec![Attachment { format: Some(context.target_chain().properties().format), samples: 1, - ops: AttachmentOps::new(AttachmentLoadOp::Clear, AttachmentStoreOp::Store), - stencil_ops: AttachmentOps::new( - AttachmentLoadOp::Clear, - AttachmentStoreOp::DontCare, - ), - layouts: Layout::ColorAttachmentOptimal..Layout::ColorAttachmentOptimal, + ops: P::attachment_ops(), + stencil_ops: P::attachment_ops(), + layouts: P::layout_as_range(), }], depth: Some(Attachment { format: Some(context.target_chain().properties().depth_format), diff --git a/stockton-render/src/ui.rs b/stockton-render/src/ui.rs index d1689be..77ff805 100644 --- a/stockton-render/src/ui.rs +++ b/stockton-render/src/ui.rs @@ -8,7 +8,7 @@ use stockton_skeleton::{ VertexPrimitiveAssemblerSpec, }, context::RenderingContext, - draw_passes::{util::TargetSpecificResources, DrawPass, IntoDrawPass}, + draw_passes::{util::TargetSpecificResources, DrawPass, IntoDrawPass, PassPosition}, error::{EnvironmentError, LockPoisoned}, queue_negotiator::QueueNegotiator, texture::{ @@ -32,8 +32,7 @@ use hal::{ buffer::SubRange, command::{ClearColor, ClearValue, RenderAttachmentInfo, SubpassContents}, format::Format, - image::Layout, - pass::{Attachment, AttachmentLoadOp, AttachmentOps, AttachmentStoreOp}, + pass::Attachment, pso::{ BlendDesc, BlendOp, BlendState, ColorBlendDesc, ColorMask, DepthStencilDesc, Face, Factor, FrontFace, InputAssemblerDesc, LogicOp, PolygonMode, Primitive, Rasterizer, Rect, @@ -54,7 +53,7 @@ pub struct UiDrawPass<'a> { framebuffers: TargetSpecificResources, } -impl<'a> DrawPass for UiDrawPass<'a> { +impl<'a, P: PassPosition> DrawPass

for UiDrawPass<'a> { fn queue_draw( &mut self, session: &Session, @@ -208,7 +207,7 @@ impl<'a> DrawPass for UiDrawPass<'a> { } } -impl<'a> IntoDrawPass> for () { +impl<'a, P: PassPosition> IntoDrawPass, P> for () { fn init(self, session: &mut Session, context: &mut RenderingContext) -> Result> { let spec = PipelineSpecBuilder::default() .rasterizer(Rasterizer { @@ -263,12 +262,9 @@ impl<'a> IntoDrawPass> for () { colors: vec![Attachment { format: Some(context.target_chain().properties().format), samples: 1, - ops: AttachmentOps::new(AttachmentLoadOp::Load, AttachmentStoreOp::Store), - stencil_ops: AttachmentOps::new( - AttachmentLoadOp::DontCare, - AttachmentStoreOp::DontCare, - ), - layouts: Layout::ColorAttachmentOptimal..Layout::ColorAttachmentOptimal, + ops: P::attachment_ops(), + stencil_ops: P::attachment_ops(), + layouts: P::layout_as_range(), }], depth: None, inputs: vec![], diff --git a/stockton-render/src/window.rs b/stockton-render/src/window.rs index 15dd5a6..da80915 100644 --- a/stockton-render/src/window.rs +++ b/stockton-render/src/window.rs @@ -1,5 +1,8 @@ use stockton_input::{Action as KBAction, InputManager, Mouse}; -use stockton_skeleton::{draw_passes::DrawPass, Renderer}; +use stockton_skeleton::{ + draw_passes::{DrawPass, Singular}, + Renderer, +}; use std::sync::{ mpsc::{channel, Receiver, Sender}, @@ -81,7 +84,7 @@ pub struct UiState { } impl UiState { - pub fn populate_initial_state(&mut self, renderer: &Renderer) { + pub fn populate_initial_state>(&mut self, renderer: &Renderer) { let props = &renderer.context().target_chain().properties(); self.set_dimensions(props.extent.width, props.extent.height); self.set_pixels_per_point(Some(renderer.context().pixels_per_point())); @@ -213,7 +216,7 @@ impl WindowFlow { #[system] /// A system to process the window events sent to renderer by the winit event loop. -pub fn _process_window_events( +pub fn _process_window_events>( #[resource] window_channel: &mut WindowFlow, #[resource] manager: &mut T, #[resource] mouse: &mut Mouse, @@ -270,7 +273,7 @@ pub fn _process_window_events manager.handle_frame(&actions_buf[0..actions_buf_cursor]); } -pub fn process_window_events_system( +pub fn process_window_events_system>( ) -> impl Runnable { _process_window_events_system::(Vec::with_capacity(4)) } -- cgit v1.2.3