From dde3093536718ff5546d7dabecf4519ee455b6fa Mon Sep 17 00:00:00 2001 From: janis Date: Sun, 12 Apr 2026 20:23:19 +0200 Subject: [PATCH] keep layout around in pipeline --- crates/renderer/src/pipeline.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/renderer/src/pipeline.rs b/crates/renderer/src/pipeline.rs index 3302376..6fe5707 100644 --- a/crates/renderer/src/pipeline.rs +++ b/crates/renderer/src/pipeline.rs @@ -19,6 +19,16 @@ pub struct ShaderStageDesc<'a> { // specialization: Option } +impl ShaderStageDesc<'_> { + fn as_create_info(&'_ self) -> vk::PipelineShaderStageCreateInfo<'_> { + vk::PipelineShaderStageCreateInfo::default() + .module(self.module.raw()) + .flags(self.flags) + .stage(self.stage) + .name(&self.entry) + } +} + #[derive(Debug, Default)] pub struct DescriptorSetLayoutBindingDesc { pub binding: u32, @@ -189,7 +199,7 @@ pub struct GraphicsPipelineDesc<'a> { pub name: Option>, pub shader_stages: &'a [ShaderStageDesc<'a>], pub render_pass: Option, - pub layout: &'a PipelineLayout, + pub layout: Arc, pub subpass: Option, pub base_pipeline: Option>, @@ -544,6 +554,7 @@ impl ShaderModule { pub struct Pipeline { pipeline: DeviceObject, bind_point: vk::PipelineBindPoint, + layout: Arc, } impl> ExternallyManagedObject for vk::Pipeline { @@ -554,16 +565,6 @@ impl> ExternallyManagedObject for vk::Pipeline { } } -impl ShaderStageDesc<'_> { - fn as_create_info(&'_ self) -> vk::PipelineShaderStageCreateInfo<'_> { - vk::PipelineShaderStageCreateInfo::default() - .module(self.module.raw()) - .flags(self.flags) - .stage(self.stage) - .name(&self.entry) - } -} - impl Pipeline { pub fn new_compute(device: Device, desc: ComputePipelineDesc) -> crate::Result { let info = &vk::ComputePipelineCreateInfo::default() @@ -593,6 +594,7 @@ impl Pipeline { Ok(Self { pipeline: DeviceObject::new_debug_named(device, pipeline, desc.name), bind_point: vk::PipelineBindPoint::COMPUTE, + layout: desc.layout, }) } @@ -761,6 +763,7 @@ impl Pipeline { Ok(Self { pipeline: DeviceObject::new_debug_named(device, pipeline, desc.name), bind_point: vk::PipelineBindPoint::GRAPHICS, + layout: desc.layout, }) }