From 3c6baa591dc70cc076bf3175855b2b5d2f8670fe Mon Sep 17 00:00:00 2001 From: janis Date: Sun, 12 Apr 2026 21:39:17 +0200 Subject: [PATCH] fix safety with lifetime of commandlist --- crates/renderer/src/render_graph/commands.rs | 10 +++++----- crates/renderer/src/render_graph/recorder.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/renderer/src/render_graph/commands.rs b/crates/renderer/src/render_graph/commands.rs index 47c468b..7b921ef 100644 --- a/crates/renderer/src/render_graph/commands.rs +++ b/crates/renderer/src/render_graph/commands.rs @@ -319,9 +319,9 @@ impl Command for EndRendering { fn apply(self, _recorder: &mut CommandRecorder) {} } -pub struct BindPipeline<'cmd>(pub &'cmd Pipeline); +pub struct BindPipeline(pub vk::Pipeline, pub vk::PipelineBindPoint); -impl<'cmd> Command for BindPipeline<'cmd> { +impl Command for BindPipeline { fn side_effects(&self, _map: SideEffectMap) { // No resource access, but affects the pipeline state } @@ -331,7 +331,7 @@ impl<'cmd> Command for BindPipeline<'cmd> { let dev = &cmd.device().raw; unsafe { - dev.cmd_bind_pipeline(cmd.raw(), self.0.bind_point(), self.0.raw()); + dev.cmd_bind_pipeline(cmd.raw(), self.1, self.0); } } } @@ -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 5e28a6f..68c1d4c 100644 --- a/crates/renderer/src/render_graph/recorder.rs +++ b/crates/renderer/src/render_graph/recorder.rs @@ -105,7 +105,7 @@ pub struct CommandList<'cmd> { side_effects: SideEffects, num_commands: u32, - _pd: PhantomData, + _pd: PhantomData<&'cmd ()>, } #[must_use] @@ -156,7 +156,7 @@ impl<'cmd> CommandList<'cmd> { self.push_inner(command); } - fn push_inner(&mut self, command: C) { + fn push_inner(&mut self, command: C) { #[repr(C, packed)] struct Packed { meta: CommandMeta,