当前位置:网站首页>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中如何通过特征结构体进行特征查询并进行开启。
边栏推荐
- Spark学习:用spark实现ETL
- The sixteenth issue of eight-part article Balabala said (MQ)
- Immersive experience iFLYTEK 2022 Consumer Expo "Official Designated Product"
- 延时队列优化 (2)
- Meta元宇宙部门第二季度亏损28亿!仍要继续押注?元宇宙发展尚未看到出路!
- LeetCode 练习——关于查找数组元素之和的两道题
- 432.4 FPS 快STDC 2.84倍 | LPS-Net 结合内存、FLOPs、CUDA实现超快语义分割模型
- ROS 环境使用第三方动态链接库(.so)文件
- What kind of framework is friendly to developers?
- AWS 控制台
猜你喜欢
6 yuan per catty, why do Japanese companies come to China to collect cigarette butts?
SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)
沉浸式体验科大讯飞2022消博会“官方指定产品”
C# wpf 无边框窗口添加阴影效果
防抖和节流有什么区别,分别用于什么场景?
Deepen school-enterprise cooperation and build an "overpass" for the growth of technical and skilled talents
Application of time series database in the field of ship risk management
《痞子衡嵌入式半月刊》 第 59 期
Mysql execution principle analysis
"Ruffian Heng Embedded Bimonthly" Issue 59
随机推荐
Critical Reviews | 南农邹建文组综述全球农田土壤抗生素与耐药基因分布
几个GTest、GMock的例子
自己需要努力
Two-point answer naked question (plus a little pigeonhole principle)
(2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
《自然语言处理实战入门》---- 文本样本扩展小技巧:使用回译技术进行样本增强
一文读懂“语言模型”
Common linked list problems and their Go implementation
微博广告分布式配置中心的构建与实践(有彩蛋)
荐号 | 对你有恩的人,不要请吃饭来报答
Delay queue optimization (2)
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!
AI基础:图解Transformer
【Pointing to Offer】Pointing to Offer 18. Delete the node of the linked list
MySQL data types
DTSE Tech Talk丨第2期:1小时深度解读SaaS应用系统设计
ByteArrayInputStream class source code analysis
【剑指 Offe】剑指 Offer 17. 打印从1到最大的n位数
The use of @ symbol in MySql
Meta元宇宙部门第二季度亏损28亿!仍要继续押注?元宇宙发展尚未看到出路!