0
votes

Recently I've updated my system and tried to recompile my Vulkan app (which uses Vulkan cpp binding) and got almost no output from vk::DebugUtilsMessengerEXT (except the string "Added messenger"). I set it up to std::cout every kind of callback, and it printed lots of information strings (before update). Does anyone know, what to do to bring back debug output?

Here is my debug messenger code:

    // ...
    vk::DebugUtilsMessengerCreateInfoEXT messengerInfo;
    messengerInfo.setMessageSeverity(
        vk::DebugUtilsMessageSeverityFlagBitsEXT::eError | 
        vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning |
        vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo | 
        vk::DebugUtilsMessageSeverityFlagBitsEXT::eVerbose);
    messengerInfo.setMessageType(
        vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral |
        vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation |
        vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance);
    messengerInfo.setPfnUserCallback(callback);
    messengerInfo.setPUserData(nullptr);
    if(instance.createDebugUtilsMessengerEXT(&messengerInfo, nullptr, &debugMessenger, loader) != vk::Result::eSuccess) throw std::runtime_error("Failed to create debug messenger!\n");
}

VKAPI_ATTR VkBool32 VKAPI_CALL System::callback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData)
{
    std::cout << pCallbackData->pMessage << '\n';
    return false;
}

"loader" is vk::DispatchLoaderDynamic

Seems like the trouble is not only with Vulkan-Hpp, but also with C Vulkan.

2
What makes you think the problem also exists with the C interface? Also, have you checked that the VK_EXT_debug_utils extension is listed by vkEnumerateInstanceExtensions? Did you enable that extension when creating the instance? - Jesse Hall

2 Answers

2
votes

Did some testing and the callbacks seem to be working correctly. I'm thinking the issue here might be the removal of some old INFO messages for performance reasons -- see Vulkan-ValidationLayers commits 18BF5C637 and 523D9C775. If INFORMATION_BIT messages were enabled in SDK releases previous to 1.1.108, you'd have seen a ton of spew. If expected validation errors are not making it to your callback, please create a github issue in the VVL repo and we'll address it immediately.

0
votes

How I'm doing it and it works, albeit not the latest SDK:

void VulkanContext::createInstance()
{
    // create the list of required extensions
    uint32_t glfwExtensionCount = 0;
    const char **glfwExtensions;
    glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);

    std::vector<const char *> extensions(glfwExtensions, glfwExtensions + glfwExtensionCount);
    extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);

    auto layers = std::vector<const char *>();
    if ( enableValidationLayers )
    {
        extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
        extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
        layers.push_back("VK_LAYER_LUNARG_standard_validation");
    }

    vk::ApplicationInfo appInfo("Vulkan test", 1, "test", 1, VK_API_VERSION_1_1);

    auto createInfo = vk::InstanceCreateInfo(
            vk::InstanceCreateFlags(),
            &appInfo,
            static_cast<uint32_t>(layers.size()),
            layers.empty() ? nullptr : layers.data(),
            static_cast<uint32_t>(extensions.size()),
            extensions.empty() ? nullptr : extensions.data()
    );

    instance = vk::createInstanceUnique(createInfo);

    dispatcher = vk::DispatchLoaderDynamic(instance.get(), vkGetInstanceProcAddr);

    if ( enableValidationLayers )
    {
        auto severityFlags = vk::DebugUtilsMessageSeverityFlagBitsEXT::eError
                            | vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning
                            | vk::DebugUtilsMessageSeverityFlagBitsEXT::eVerbose
                            | vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo;

        auto typeFlags = vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral
                         | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation
                         | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance;

        messenger = instance->createDebugUtilsMessengerEXTUnique(
                {{}, severityFlags, typeFlags, debugCallback},
                nullptr,
                dispatcher
        );
    }
}

Make sure you're enabling the debug extensions and validation layers.

Check that your loader/dispatcher is initialized correctly.

Try some of the other commands for creating the messenger, not sure but maybe the API changed and the severity flags are passed in the wrong place.

Make sure the validation layers are installed correctly, don't recall dealing with that myself but saw mentions that it can be an issue.