diff options
| author | Tobin Ehlis <tobine@google.com> | 2017-01-04 07:53:33 -0700 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2017-01-04 15:05:18 -0700 |
| commit | 6c47d2fb4ff797b39ce80ff3d6e8057734523827 (patch) | |
| tree | 740cd8fb165a6d87d16a305b33ab6a56a183c14a | |
| parent | 0d1d22eaa3dd287869d614b279c73dd23cf04365 (diff) | |
| download | usermoji-6c47d2fb4ff797b39ce80ff3d6e8057734523827.tar.xz | |
layers:Remove redundant validation check
As was noted in a comment, the core_validation check for a valid
instance in EnumeratePhysicalDevices() was replicating the same check
in object_tracker. Killing the core_validation check.
| -rw-r--r-- | layers/core_validation.cpp | 79 |
1 files changed, 36 insertions, 43 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 7277e259..ea1aedad 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -12371,52 +12371,45 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uin VkPhysicalDevice *pPhysicalDevices) { bool skip_call = false; instance_layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), instance_layer_data_map); + assert(instance_data); - if (instance_data) { - // For this instance, flag when vkEnumeratePhysicalDevices goes to QUERY_COUNT and then QUERY_DETAILS - if (NULL == pPhysicalDevices) { - instance_data->vkEnumeratePhysicalDevicesState = QUERY_COUNT; - } else { - if (UNCALLED == instance_data->vkEnumeratePhysicalDevicesState) { - // Flag warning here. You can call this without having queried the count, but it may not be - // robust on platforms with multiple physical devices. - skip_call |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - 0, __LINE__, DEVLIMITS_MISSING_QUERY_COUNT, "DL", - "Call sequence has vkEnumeratePhysicalDevices() w/ non-NULL pPhysicalDevices. You should first " - "call vkEnumeratePhysicalDevices() w/ NULL pPhysicalDevices to query pPhysicalDeviceCount."); - } // TODO : Could also flag a warning if re-calling this function in QUERY_DETAILS state - else if (instance_data->physical_devices_count != *pPhysicalDeviceCount) { - // Having actual count match count from app is not a requirement, so this can be a warning - skip_call |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", - "Call to vkEnumeratePhysicalDevices() w/ pPhysicalDeviceCount value %u, but actual count " - "supported by this instance is %u.", - *pPhysicalDeviceCount, instance_data->physical_devices_count); - } - instance_data->vkEnumeratePhysicalDevicesState = QUERY_DETAILS; - } - if (skip_call) { - return VK_ERROR_VALIDATION_FAILED_EXT; - } - VkResult result = instance_data->dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); - if (NULL == pPhysicalDevices) { - instance_data->physical_devices_count = *pPhysicalDeviceCount; - } else if (result == VK_SUCCESS){ // Save physical devices - for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { - auto & phys_device_state = instance_data->physical_device_map[pPhysicalDevices[i]]; - phys_device_state.phys_device = pPhysicalDevices[i]; - // Init actual features for each physical device - instance_data->dispatch_table.GetPhysicalDeviceFeatures(pPhysicalDevices[i], &phys_device_state.features); - } - } - return result; + // For this instance, flag when vkEnumeratePhysicalDevices goes to QUERY_COUNT and then QUERY_DETAILS + if (NULL == pPhysicalDevices) { + instance_data->vkEnumeratePhysicalDevicesState = QUERY_COUNT; } else { - // This seems redundant with object_tracker - log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, 0, __LINE__, - VALIDATION_ERROR_00023, "DL", "Invalid instance (0x%p) passed into vkEnumeratePhysicalDevices(). %s", instance, - validation_error_map[VALIDATION_ERROR_00023]); + if (UNCALLED == instance_data->vkEnumeratePhysicalDevicesState) { + // Flag warning here. You can call this without having queried the count, but it may not be + // robust on platforms with multiple physical devices. + skip_call |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, 0, __LINE__, DEVLIMITS_MISSING_QUERY_COUNT, "DL", + "Call sequence has vkEnumeratePhysicalDevices() w/ non-NULL pPhysicalDevices. You should first " + "call vkEnumeratePhysicalDevices() w/ NULL pPhysicalDevices to query pPhysicalDeviceCount."); + } // TODO : Could also flag a warning if re-calling this function in QUERY_DETAILS state + else if (instance_data->physical_devices_count != *pPhysicalDeviceCount) { + // Having actual count match count from app is not a requirement, so this can be a warning + skip_call |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", + "Call to vkEnumeratePhysicalDevices() w/ pPhysicalDeviceCount value %u, but actual count " + "supported by this instance is %u.", + *pPhysicalDeviceCount, instance_data->physical_devices_count); + } + instance_data->vkEnumeratePhysicalDevicesState = QUERY_DETAILS; + } + if (skip_call) { + return VK_ERROR_VALIDATION_FAILED_EXT; + } + VkResult result = instance_data->dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); + if (NULL == pPhysicalDevices) { + instance_data->physical_devices_count = *pPhysicalDeviceCount; + } else if (result == VK_SUCCESS) { // Save physical devices + for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { + auto &phys_device_state = instance_data->physical_device_map[pPhysicalDevices[i]]; + phys_device_state.phys_device = pPhysicalDevices[i]; + // Init actual features for each physical device + instance_data->dispatch_table.GetPhysicalDeviceFeatures(pPhysicalDevices[i], &phys_device_state.features); + } } - return VK_ERROR_VALIDATION_FAILED_EXT; + return result; } VKAPI_ATTR void VKAPI_CALL |
