Using Vulkan -- Querying Properties, Extensions, Features, Limits, and Formats -- Enabling Features
本节讲解启用features的具体流程。Category of FeaturesVulkan 中的所有 feature 可归为 / 查自以下 3 类Core 1.0 Features这些是 Vulkan 1.0 初始版本就提供的特性集合。特性列表可在VkPhysicalDeviceFeatures中找到。Future Core Version Features从 Vulkan 1.1 开始core 版本中加入了一些新特性。为保持VkPhysicalDeviceFeatures的大小与向后兼容新增了专门的结构体来存放这些特性VkPhysicalDeviceVulkan11FeaturesVkPhysicalDeviceVulkan12FeaturesExtension Features有些 extension 内部包含需要显式启用的 feature。它们很容易识别命名格式均为VkPhysicalDevice[ExtensionName]FeaturesHow to Enable the Features所有 feature 都必须在创建VkDevice时通过VkDeviceCreateInfo结构体启用。注意不要忘记先用vkGetPhysicalDeviceFeatures或vkGetPhysicalDeviceFeatures2查询是否支持。对于 Core 1.0 Features只需将需要开启的特性填入VkDeviceCreateInfo::pEnabledFeatures即可。VkPhysicalDeviceFeatures features {}; vkGetPhysicalDeviceFeatures(physical_device, features); // 如果特性不支持的处理逻辑 if (features.robustBufferAccess VK_FALSE) { } VkDeviceCreateInfo info {}; info.pEnabledFeatures features;对于所有特性包括 Core 1.0 Features推荐使用VkPhysicalDeviceFeatures2并通过VkDeviceCreateInfo.pNext传入。VkPhysicalDeviceShaderDrawParametersFeatures ext_feature {}; ext_feature.sType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES; VkPhysicalDeviceFeatures2 physical_features2 {}; physical_features2.sType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; physical_features2.pNext ext_feature; vkGetPhysicalDeviceFeatures2(physical_device, physical_features2); // 如果特性不支持的处理逻辑 if (ext_feature.shaderDrawParameters VK_FALSE) { } VkDeviceCreateInfo info {}; info.pNext physical_features2;同样的方法也适用于 “Future Core Version Features”。VkPhysicalDeviceVulkan11Features features11 {}; features11.sType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; VkPhysicalDeviceFeatures2 physical_features2 {}; physical_features2.sType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; physical_features2.pNext features11; vkGetPhysicalDeviceFeatures2(physical_device, physical_features2); // 如果特性不支持的处理逻辑 if (features11.shaderDrawParameters VK_FALSE) { } VkDeviceCreateInfo info {}; info.pNext physical_features2;
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2415726.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!