From 0ac953c991f4839f9f75a93bd232f59707ba1602 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Sun, 15 Jan 2023 15:19:58 +0100 Subject: [PATCH] Fix #2130 --- vulkano/src/image/sys.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/vulkano/src/image/sys.rs b/vulkano/src/image/sys.rs index 757d229740..f95ed5c789 100644 --- a/vulkano/src/image/sys.rs +++ b/vulkano/src/image/sys.rs @@ -1024,12 +1024,16 @@ impl RawImage { } }; - let memory_requirements = if flags.intersects(ImageCreateFlags::DISJOINT) { - (0..format.unwrap().planes().len()) - .map(|plane| Self::get_memory_requirements(&device, handle, Some(plane))) - .collect() + let memory_requirements = if needs_destruction { + if flags.intersects(ImageCreateFlags::DISJOINT) { + (0..format.unwrap().planes().len()) + .map(|plane| Self::get_memory_requirements(&device, handle, Some(plane))) + .collect() + } else { + smallvec![Self::get_memory_requirements(&device, handle, None)] + } } else { - smallvec![Self::get_memory_requirements(&device, handle, None)] + smallvec![] }; RawImage { @@ -1605,6 +1609,7 @@ impl RawImage { /// Returns the memory requirements for this image. /// + /// - If the image is a swapchain image, this returns a slice with a length of 0. /// - If `self.flags().disjoint` is not set, this returns a slice with a length of 1. /// - If `self.flags().disjoint` is set, this returns a slice with a length equal to /// `self.format().unwrap().planes().len()`. @@ -2086,6 +2091,7 @@ impl Image { /// Returns the memory requirements for this image. /// + /// - If the image is a swapchain image, this returns a slice with a length of 0. /// - If `self.flags().disjoint` is not set, this returns a slice with a length of 1. /// - If `self.flags().disjoint` is set, this returns a slice with a length equal to /// `self.format().unwrap().planes().len()`.