vk: fix double free of image views in intermediates
This commit is contained in:
parent
e9a1518c5d
commit
f85e44a3b9
|
@ -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<vk::ImageView>,
|
||||
owned: Vec<OwnedImage>,
|
||||
|
@ -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<FrameOptions>,
|
||||
) -> 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.
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue