fix(renderer): plug shader-module and stale-handle leaks

create_graphics_pipeline now destroys its shader modules on the error
path as well, and update_mesh nulls the buffer handles after destroying
them so a later Drop or retry cannot redestroy freed buffers.
This commit is contained in:
Serkyo 2026-05-16 19:43:16 +02:00
parent 4130ebf5f9
commit f04912df70
2 changed files with 6 additions and 6 deletions

View file

@ -135,18 +135,16 @@ pub fn create_graphics_pipeline(
.layout(layout)
.depth_stencil_state(depth_stencil_state);
let pipeline = unsafe {
device
.create_graphics_pipelines(vk::PipelineCache::null(), &[pipeline_info], None)
.map_err(|(_, e)| e)?
}[0];
let result = unsafe {
device.create_graphics_pipelines(vk::PipelineCache::null(), &[pipeline_info], None)
};
// Cleanup temporary shader modules (they are baked into the pipeline now)
unsafe {
device.destroy_shader_module(vert_module, None);
device.destroy_shader_module(frag_module, None);
}
let pipeline = result.map_err(|(_, e)| e)?[0];
Ok(pipeline)
}

View file

@ -369,11 +369,13 @@ impl Renderer {
let _ = allocator.free(alloc);
}
self.device.destroy_buffer(self.vertex_buffer, None);
self.vertex_buffer = vk::Buffer::null();
if let Some(alloc) = self.index_allocation.take() {
let _ = allocator.free(alloc);
}
self.device.destroy_buffer(self.index_buffer, None);
self.index_buffer = vk::Buffer::null();
}
let allocator = self