Hi!
I followed the new tutorial that uses RAII Vulkan headers. Everything works fine, but there is one problem: before the program terminates, when the HelloTriangleApplication instance is destroyed, all the vk::raii objects are destroyed after the glfwDestroyWindow and glfwTerminate calls, which creates a segmentation fault. To avoid this, I added this code to the cleanup function:
void cleanup() {
inFlightFences.clear();
renderSemaphores.clear();
presentSemaphores.clear();
commandBuffers.clear();
commandPool = nullptr;
pipeline = nullptr;
pipelineLayout = nullptr;
imageViews.clear();
images.clear();
swapChain = nullptr;
surface = nullptr;
queue = nullptr;
device = nullptr;
physicalDevice = nullptr;
debugMessenger = nullptr;
instance = nullptr;
glfwDestroyWindow(window);
window = nullptr;
glfwTerminate();
}
This allows all destructors of Vulkan objects to be called before the GLFW window is destroyed.
I find this solution inconvenient because it completely kills the benefits of RAII.
Am I missing something in the tutorial?
Hi!
I followed the new tutorial that uses RAII Vulkan headers. Everything works fine, but there is one problem: before the program terminates, when the HelloTriangleApplication instance is destroyed, all the vk::raii objects are destroyed after the
glfwDestroyWindowandglfwTerminatecalls, which creates a segmentation fault. To avoid this, I added this code to thecleanupfunction:This allows all destructors of Vulkan objects to be called before the GLFW window is destroyed.
I find this solution inconvenient because it completely kills the benefits of RAII.
Am I missing something in the tutorial?