diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index 8ab7521..89b0aa2 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -145,7 +145,7 @@ pub(crate) struct FilterCommon { /// These Vulkan objects must stay alive until the command buffer is submitted /// to the rendering queue, and the GPU is done with the objects. #[must_use] -pub struct FrameIntermediates { +struct FrameIntermediates { device: ash::Device, image_views: Vec, owned: Vec, @@ -170,10 +170,10 @@ impl FrameIntermediates { /// Dispose of the intermediate objects created during a frame. pub fn dispose(&mut self) { - for image_view in &self.image_views { - if *image_view != vk::ImageView::null() { + for image_view in self.image_views.drain(0..) { + if image_view != vk::ImageView::null() { unsafe { - self.device.destroy_image_view(*image_view, None); + self.device.destroy_image_view(image_view, None); } } } @@ -181,6 +181,12 @@ impl FrameIntermediates { } } +impl Drop for FrameIntermediates { + fn drop(&mut self) { + self.dispose() + } +} + impl FilterChain { /// Load the shader preset at the given path into a filter chain. pub fn load_from_path( @@ -579,7 +585,7 @@ impl FilterChain { cmd: vk::CommandBuffer, options: Option, ) -> error::Result<()> { - let mut intermediates = &mut self.intermediates[count % self.intermediates.len()]; + let intermediates = &mut self.intermediates[count % self.intermediates.len()]; intermediates.dispose(); // limit number of passes to those enabled. diff --git a/librashader-runtime-vk/src/hello_triangle/mod.rs b/librashader-runtime-vk/src/hello_triangle/mod.rs index abd73c2..7f81901 100644 --- a/librashader-runtime-vk/src/hello_triangle/mod.rs +++ b/librashader-runtime-vk/src/hello_triangle/mod.rs @@ -338,7 +338,7 @@ impl VulkanWindow { .queue_present(vulkan.base.graphics_queue, &present_info) .unwrap(); - vulkan.base.device.device_wait_idle().unwrap(); + // vulkan.base.device.device_wait_idle().unwrap(); // intermediates.dispose(); } } diff --git a/librashader-runtime-vk/src/lib.rs b/librashader-runtime-vk/src/lib.rs index 2d1e484..3a57aca 100644 --- a/librashader-runtime-vk/src/lib.rs +++ b/librashader-runtime-vk/src/lib.rs @@ -19,7 +19,6 @@ mod util; mod vulkan_primitives; mod vulkan_state; -pub use filter_chain::FrameIntermediates; pub use filter_chain::FilterChain; pub use filter_chain::VulkanDevice; pub use filter_chain::VulkanInstance;