glslvulkanvalidation-layers

Using debugPrintfEXT in Vulkan


I'm trying to figure out how to use debugPrintfEXT but with no luck. First I've enabled the extension in my vertex shader

#version 450
#extension GL_EXT_debug_printf : enable


void main()
{
    debugPrintfEXT("Test");
    // ... some more stuff here ...
}

Then I specify the necessary extensions for the Vulkan instance

VkValidationFeatureEnableEXT enables[] = {VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT};
VkValidationFeaturesEXT features = {};
features.sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT;
features.enabledValidationFeatureCount = 1;
features.pEnabledValidationFeatures = enables;

VkInstanceCreateInfo info = {};
info.pNext = &features;

In the info.ppEnabledExtensionNames field I specified VK_EXT_validation_features and VK_EXT_debug_utils among other things.

When I run my app, I get the following logs

VUID_Undefined(ERROR / SPEC): msgNum: 2044605652 - Validation Error: [ VUID_Undefined ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x79de34d4 | vkCreateDebugUtilsMessengerEXT: value of pCreateInfo->pNext must be NULL. This error is based on the Valid Usage documentation for version 182 of the Vulkan header.  It is possible that you are using a struct from a private extension or an extension that was added to a later version of the Vulkan header, in which case the use of pCreateInfo->pNext is undefined and may not work correctly with validation enabled
    Objects: 1
        [0] 0, type: 3, name: NULL

[Debug][Error][Validation]"Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-04147 ] Object 0: handle = 0x5651b647e828, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x3d492883 | vkCreateShaderModule(): The SPIR-V Extension (SPV_KHR_non_semantic_info) was declared, but none of the requirements were met to use it. The Vulkan spec states: If pCode declares any of the SPIR-V extensions listed in the SPIR-V Environment appendix, one of the corresponding requirements must be satisfied (https://vulkan.lunarg.com/doc/view/1.2.182.0/linux/1.2-extensions/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-04147)"

What more should I do? And what does

one of the corresponding requirements must be satisfied

mean? Is there something that I'm missing?

Edit:

As suggested by Karl Schultz, it's necessary to add VK_KHR_shader_non_semantic_info to info.ppEnabledExtensionNames.

Also, make sure to set log level to INFO with VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT in VkDebugUtilsMessengerCreateInfoEXT::messageSeverity. By default all the output produced by debugPrintfEXT has INFO level.

You may also see

Printf message was truncated, likely due to a buffer size that was too small for the message

if you spawn too many threads, each printing its own long logs.


Solution

  • You also need to enable the VK_KHR_shader_non_semantic_info device extension in your application code when you create the device.

    LunarG has also recently published a white paper about debugPrintfEXT.