当前位置:网站首页>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中如何通过特征结构体进行特征查询并进行开启。
边栏推荐
- 微信小程序云开发 | 城市信息管理
- LeetCode Exercise - Two Questions About Finding Sum of Array Elements
- WEBSOCKETPP使用简介+demo
- ESP8266-Arduino programming example-HC-SR04 ultrasonic sensor driver
- 博纳影通过IPO注册:阿里腾讯是股东 受疫情冲击明显
- 6块钱1斤,日本公司为何来中国收烟头?
- requet.getHeader("token") is null
- 设计消息队列存储消息数据的 MySQL 表格
- LeetCode每日一题(1717. Maximum Score From Removing Substrings)
- 二分答案裸题(加一点鸽巢原理)
猜你喜欢

One year after graduation, I was engaged in software testing and won 11.5k. I didn't lose face to the post-98 generation...

NC | 西湖大学陶亮组-TMPRSS2“助攻”病毒感染并介导索氏梭菌出血毒素的宿主入侵...

Scrapy framework is introduced

6块钱1斤,日本公司为何来中国收烟头?

自然语言处理nltk

Mongo for infrastructure

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!

Application of time series database in the field of ship risk management

CCNA-ACL(访问控制列表)标准ACL 扩展ACL 命名ACL

- daily a LeetCode 】 【 191. A number of 1
随机推荐
深化校企合作 搭建技术技能人才成长“立交桥”
while,do while,for循环语句
Hello, my new name is "Bronze Lock/Tongsuo"
LeetCode Exercise - Two Questions About Finding Sum of Array Elements
运营 23 年,昔日“国内第一大电商网站”黄了...
MySql中@符号的使用
Pytorch foundation -- tensorboard use (1)
Anaconda Navigator卡在loading applications
JS提升:Promise中reject与then之间的关系
MYSQL (Basic) - An article takes you into the wonderful world of MYSQL
Chapter 14 Type Information
CIMC Shilian Dafeitong is the global industrial artificial intelligence AI leader, the world's top AI core technology, high generalization, high robustness, sparse sample continuous learning, industri
【Qt Designer工具的使用】
一文读懂“语言模型”
Critical Reviews | A review of the global distribution of antibiotics and resistance genes in farmland soil by Nannong Zou Jianwen's group
攻防世界web-Cat
Common linked list problems and their Go implementation
解决终极bug,项目最终能顺利部署上线。
MySQL数据类型
AI基础:图解Transformer