在 Vulkan 中使用 debugPrintfEXT
Using debugPrintfEXT in Vulkan
我正在尝试弄清楚如何使用 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_features
和 VK_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)"
我还应该做什么?什么是
one of the corresponding requirements must be satisfied
是什么意思?有什么我想念的吗?
编辑:
根据 Karl Schultz 的建议,有必要将 VK_KHR_shader_non_semantic_info
添加到 info.ppEnabledExtensionNames
。
此外,确保在 VkDebugUtilsMessengerCreateInfoEXT::messageSeverity
中使用 VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
将日志级别设置为 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 has also recently published a white paper 关于 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_features
和 VK_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)"
我还应该做什么?什么是
one of the corresponding requirements must be satisfied
是什么意思?有什么我想念的吗?
编辑:
根据 Karl Schultz 的建议,有必要将 VK_KHR_shader_non_semantic_info
添加到 info.ppEnabledExtensionNames
。
此外,确保在 VkDebugUtilsMessengerCreateInfoEXT::messageSeverity
中使用 VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
将日志级别设置为 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 has also recently published a white paper 关于 debugPrintfEXT
。