From 933b4a5979cda996ef4dafab2693488f3a89fd0d Mon Sep 17 00:00:00 2001 From: janis Date: Sun, 12 Apr 2026 21:12:00 +0200 Subject: [PATCH] compiles! --- crates/renderer/src/egui.rs | 5 ++--- crates/renderer/src/lib.rs | 8 +++---- crates/renderer/src/render_graph/commands.rs | 4 ++-- crates/renderer/src/render_graph/recorder.rs | 22 ++++++++++---------- crates/renderer/src/rendering/mod.rs | 17 +++++++-------- 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/crates/renderer/src/egui.rs b/crates/renderer/src/egui.rs index 113e2d6..a8c90a3 100644 --- a/crates/renderer/src/egui.rs +++ b/crates/renderer/src/egui.rs @@ -631,7 +631,6 @@ pub fn egui_pass( let record: Box = Box::new({ let pipeline = egui_state.pipeline.clone(); - let pipeline_layout = egui_state.pipeline_layout.clone(); let descriptor_set = egui_state.descriptor_set; let screen_rect = egui.screen_rect(); @@ -733,7 +732,7 @@ pub fn egui_pass( cmd.bind_indices(indices.raw(), 0, vk::IndexType::UINT32); cmd.bind_vertex_buffers(&[vertices.raw()], &[0]); cmd.push_constants( - &pipeline_layout, + pipeline.layout(), vk::ShaderStageFlags::VERTEX, 0, bytemuck::cast_slice( @@ -741,7 +740,7 @@ pub fn egui_pass( ), ); cmd.bind_descriptor_sets( - &pipeline_layout, + pipeline.layout(), vk::PipelineBindPoint::GRAPHICS, &[descriptor_set], ); diff --git a/crates/renderer/src/lib.rs b/crates/renderer/src/lib.rs index 467805c..f693353 100644 --- a/crates/renderer/src/lib.rs +++ b/crates/renderer/src/lib.rs @@ -690,7 +690,6 @@ pub struct EguiState { descriptor_set: vk::DescriptorSet, #[allow(unused)] descriptor_layout: pipeline::DescriptorSetLayout, - pipeline_layout: Arc, pipeline: Arc, } @@ -789,7 +788,7 @@ impl EguiState { Result::Ok((descriptor_pool, descriptor_layout, sets)) })?; - let pipeline_layout = pipeline::PipelineLayout::new( + let pipeline_layout = Arc::new(pipeline::PipelineLayout::new( device.clone(), pipeline::PipelineLayoutDesc { descriptor_set_layouts: &[&descriptor_layout], @@ -800,7 +799,7 @@ impl EguiState { }], name: Some("egui-pipeline-layout".into()), }, - )?; + )?); let frag_shader = pipeline::ShaderModule::new_from_path( device.clone(), @@ -831,7 +830,7 @@ impl EguiState { }, ], render_pass: None, - layout: &pipeline_layout, + layout: pipeline_layout, subpass: None, base_pipeline: None, vertex_input: Some(pipeline::VertexInputState { @@ -915,7 +914,6 @@ impl EguiState { descriptor_layout, descriptor_set: sets[0], pipeline: Arc::new(pipeline), - pipeline_layout: Arc::new(pipeline_layout), }) } diff --git a/crates/renderer/src/render_graph/commands.rs b/crates/renderer/src/render_graph/commands.rs index e14be2c..47c468b 100644 --- a/crates/renderer/src/render_graph/commands.rs +++ b/crates/renderer/src/render_graph/commands.rs @@ -602,8 +602,8 @@ impl OutsideRenderPass for Copy {} impl OutsideRenderPass for ClearTexture {} impl OutsideRenderPass for UpdateBuffer {} -impl InsideRenderPass for BindPipeline {} -impl OutsideRenderPass for BindPipeline {} +impl InsideRenderPass for BindPipeline<'_> {} +impl OutsideRenderPass for BindPipeline<'_> {} impl InsideRenderPass for BindVertexBuffers {} impl OutsideRenderPass for BindVertexBuffers {} impl InsideRenderPass for BindIndexBuffer {} diff --git a/crates/renderer/src/render_graph/recorder.rs b/crates/renderer/src/render_graph/recorder.rs index f60b827..5e28a6f 100644 --- a/crates/renderer/src/render_graph/recorder.rs +++ b/crates/renderer/src/render_graph/recorder.rs @@ -97,40 +97,40 @@ impl<'a> SideEffectMap<'a> { } } -pub struct CommandList { +pub struct CommandList<'cmd> { command_bytes: Vec>, cursor: usize, // each command that accesses a resource adds an entry to this map (id, command_index) -> access // during command recording, we fold accesses to the same resource as commands are recorded, and when a command reads a resource, we check for any previous writes to be made available/visible side_effects: SideEffects, num_commands: u32, + + _pd: PhantomData, } #[must_use] -pub struct RenderPass<'a> { - cmd_list: &'a mut CommandList, +pub struct RenderPass<'cmd, 'a> { + cmd_list: &'a mut CommandList<'cmd>, } -impl<'a> RenderPass<'a> { +impl<'cmd, 'a> RenderPass<'cmd, 'a> { pub fn finalise(self) { self.cmd_list.push_inner(super::commands::EndRendering); } - pub fn push<'c, C: Command + InsideRenderPass + 'c>(&mut self, command: C) - where - 'c: 'a, - { + pub fn push(&mut self, command: C) { self.cmd_list.push_inner(command); } } -impl CommandList { +impl<'cmd> CommandList<'cmd> { pub fn new() -> Self { Self { command_bytes: Vec::new(), cursor: 0, side_effects: SideEffects::default(), num_commands: 0, + _pd: PhantomData, } } @@ -141,7 +141,7 @@ impl CommandList { stencil_attachment: Option, area: (u32, u32), layers: u32, - ) -> RenderPass<'_> { + ) -> RenderPass<'cmd, '_> { self.push(super::commands::BeginRendering { color_attachments, depth_attachment, @@ -152,7 +152,7 @@ impl CommandList { RenderPass { cmd_list: self } } - pub fn push(&mut self, command: C) { + pub fn push(&mut self, command: C) { self.push_inner(command); } diff --git a/crates/renderer/src/rendering/mod.rs b/crates/renderer/src/rendering/mod.rs index f40c39c..28a0fc4 100644 --- a/crates/renderer/src/rendering/mod.rs +++ b/crates/renderer/src/rendering/mod.rs @@ -26,7 +26,6 @@ pub struct Wireframe { num_indices: u32, colors: Arc, pipeline: Arc, - layout: Arc, } impl Wireframe { @@ -168,7 +167,7 @@ impl Wireframe { Arc::new(sync::Fence::from_pool(&dev.pools.fences, None)?), )?; - let (pipeline, layout) = Self::create_pipeline(dev.clone())?; + let pipeline = Self::create_pipeline(dev.clone())?; future.await; @@ -177,13 +176,12 @@ impl Wireframe { indices: Arc::new(indices), colors: Arc::new(colors), pipeline: Arc::new(pipeline), - layout: Arc::new(layout), num_indices, }) } - fn create_pipeline(device: Device) -> Result<(pipeline::Pipeline, pipeline::PipelineLayout)> { - let pipeline_layout = pipeline::PipelineLayout::new( + fn create_pipeline(device: Device) -> Result { + let pipeline_layout = Arc::new(pipeline::PipelineLayout::new( device.clone(), pipeline::PipelineLayoutDesc { descriptor_set_layouts: &[], @@ -194,7 +192,7 @@ impl Wireframe { }], name: Some("wireframe-pipeline-layout".into()), }, - )?; + )?); let shader = pipeline::ShaderModule::new_from_path( device.clone(), @@ -221,7 +219,7 @@ impl Wireframe { }, ], render_pass: None, - layout: &pipeline_layout, + layout: pipeline_layout, subpass: None, base_pipeline: None, vertex_input: Some(pipeline::VertexInputState { @@ -301,7 +299,7 @@ impl Wireframe { }, )?; - Ok((pipeline, pipeline_layout)) + Ok(pipeline) } pub fn pass(&self, rg: &mut RenderGraph, target: GraphResourceId) -> Result<()> { @@ -315,7 +313,6 @@ impl Wireframe { let num_indices = self.num_indices; let pipeline = self.pipeline.clone(); - let layout = self.layout.clone(); move |ctx: &RenderContext| -> Result<()> { let target = ctx.get_image(target).unwrap(); @@ -361,7 +358,7 @@ impl Wireframe { cmd.bind_indices(indices.raw(), 0, vk::IndexType::UINT32); cmd.bind_vertex_buffers(&[positions.raw(), colors.raw()], &[0, 0]); cmd.push_constants( - &layout, + &pipeline.layout(), vk::ShaderStageFlags::VERTEX, 0, bytemuck::cast_slice(&[to_clip]),