Dess
Dess

Reputation: 2649

Vulkan: debugPrintfEXT doesn't print anything

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

Steps I've takens:

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:

Upvotes: 2

Views: 1817

Answers (1)

Karl Schultz
Karl Schultz

Reputation: 1556

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.

Upvotes: 2

Related Questions