DebugReportCallbackEXT cannot be destroyed

VulkanSDK 1.2.182.0 (It’s not the latest)

Hi, as the title says, DebugReportCallbackEXT cannot be destroyed but I could destroy it in the past, but due to the latest (Driver) after Windows reinstallation and online Driver Pack installation, then I can no longer destroy it, so how to destroy it? There are more explanation at the bottom of this post.

Referenced from:

#ifdef IMGUI_VULKAN_DEBUG_REPORT
    // Enabling validation layers
    const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
    create_info.enabledLayerCount = 1;
    create_info.ppEnabledLayerNames = layers;

    // Enable debug report extension (we need additional storage, so we duplicate the user array to add our new extension to it)
    const char** extensions_ext = (const char**)malloc(sizeof(const char*) * (extensions_count + 1));
    memcpy(extensions_ext, extensions, extensions_count * sizeof(const char*));
    extensions_ext[extensions_count] = "VK_EXT_debug_report";
    create_info.enabledExtensionCount = extensions_count + 1;
    create_info.ppEnabledExtensionNames = extensions_ext;

    // Create Vulkan Instance
    err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
    check_vk_result(err);
    free(extensions_ext);

    // Get the function pointer (required for any extensions)
    auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
    IM_ASSERT(vkCreateDebugReportCallbackEXT != NULL);

    // Setup the debug report callback
    VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
    debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
    debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
    debug_report_ci.pfnCallback = vk_debug_report;
    debug_report_ci.pUserData = NULL;
    pushMemoryHint("vkCreateDebugReportCallbackEXT"); // <-- This is my own function for debugging purpose.
    err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
    popMemoryHint(); // <-- My own function.
    check_vk_result(err);

    g_vk_debugReport.setup(binPath(projectName) + "_vk_debug_report.txt");
#else
    ...
#endif

The cleanup function:

static void CleanupVulkan()
{
    vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);

#ifdef IMGUI_VULKAN_DEBUG_REPORT
    // Remove the debug report callback
    auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
    vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
#endif // IMGUI_VULKAN_DEBUG_REPORT

    vkDestroyDevice(g_Device, g_Allocator);
    vkDestroyInstance(g_Instance, g_Allocator);
}

unfreed memory block

The text file “_not_freed_memory_blocks.txt” generated by the app:

----------------------------------------------------------------------------------------------------
Known sources: List of not freed memory blocks with total size 0.000 MB
----------------------------------------------------------------------------------------------------
file: "...\engine.cpp", line: 32, scope: VK_SYSTEM_ALLOCATION_SCOPE_OBJECT, hint: vkCreateDebugReportCallbackEXT, size in bytes: 48

That debug text file above tells that the “DebugReportCallbackEXT” cannot be destroyed. But in the past, it could be destroyed without any memory leak. The reason it cannot be destroyed is I completely reinstalled Windows with the latest drivers using “Online Driver Pack”, so I realize that the latest Driver for Vulkan in Windows doesn’t properly destroy.

My own temporary solution to avoid the Memory Leak Warning: “Skip the hint vkCreateDebugReportCallbackEXT” so that warning window will no longer pop up.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.