我试图弄清楚如何使用 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)"
我还应该做什么?什么
必须满足其中一项要求
意思是?有什么我想念的吗?
编辑:
正如 Karl Schultz 所建议的,有必要添加VK_KHR_shader_non_semantic_info
到info.ppEnabledExtensionNames
.
此外,请确保使用VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
in将日志级别设置为 INFO VkDebugUtilsMessengerCreateInfoEXT::messageSeverity
。默认情况下,由 产生的所有输出debugPrintfEXT
都具有 INFO 级别。
你可能还会看到
Printf message was truncated, likely due to a buffer size that was too small for the message
如果您产生太多线程,每个线程都会打印自己的长日志。