summary refs log tree commit diff
path: root/src/graphics/window_dressing.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-08-15 20:26:28 -0700
committerIrene Knapp <ireneista@irenes.space>2026-08-16 02:08:18 -0700
commitdb64249ce8108439ada78a2d23d67d2c573a1688 (patch)
tree3029aeaab6f3e30ff199ae367f75a5851e8f0222 /src/graphics/window_dressing.rs
parent2fae64a18c3253a892c9b3e529fb7b09e0bac753 (diff)
move uniform buffers into Frame
it's better this way. same lifetime.

Force-Push: yes
Change-Id: Ida309f05132838febcc9eb606f5915e7592ac398
Diffstat (limited to 'src/graphics/window_dressing.rs')
-rw-r--r--src/graphics/window_dressing.rs50
1 files changed, 1 insertions, 49 deletions
diff --git a/src/graphics/window_dressing.rs b/src/graphics/window_dressing.rs
index 07dfaf0..d6afa20 100644
--- a/src/graphics/window_dressing.rs
+++ b/src/graphics/window_dressing.rs
@@ -2,13 +2,9 @@
 use crate::error::*;
 use crate::graphics::{ Permanent, ForReinit };
 use crate::graphics::permanent::{ QueueFamilyIndices, EnableAnisotropy };
-use crate::graphics::util::{
-  allocate_buffer, allocate_image, init_image_view
-};
-use crate::shader_data::UniformBlock;
+use crate::graphics::util::{ allocate_image, init_image_view };
 
 use std::collections::BTreeSet;
-use std::mem::size_of;
 
 use vulkanalia::{ Device, Instance };
 use vulkanalia::vk::{ self, Handle, HasBuilder, InstanceV1_0, DeviceV1_0,
@@ -42,9 +38,6 @@ pub struct WindowDressing {
 
   pub sampler: vk::Sampler,
 
-  pub uniform_buffers: Vec<vk::Buffer>,
-  pub uniform_buffer_memory: Vec<vk::DeviceMemory>,
-
   pub descriptor_pool: vk::DescriptorPool,
 
   pub concurrency: Concurrency,
@@ -110,9 +103,6 @@ impl WindowDressing {
 
     let sampler = init_sampler(&device, &enable_anisotropy, mip_count)?;
 
-    let (uniform_buffers, uniform_buffer_memory)
-            = init_uniform_buffers(instance, device, swapchain.images.len())?;
-
     let descriptor_pool
             = init_descriptor_pool(device, swapchain.images.len())?;
 
@@ -128,8 +118,6 @@ impl WindowDressing {
       depth_image_view,
       depth_format,
       sampler,
-      uniform_buffers,
-      uniform_buffer_memory,
       descriptor_pool,
       concurrency,
     })
@@ -161,9 +149,6 @@ impl WindowDressing {
     let (depth_image, depth_image_memory, depth_image_view, depth_format)
             = init_depth(instance, device, &swapchain.extent, sample_count)?;
 
-    let (uniform_buffers, uniform_buffer_memory)
-            = init_uniform_buffers(instance, device, swapchain.images.len())?;
-
     // Notice that we did NOT reuse the descriptor pool.
     let descriptor_pool
             = init_descriptor_pool(device, swapchain.images.len())?;
@@ -179,8 +164,6 @@ impl WindowDressing {
     self.depth_image_memory = depth_image_memory;
     self.depth_image_view = depth_image_view;
     self.depth_format = depth_format;
-    self.uniform_buffers = uniform_buffers;
-    self.uniform_buffer_memory = uniform_buffer_memory;
     self.descriptor_pool = descriptor_pool;
 
     Ok(())
@@ -215,16 +198,6 @@ impl WindowDressing {
     // which will be different next time. So, we destroy it all the way.
     unsafe { device.destroy_descriptor_pool(self.descriptor_pool, None) };
 
-    //   Notice that, unlike the vertex and index buffers, we destroy and
-    // re-create these on every reinitialization. That's because the number of
-    // them depends on how many images the swapchain has.
-    for buffer in &self.uniform_buffers {
-      unsafe { device.destroy_buffer(*buffer, None) };
-    }
-    for memory in &self.uniform_buffer_memory {
-      unsafe { device.free_memory(*memory, None) };
-    }
-
     unsafe { device.destroy_image(self.color_image, None) };
     unsafe { device.free_memory(self.color_image_memory, None) };
     unsafe { device.destroy_image_view(self.color_image_view, None) };
@@ -365,27 +338,6 @@ fn init_depth(instance: &Instance, device: &Device, extent: &vk::Extent2D,
 }
 
 
-fn init_uniform_buffers(instance: &Instance, device: &Device, count: usize)
-    -> Result<(Vec<vk::Buffer>, Vec<vk::DeviceMemory>)>
-{
-  let mut buffers = Vec::new();
-  let mut all_memory = Vec::new();
-
-  for _ in 0 .. count {
-    let (buffer, memory) = allocate_buffer(
-            instance, device,
-            size_of::<UniformBlock<f32>>() as vk::DeviceSize,
-            vk::BufferUsageFlags::UNIFORM_BUFFER,
-            vk::MemoryPropertyFlags::HOST_COHERENT
-            | vk::MemoryPropertyFlags::HOST_VISIBLE)?;
-    buffers.push(buffer);
-    all_memory.push(memory);
-  }
-
-  Ok((buffers, all_memory))
-}
-
-
 #[allow(unsafe_code)]
 fn init_sampler(device: &Device, enable_anisotropy: &EnableAnisotropy,
                 mip_count: u32)