【问题标题】:Vulkan hpp wrappers, signature conflictVulkan hpp 包装器,签名冲突
【发布时间】:2019-03-16 03:03:13
【问题描述】:

我正在尝试将我现有的代码库转换为使用 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);

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

d 是函数的第二个参数。

dispatch 需要什么才能成功编译这段代码?

【问题讨论】:

    标签: c++ header wrapper vulkan


    【解决方案1】:

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

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

    这也使您不必调用函数两次,就像使用 C 标头一样,您首先需要获取计数并分配您的向量。这一切都在这里隐式完成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多