layers: Capture device features from extension
When the VK_KHR_get_physical_device_properties2 is present, physical
device properties can be passed to VkCreate either in the
pEnabledFeatures member or VkDeviceCreateInfo or in a
VkPhysicalDeviceFeatures2KHR structure on the pNext chain.
Neither the parameter validation or core validation layers were
capturing device features from the pNext struct, causing false
parameter checking errors, when the default (all false) state was
used for later validations.
Change-Id: I187827443f09aafaa80588a78bc5b67595d0acda
diff --git a/layers/parameter_validation_utils.cpp b/layers/parameter_validation_utils.cpp
index d40c7ea..2a7511a 100644
--- a/layers/parameter_validation_utils.cpp
+++ b/layers/parameter_validation_utils.cpp
@@ -498,8 +498,22 @@
my_device_data->device = *pDevice;
// Save app-enabled features in this device's layer_data structure
- if (pCreateInfo->pEnabledFeatures) {
- my_device_data->physical_device_features = *pCreateInfo->pEnabledFeatures;
+ // The enabled features can come from either pEnabledFeatures, or from the pNext chain
+ const VkPhysicalDeviceFeatures *enabled_features_found = pCreateInfo->pEnabledFeatures;
+ if ((nullptr == enabled_features_found) && my_device_data->extensions.vk_khr_get_physical_device_properties_2) {
+ const GenericHeader *current = reinterpret_cast<const GenericHeader *>(pCreateInfo->pNext);
+ while (current) {
+ if (VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR == current->sType) {
+ const VkPhysicalDeviceFeatures2KHR *features2 = reinterpret_cast<const VkPhysicalDeviceFeatures2KHR *>(current);
+ enabled_features_found = &(features2->features);
+ current = nullptr;
+ } else {
+ current = reinterpret_cast<const GenericHeader *>(current->pNext);
+ }
+ }
+ }
+ if (enabled_features_found) {
+ my_device_data->physical_device_features = *enabled_features_found;
} else {
memset(&my_device_data->physical_device_features, 0, sizeof(VkPhysicalDeviceFeatures));
}