diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
commit | e1cc0e9a9d191bcd3a634be46fd3555d430b07a8 (patch) | |
tree | 7f984fbb55c935797217d105e93f3f415f35d226 /stockton-render/src | |
parent | 0353181306702c40ad0fe482b5c2b159b46794a4 (diff) |
feat(skeleton): draw pass aware of position
Diffstat (limited to 'stockton-render/src')
-rw-r--r-- | stockton-render/src/camera.rs | 7 | ||||
-rw-r--r-- | stockton-render/src/level.rs | 24 | ||||
-rw-r--r-- | stockton-render/src/ui.rs | 18 | ||||
-rw-r--r-- | stockton-render/src/window.rs | 11 |
4 files changed, 30 insertions, 30 deletions
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::<Transform>() | maybe_changed::<CameraSettings>())] -pub fn calc_vp_matrix<DP: DrawPass + 'static>( +pub fn calc_vp_matrix<DP: DrawPass<Singular> + '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<M>, } -impl<'a, M> DrawPass for LevelDrawPass<'a, M> +impl<'a, M, P: PassPosition> DrawPass<P> for LevelDrawPass<'a, M> where M: for<'b> MinRenderFeatures<'b> + 'static, { @@ -269,10 +269,11 @@ pub struct LevelDrawPassConfig<R> { pub tex_resolver: R, } -impl<'a, M, R> IntoDrawPass<LevelDrawPass<'a, M>> for LevelDrawPassConfig<R> +impl<'a, M, R, P> IntoDrawPass<LevelDrawPass<'a, M>, P> for LevelDrawPassConfig<R> 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<FramebufferT>, } -impl<'a> DrawPass for UiDrawPass<'a> { +impl<'a, P: PassPosition> DrawPass<P> for UiDrawPass<'a> { fn queue_draw( &mut self, session: &Session, @@ -208,7 +207,7 @@ impl<'a> DrawPass for UiDrawPass<'a> { } } -impl<'a> IntoDrawPass<UiDrawPass<'a>> for () { +impl<'a, P: PassPosition> IntoDrawPass<UiDrawPass<'a>, P> for () { fn init(self, session: &mut Session, context: &mut RenderingContext) -> Result<UiDrawPass<'a>> { let spec = PipelineSpecBuilder::default() .rasterizer(Rasterizer { @@ -263,12 +262,9 @@ impl<'a> IntoDrawPass<UiDrawPass<'a>> 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<T: DrawPass>(&mut self, renderer: &Renderer<T>) { + pub fn populate_initial_state<T: DrawPass<Singular>>(&mut self, renderer: &Renderer<T>) { 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<T: 'static + InputManager, DP: 'static + DrawPass>( +pub fn _process_window_events<T: 'static + InputManager, DP: 'static + DrawPass<Singular>>( #[resource] window_channel: &mut WindowFlow, #[resource] manager: &mut T, #[resource] mouse: &mut Mouse, @@ -270,7 +273,7 @@ pub fn _process_window_events<T: 'static + InputManager, DP: 'static + DrawPass> manager.handle_frame(&actions_buf[0..actions_buf_cursor]); } -pub fn process_window_events_system<T: 'static + InputManager, DP: 'static + DrawPass>( +pub fn process_window_events_system<T: 'static + InputManager, DP: 'static + DrawPass<Singular>>( ) -> impl Runnable { _process_window_events_system::<T, DP>(Vec::with_capacity(4)) } |