Vkgetphysicaldevicefeatures2 [best]
// 1. Define the structs you care about VkPhysicalDeviceFeatures2 features2 = .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 ; VkPhysicalDeviceVulkan13Features vulkan13Features = .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES ; VkPhysicalDeviceRayTracingPipelineFeaturesKHR rtFeatures = .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR ;
While safe, this is verbose. Helper libraries (like Volk or C++ wrappers) often abstract this away, but in raw C, it adds significant code volume. vkgetphysicaldevicefeatures2
The original VkPhysicalDeviceFeatures was a fixed-size struct. When Khronos introduced new features (e.g., shaderInt16 , descriptorIndexing ), they could not add new flags without breaking binary compatibility. Their solution was to create new VkPhysicalDevice*Features structs for each extension or core version—for example, VkPhysicalDeviceVulkan12Features . However, there was no standardized, type-safe way to query all features in a single call. Developers had to call separate functions for each extension or core version, leading to verbose, error-prone code. However, there was no standardized, type-safe way to
It is critical to note that you usually need to enable an instance extension (or rely on a specific Vulkan version) before you can query the corresponding feature structs. creating a chain.
In Vulkan 1.0, developers relied on vkGetPhysicalDeviceFeatures . While functional, it returned a fixed VkPhysicalDeviceFeatures struct. As the Khronos Group introduced new hardware features—like ray tracing, mesh shaders, or variable rate shading—this fixed structure became a bottleneck. There was no clean way to append new features without breaking the existing API.
: Always ensure every struct in your chain has the correct sType initialized. Forgetting this is a leading cause of driver crashes and "garbage" data returns. Conclusion
: The "secret sauce." This pointer can point to another feature structure (e.g., VkPhysicalDeviceRayTracingPipelineFeaturesKHR ), creating a chain.