当前位置:网站首页>Vulkan开启特征(feature)的正确姿势
Vulkan开启特征(feature)的正确姿势
2022-07-30 18:50:00 【zenny_chen】
当我们在用Vulkan写一些应用时,无论是用其图形流水线还是计算流水线,或多或少需要用到一些当前设备的Vulkan核心版本所不具备的扩展特征,那么我们如何能既安全又方便地开启一些我们需要的特征呢?本文将给各位进行介绍。
我们要开启当前设备的某一扩展特征基本有两种手段。而且这两种手段并非是互斥的,而是需要一同使用。
一、指定特定的扩展名
这种是常见且常用的方式。我们先调用 vkEnumerateDeviceExtensionProperties API枚举出当前指定使用的 物理设备 一共支持多少种扩展,最后在创建 逻辑设备 时将将所需要使用的扩展名指定在 VkDeviceCreateInfo 结构体对象的 ppEnabledExtensionNames 成员之中。
下面为枚举扩展名的大致示例代码:
enum MY_CONSTANT
{
MAX_VULKAN_GLOBAL_EXT_PROPS = 256
};
// Query Vulkan extensions the current selected physical device supports
uint32_t extPropCount = 0U;
res = vkEnumerateDeviceExtensionProperties(physicalDevices[deviceIndex], NULL, &extPropCount, NULL);
if (res != VK_SUCCESS)
{
printf("vkEnumerateDeviceExtensionProperties for count failed: %d\n", res);
return res;
}
printf("The current selected physical device supports %u Vulkan extensions!\n", extPropCount);
if (extPropCount > MAX_VULKAN_GLOBAL_EXT_PROPS) {
extPropCount = MAX_VULKAN_GLOBAL_EXT_PROPS;
}
VkExtensionProperties extProps[MAX_VULKAN_GLOBAL_EXT_PROPS];
res = vkEnumerateDeviceExtensionProperties(physicalDevices[deviceIndex], NULL, &extPropCount, extProps);
if (res != VK_SUCCESS)
{
printf("vkEnumerateDeviceExtensionProperties for content failed: %d\n", res);
return res;
}
这里各位需要注意的是,某些扩展可能在当前Vulkan版本中已经被融入到核心里去了,而有些GPU设计商可能就不会再把该扩展名列出来了,因此我们用 vkEnumerateDeviceExtensionProperties 这一API时压根就枚举不到,但这并不意味着我们就无法使用该扩展。
比如说我们当前设备可能枚举不到 VK_KHR_8BIT_STORAGE_EXTENSION_NAME 这一特征,但该特征早在Vulkan 1.2版本中就已经被加入到核心中去了。此时,我们可以通过下面将会介绍的,利用其相应的特征结构体去做进一步查询。而该特征名正好有个特征结构体,名字为:VkPhysicalDevice8BitStorageFeatures。
另外,对于一些没有相应特征结构体的扩展,也可利用其对应的属性结构体进行查询。比如,如果我们当前设备没有枚举到 VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME 这一特征,那么我们可以跟subgroup相关的 VkPhysicalDeviceSubgroupProperties 这个属性中的 supportedOperations 做进一步查询。
下面我们将谈论一下Vulkan中如何通过特征结构体进行特征查询并进行开启。
边栏推荐
- AI Basics: Graphical Transformer
- NC | Tao Liang Group of West Lake University - TMPRSS2 "assists" virus infection and mediates the host invasion of Clostridium sothrix hemorrhagic toxin...
- cocos creater 热更重启导致崩溃
- AI基础:图解Transformer
- Pytorch基础--tensorboard使用(一)
- "Ruffian Heng Embedded Bimonthly" Issue 59
- 跨域问题的解决方法
- 【剑指 Offe】剑指 Offer 18. 删除链表的节点
- 7.29模拟赛总结
- MySQL——基础知识
猜你喜欢

OneFlow source code analysis: Op, Kernel and interpreter

SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)

The large-scale application of artificial intelligence AI products in industrial-grade mature shipping ports of CIMC World Lianda will create a new generation of high-efficiency smart ports and innova

MongoDB打破了原则引入SQL?

运营 23 年,昔日“国内第一大电商网站”黄了...

CCNA-子网划分(VLSM)

【总结】1396- 60+个 VSCode 插件,打造好用的编辑器

What is the value of biomedical papers? How to translate the papers into Chinese and English?

C# wpf borderless window add shadow effect

NC | 西湖大学陶亮组-TMPRSS2“助攻”病毒感染并介导索氏梭菌出血毒素的宿主入侵...
随机推荐
Pytorch基础--tensorboard使用(一)
沉浸式体验科大讯飞2022消博会“官方指定产品”
实体中增加操作方法
requet.getHeader(“token“) 为null
智慧中控屏
- daily a LeetCode 】 【 191. A number of 1
生物医学论文有何价值 论文中译英怎样翻译效果好
Go system collection
MongoDB打破了原则引入SQL?
JS提升:Promise中reject与then之间的关系
【剑指 Offer】剑指 Offer 22. 链表中倒数第k个节点
7.29模拟赛总结
LocalDate时间生成
经济新闻:错误# 15:初始化libiomp5md。dll,但发现libiomp5md。已经初始化dll。解决方法
【网站放大镜效果】两种方式实现
几个GTest、GMock的例子
怎么样的框架对于开发者是友好的?
The Meta metaverse division lost 2.8 billion in the second quarter!Still want to keep betting?Metaverse development has yet to see a way out!
WEBSOCKETPP使用简介+demo
深化校企合作 搭建技术技能人才成长“立交桥”