I was following along the 'new' guide for Vulkan 1.3 with dynamic rendering, and got a runtime error when exiting application, during cleanup() function ( _mainDeletionQueue.flush(); ).
The lambda expression is capturing by reference, but in its body, the variables sky and gradient reference garbage data, as they are not fields of the VulkanEngine class.
I got it working by replacing the lines responsible for pipeline destruction that were using sky and gradient by reference with a for loop, and also destroying _gradientPipelineLayout last, like this:
_mainDeletionQueue.push_function([&]() {
for (auto it = backgroundEffects.rbegin(); it != backgroundEffects.rend(); it++){
vkDestroyPipeline(_device, it->pipeline, nullptr);
}
vkDestroyPipelineLayout(_device, _gradientPipelineLayout, nullptr);
});
I was following along the 'new' guide for Vulkan 1.3 with dynamic rendering, and got a runtime error when exiting application, during
cleanup()
function (_mainDeletionQueue.flush();
).The lambda expression is capturing by reference, but in its body, the variables
sky
andgradient
reference garbage data, as they are not fields of the VulkanEngine class.https://github.com/vblanco20-1/vulkan-guide/blame/4fafdfee151fea55d036c727b3b0b372d1c9239e/docs/new_chapter_2/vulkan_pushconstants.md#L215C2-L215C2
I got it working by replacing the lines responsible for pipeline destruction that were using
sky
andgradient
by reference with a for loop, and also destroying _gradientPipelineLayout last, like this: