gpt4 book ai didi

vulkan - 如何在 Vulkan 中获得支持的扩展

转载 作者:行者123 更新时间:2023-12-02 15:13:15 28 4
gpt4 key购买 nike

我正在开发一个使用 Vulkan 的 C++ 应用程序。我如何获得支持的扩展集?

std::set<std::string> get_supported_extensions()这样的签名会很理想。

最佳答案

vkEnumerateInstanceExtensionProperties API 执行此操作。

std::set<std::string> get_supported_extensions() {
VkResult result = 0;

/*
* From the link above:
* If `pProperties` is NULL, then the number of extensions properties
* available is returned in `pPropertyCount`.
*
* Basically, gets the number of extensions.
*/
uint32_t count = 0;
result = vkEnumerateInstanceExtensionProperties(nullptr, &count, nullptr);
if (result != VK_SUCCESS) {
// Throw an exception or log the error
}

std::vector<VkExtensionProperties> extensionProperties(count);

// Get the extensions
result = vkEnumerateInstanceExtensionProperties(nullptr, &count, extensionProperties.data());
if (result != VK_SUCCESS) {
// Throw an exception or log the error
}

std::set<std::string> extensions;
for (auto & extension : extensionProperties) {
extensions.insert(extension.extensionName);
}

return extensions;
}

关于vulkan - 如何在 Vulkan 中获得支持的扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42057041/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com