vulkan 构建错误:“createResultValue”不是“vk”的成员

vulkan 构建错误:“createResultValue”不是“vk”的成员

我正在尝试编译一个使用 vulkan hpp 的程序,它使用名为 vulkan_driver.h 的文件中的方法,如下所示:

// Evaluate f and if result is not a success throw proper vk exception.
#define CHECK_VK_RESULT(x) do { \
   vk::Result res = vk::Result(x); \
   int tmp = 0; \
   vk::createResultValue(res, tmp, __FILE__ ":" TOSTRING(__LINE__)); \
} while (0)

当我编译时出现以下错误:

[  199s] In file included from /home/abuild/rpmbuild/BUILD/decaf-emu-20220508T212126/src/libgpu/src/vulkan/vulkan_driver.cpp:2:
[  199s] /home/abuild/rpmbuild/BUILD/decaf-emu-20220508T212126/src/libgpu/src/vulkan/vulkan_driver.cpp: In member function 'void vulkan::Driver::initialise(vk::Instance, vk::PhysicalDevice, vk::Device, vk::Queue, uint32_t)':
[  199s] /home/abuild/rpmbuild/BUILD/decaf-emu-20220508T212126/src/libgpu/src/vulkan/vulkan_driver.h:36:8: error: 'createResultValue' is not a member of 'vk'; did you mean 'createResultValueType'?
[  199s]    36 |    vk::createResultValue(res, tmp, __FILE__ ":" TOSTRING(__LINE__)); \
[  199s]       |        ^~~~~~~~~~~~~~~~~
[  199s] /home/abuild/rpmbuild/BUILD/decaf-emu-20220508T212126/src/libgpu/src/vulkan/vulkan_driver.cpp:89:4: note: in expansion of macro 'CHECK_VK_RESULT'
[  199s]    89 |    CHECK_VK_RESULT(vmaCreateAllocator(&allocatorCreateInfo, &mAllocator));
[  199s]       |    ^~~~~~~~~~~~~~~
[  199s] make[2]: *** [src/libgpu/CMakeFiles/libgpu.dir/build.make:647: src/libgpu/CMakeFiles/libgpu.dir/src/vulkan/vulkan_driver.cpp.o] Error 1

我该如何修复这个错误?

答案1

我在尝试构建时遇到了同样的错误https://github.com/jherico/Vulkan(在 Ubuntu 22.04 和 Windows 10 上)
例如glfw.cpp 中的这一行导致与 Ahmed Moselhi 发布的相同编译错误。

我发现该函数的名称和签名已在 vulkan.hpp 中更改
(请参阅此提交位于 Github Vulkan-Headers 存储库中

为了让编译再次工作,我需要更改函数的用法:

vk::createResultValue(result, rawSurface, "vk::CommandBuffer::begin");

到:

vk::createResultValueType(result, rawSurface);

对于您的情况@Ahmed Moselhi,您应该将代码更改为以下内容:

vk::createResultValueType(res, tmp);

相关内容