Validation errors never happen because Drop impl never gets called after upgrading to winit 0.20
valignatev opened this issue · 4 comments
Hi! Thanks for a great port of a vulkan-tutorial, it really helps!
I completed the fourth part of the tutorial (Logical Device) and forgot to call self.device.destroy_device(None)
. It didn't break anything, but now I wonder if validation layers should've complained about it?
They certainly do apply to the device creation process, because if I try to pass something silly to p_next
field of the vk::DeviceCreateInfo
, I get expected "unknown struct type" errors in the console.
UPD: Maybe this question is better be asked in the ash issue tracker 🤔
Did you destroy the Vulkan instance? The call to destroy_instance
would trigger the validation message. If you don't call that, the validation layers have no chance to check if the device was properly destroyed or not.
I did. My Drop impl looked exactly like this:
https://github.com/unknownue/vulkan-tutorial-rust/blob/master/src/tutorials/04_logical_device.rs#L192-L204
But without destroy_device
part
I can't seem to reproduce this. My second thought was it might be because of not passing debug messenger info in vk::InstanceCreateInfo::p_next
but even then the debug layers correctly print out a warning for me:
UNASSIGNED-ObjectTracker-ObjectLeak(ERROR / SPEC): msgNum: 0 - OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT object VkDevice 0x2837e5138d0[] has not been destroyed.
(SDK 1.1.114)
What SDK version are you using? And what validation layers did you enable?
Ok, after you've clarified that validation errors indeed must appear, I started to look into how my application finishes more closely and I get now why there's no validation errors:
in winit 0.20 event_loop.run
hijacks the thread and calls std::process.exit(0) internally when the loop ends, so Drop impl for VulkanApp never gets called. It even explicitly said in the winit docs:
Any values not passed to this function will *not* be dropped.
So unless self
in the main_loop
is used in the event loop callback, or run_return
is used, VulkanApp's drop
won't be called. The first tutorial chapter when it happens is 15_hello_triangle.rs, and all chapters before that don't execute the destructor, I checked that by running examples from the repo.
I think that I can fix that and submit a PR
Also, winit 0.20 reorganized platform modules so the examples do not compile on Linux because winit::os::unix::WindowExt
became winit::platform::unix::WindowExtUnix
although it is a separate issue, I think, and should be reported separately (I'll do that).
@pezcode Thanks a lot for you help with finding this ❤️