aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorJohn Zulauf <jzulauf@lunarg.com>2017-10-18 18:21:23 -0600
committerjzulauf-lunarg <32470354+jzulauf-lunarg@users.noreply.github.com>2017-10-30 14:26:07 -0600
commitd67dca051138146b29d94546cd7ab240c5a8a076 (patch)
treefec38d11e45d45235e10d308d549ff2e52451253 /layers/core_validation.cpp
parent4c73582f2c9313d02611db141eb1c9fd269537ce (diff)
downloadusermoji-d67dca051138146b29d94546cd7ab240c5a8a076.tar.xz
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
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 1f4087f4..3af2df02 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -2139,9 +2139,25 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice gpu, const VkDevice
}
// Check that any requested features are available
- if (pCreateInfo->pEnabledFeatures) {
- skip |= ValidateRequestedFeatures(instance_data, pd_state, 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) {
+ GENERIC_HEADER *struct_header = (GENERIC_HEADER *)pCreateInfo->pNext;
+ while (struct_header) {
+ if (VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR == struct_header->sType) {
+ VkPhysicalDeviceFeatures2KHR *features2 = (VkPhysicalDeviceFeatures2KHR *)struct_header;
+ enabled_features_found = &(features2->features);
+ struct_header = nullptr;
+ } else {
+ struct_header = (GENERIC_HEADER *)struct_header->pNext;
+ }
+ }
+ }
+
+ if (enabled_features_found) {
+ skip |= ValidateRequestedFeatures(instance_data, pd_state, enabled_features_found);
}
+
skip |=
ValidateDeviceQueueCreateInfos(instance_data, pd_state, pCreateInfo->queueCreateInfoCount, pCreateInfo->pQueueCreateInfos);
@@ -2188,8 +2204,8 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice gpu, const VkDevice
instance_data->dispatch_table.GetPhysicalDeviceQueueFamilyProperties(
gpu, &count, &device_data->phys_dev_properties.queue_family_properties[0]);
// TODO: device limits should make sure these are compatible
- if (pCreateInfo->pEnabledFeatures) {
- device_data->enabled_features = *pCreateInfo->pEnabledFeatures;
+ if (enabled_features_found) {
+ device_data->enabled_features = *enabled_features_found;
} else {
memset(&device_data->enabled_features, 0, sizeof(VkPhysicalDeviceFeatures));
}