微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 Vulkan 中使用 debugPrintfEXT

如何解决在 Vulkan 中使用 debugPrintfEXT

我想弄清楚如何使用 debugPrintfEXT 但没有成功。 首先,我在顶点着色器中启用了扩展

#version 450
#extension GL_EXT_debug_printf : enable


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

然后我为 Vulkan 实例指定必要的扩展

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;

info.ppEnabledExtensionNames 字段中,我指定了 VK_EXT_validation_featuresVK_EXT_debug_utils 等。

当我运行我的应用程序时,我得到以下日志

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)"

我还应该做什么?还有什么

必须满足相应要求之一

是什么意思?有什么我遗漏的吗?

编辑:

根据 Karl Schultz 的建议,有必要将 VK_KHR_shader_non_semantic_info 添加info.ppEnabledExtensionNames

另外,请确保在 VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT 中使用 VkDebugUtilsMessengerCreateInfoEXT::messageSeverity 将日志级别设置为 INFO。认情况下,debugPrintfEXT 产生的所有输出都具有 INFO 级别。

你也可以看到

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

如果你产生太多线程,每个线程都会打印自己的长日志。

解决方法

您还需要在创建设备时在应用程序代码中启用 VK_KHR_shader_non_semantic_info 设备扩展。

LunarG 最近还发布了关于 debugPrintfEXTwhite paper

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。