Vulkan hpp包装,签名冲突

问题描述 投票:1回答:1

我试图将我现有的代码库转换为使用lunar SDK中vulkan.hpp中的包装器定义。

特别是,我有一行代码:

vkEnumerateInstanceLayerProperties(&layerCount, nullptr);

哪个是本地C喜欢用vulkan做东西的方法。

我尝试将其更改为:

vk::enumerateInstanceLayerProperties(&layerCount, nullptr);这是vulkan.hpp的命名约定。然而,这无法编译,有多个错误,第一个是error: ‘unsigned int*’ is not a class, struct, or union type

vulkan.hpp中定义的签名是:

template <typename Allocator, typename Dispatch>
  VULKAN_HPP_INLINE typename ResultValueType<std::vector<LayerProperties,Allocator>>::type enumerateInstanceLayerProperties(Allocator const& vectorAllocator, Dispatch const &d )

我的假设是,第一个参数需要是一个向量:std::vector<vk::LayerProperties> availableLayers; vk::enumerateInstanceLayerProperties(availableLayers, nullptr);

然而,这也无法编译,警告我:error: request for member ‘vkEnumerateInstanceLayerProperties’ in ‘d’, whichis of non-class type ‘std::nullptr_t’

d是该函数的第二个参数。

成功编译这段代码需要什么样的调度?

c++ header wrapper vulkan
1个回答
4
投票

使用C ++标头,该函数根本不接受任何参数,而只是直接返回vk::LayerProperties的向量,因此您只需分配结果:

std::vector<vk::LayerProperties> instanceLayerProps = vk::enumerateInstanceLayerProperties();

这也节省了你必须两次调用该函数,比如使用C头,你首先需要获取计数分配你的向量。这一切都隐含在这里完成。

© www.soinside.com 2019 - 2024. All rights reserved.