#vkDestroySurfaceKHR not destroyng the surface

15 messages · Page 1 of 1 (latest)

haughty ember
#
if (out != VK_SUCCESS) {
        fprintf(stderr, "Failed to create swapchain!\n");
        printf("%d\n", out);
        vkDestroySwapchainKHR(vulkanStruct->device, vulkanStruct->swapchain, NULL);
        vkDestroySurfaceKHR(vulkanStruct->instance, vulkanStruct->surface, NULL); //why isn't this working
        vkDestroyDevice(vulkanStruct->device, NULL);
        vkDestroyInstance(vulkanStruct->instance, NULL);
        glfwTerminate();
        exit(EXIT_FAILURE);
}```
```json
VUID-vkDestroyInstance-instance-00629(ERROR / SPEC): msgNum: -1958900200 - Validation Error: [ VUID-vkDestroyInstance-instance-00629 ] Object 0: handle = 0x17e04211b50, type = VK_OBJECT_TYPE_INSTANCE; Object 1: handle = 0xfd5b260000000001, type = VK_OBJECT_TYPE_SURFACE_KHR; | MessageID = 0x8b3d8e18 | OBJ ERROR : For VkInstance 0x17e04211b50[], VkSurfaceKHR 0xfd5b260000000001[] has not been destroyed. The Vulkan spec states: All child objects created using instance must have been destroyed prior to destroying instance (https://vulkan.lunarg.com/doc/view/1.3.246.1/windows/1.3-extensions/vkspec.html#VUID-vkDestroyInstance-instance-00629)
    Objects: 2
        [0] 0x17e04211b50, type: 1, name: NULL
        [1] 0xfd5b260000000001, type: 1000000000, name: NULL

I don't understand what could be the issue

patent robin
#

or that you're passing a null handle

hazy bronze
#

@haughty ember your code only shows you destroying when you failed to create a swaphain, you did not show any code showing you destroyed on program shutdown

haughty ember
patent robin
#

this kind of error handling is going to become untenable very quickly

haughty ember
#

its verry strange

patent robin
#

well, that would explain it. And possibly why your swapchain creation is failing too 🙂

#

should have had a validation error for that already

haughty ember
#

forgotted vulkanStruct->surface = surface; I am an idiot X)

#

Thanks anyway

haughty ember
patent robin
#

Have destruction of handles managed in only one place (for any given object), and simply defer to that on shutdown

haughty ember
#

Yes good idea