summary refs log tree commit diff
path: root/src/graphics/render.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-08-14 18:54:33 -0700
committerIrene Knapp <ireneista@irenes.space>2026-08-14 18:54:33 -0700
commit2fae64a18c3253a892c9b3e529fb7b09e0bac753 (patch)
treebe124cb085372a1ba6257f9f6e2c7cb4133bf24d /src/graphics/render.rs
parent5a4fad7b67a6ab477b230f4d8a70efed0e9100cb (diff)
move the Frame destruction code to where it goes
this is, however, the first time one of these render state objects has been managed by another one rather than by main() directly, so there's a little weirdness around the lifetime logic that might need reconsidering. seems okay for now though.

Force-Push: yes
Change-Id: Ide3b9f0a7163f78a51ceed4dfb506232475354dd
Diffstat (limited to 'src/graphics/render.rs')
-rw-r--r--src/graphics/render.rs22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/graphics/render.rs b/src/graphics/render.rs
index 00e55ee..30f4b62 100644
--- a/src/graphics/render.rs
+++ b/src/graphics/render.rs
@@ -98,6 +98,8 @@ impl Render {
   pub fn destroy(mut self, permanent: &Permanent) {
     self.destroy_replaceable(permanent);
 
+    Frame::destroy(&mut self.per_frame, permanent);
+
     if let Some(model) = self.model {
       model.destroy(&permanent.device);
     }
@@ -105,24 +107,10 @@ impl Render {
 
   #[allow(unsafe_code)]
   fn destroy_replaceable(&mut self, permanent: &Permanent) {
-    let device = &permanent.device;
-
-    let mut command_buffers = Vec::new();
-    for frame in &self.per_frame {
-      unsafe { device.destroy_framebuffer(frame.framebuffer, None) };
+    // We skip calling Frame::destroy_replaceable() here because then it would
+    // be called twice during Render::reinit(), and that seems excessive.
 
-      command_buffers.push(frame.command_buffer);
-    }
-
-    //   Notice that we free the buffers in the pool, but do not destroy the
-    // pool itself. Notice also that we only do this for the primary command
-    // pool, because that's the only one where we've kept track of the
-    // buffers. We promise ourselves to free buffers in the transient pool
-    // immediately after using them.
-    unsafe {
-      device.free_command_buffers(permanent.primary_command_pool,
-                                  &command_buffers)
-    };
+    let device = &permanent.device;
 
     unsafe { device.destroy_pipeline(self.pipeline, None) };
     unsafe { device.destroy_pipeline_layout(self.pipeline_layout, None) };