1
votes

I can't get debugPrintfEXT to work. I don't see what I'm missing.

Steps I've takens:

  • Enabled instance extension VK_EXT_debug_utils; Verified using Nvidia Nsight.
  • Use DebugUtils print to output messages. Printing all messages, including DEBUG and INFO.
  • Added #extension GL_EXT_debug_printf : enable to vertex shader.
  • Used debugPrintfEXT("Foo") in vertex shader.
  • Run code from Vulkan Configurator, with Print layer enabled.
  • Enabled validation feature in Instance.

Code:

vk::InstanceCreateInfo createInfo;
std::vector valFeaturesEnabled = {vk::ValidationFeatureEnableEXT::eDebugPrintf};
vk::ValidationFeaturesEXT valFeatures;
valFeatures.enabledValidationFeatureCount = (uint32_t) valFeaturesEnabled.size();
valFeatures.pEnabledValidationFeatures = valFeaturesEnabled.data();
createInfo.setPNext(&valFeatures);

Details:

  • Windows 10
  • GTX 1080Ti
  • Visual Studio 2019
  • Vulkan 1.2
1

1 Answers

1
votes

What you're doing should work.

I've gotten it to work by making some small changes to the "hello triangle" sample in Khronos Vulkan-Samples.

Force usage of the validation layer for both Debug and Release builds by building with the CMake option -DVKB_VALIDATION_LAYERS=ON or by adding a define at the top of hello_triangle.cpp. Since the project activates the validation layer in a Debug build, you can skip this step if you stick with a Debug build.

#define VKB_VALIDATION_LAYERS

Add the VK_DEBUG_REPORT_INFORMATION_BIT_EXT flag to debug_report_create_info.flags. The documentation for this requirement isn't clear but is going to be fixed shortly. You were already doing this.

Add the following code just before the call to vkCreateInstance. It is essentially the same as the code you pasted.

VkValidationFeatureEnableEXT enabled[] = {VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT};
VkValidationFeaturesEXT      features{VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT};
features.disabledValidationFeatureCount = 0;
features.enabledValidationFeatureCount  = 1;
features.pDisabledValidationFeatures    = nullptr;
features.pEnabledValidationFeatures     = enabled;

features.pNext                          = instance_info.pNext;
instance_info.pNext                     = &features;

And make the same changes to the vertex shader that you did.

If you can get it working with this sample, perhaps you will see what you're doing differently in your application.