Skip to content

Latest commit

 

History

History
72 lines (49 loc) · 2.84 KB

enabling_features.md

File metadata and controls

72 lines (49 loc) · 2.84 KB

Enabling Features

This section goes over the logistics for enabling features.

Category of Features

All features in Vulkan can be categorized/found in 3 sections

  1. Core 1.0 Features
    • These are the set of features that were available from the initial 1.0 release of Vulkan. The list of features can be found in VkPhysicalDeviceFeatures
  2. Future Core Version Features
  3. Extension Features
    • Sometimes extensions contain features in order to enable certain aspects of the extension. These are easily found as they are all labeled as VkPhysicalDevice[[ExtensionName]]Features

How to Enable the Features

All features must be enabled at VkDevice creation time inside the VkDeviceCreateInfo struct.

Don't forget to query first with vkGetPhysicalDeviceFeatures or vkGetPhysicalDeviceFeatures2

For the Core 1.0 Features, this is as simple as setting VkDeviceCreateInfo::pEnabledFeatures with the features desired to be turned on.

VkPhysicalDeviceFeatures features = {};
vkGetPhysicalDeviceFeatures(physical_device, &features);

// Logic if feature is not supported
if (features.robustBufferAccess == VK_FALSE) {
}

VkDeviceCreateInfo info = {};
info.pEnabledFeatures = &features;

For all features, including the Core 1.0 Features, use VkPhysicalDeviceFeatures2 to pass into VkDeviceCreateInfo.pNext

VkPhysicalDeviceShaderDrawParametersFeatures ext_feature = {};

VkPhysicalDeviceFeatures2 physical_features2 = {};
physical_features2.pNext = &ext_feature;

vkGetPhysicalDeviceFeatures2(physical_device, &physical_features2);

// Logic if feature is not supported
if (ext_feature.shaderDrawParameters == VK_FALSE) {
}

VkDeviceCreateInfo info = {};
info.pNext = &physical_features2;

The same works for the "Future Core Version Features" too.

VkPhysicalDeviceVulkan11Features features11 = {};

VkPhysicalDeviceFeatures2 physical_features2 = {};
physical_features2.pNext = &features11;

vkGetPhysicalDeviceFeatures2(physical_device, &physical_features2);

// Logic if feature is not supported
if (features11.shaderDrawParameters == VK_FALSE) {
}

VkDeviceCreateInfo info = {};
info.pNext = &physical_features2;