繁体   English   中英

Vulkan HPP包装器,签名冲突

[英]Vulkan hpp wrappers, signature conflict

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

特别是,我有以下代码行:

vkEnumerateInstanceLayerProperties(&layerCount, nullptr);

使用vulkan做事的本机C类方式。

我尝试将其更改为:

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); 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 ++头文件,该函数根本不接受任何参数,而是直接返回vk::LayerProperties的向量,因此您只需分配结果即可:

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

这也省去了两次调用函数的麻烦,就像C头一样,您首先需要获取计数来分配向量。 这一切都在这里隐式完成。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM