diff options
| author | Mark Lobodzinski <mark@lunarg.com> | 2016-03-22 10:07:26 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-03-24 07:09:15 -0600 |
| commit | 0fda7ff2b17ea83f451b59b7dbcf1f2660730eef (patch) | |
| tree | 31c233c449a3bec2134379f2cdc3506d44181cf6 /layers/parameter_validation.cpp | |
| parent | 1643e2693923cbe63017c5fbe1465756c8a07341 (diff) | |
| download | usermoji-0fda7ff2b17ea83f451b59b7dbcf1f2660730eef.tar.xz | |
layers: LX450, Tighten up queueFamilyIndex validation, fix crash
For CreateBuffer and CreateImage the QFIs should be ignored unless
sharingMode is set to CONCURRENT. Also added QFI validation to
CreateCommandPool and added a special case for when an index is
incorrectly set to QUEUE_FAMILY_IGNORED.
Change-Id: I17639230ea7aa58ab89b9b0dc33e55927e9f1c84
Diffstat (limited to 'layers/parameter_validation.cpp')
| -rw-r--r-- | layers/parameter_validation.cpp | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp index 4302e9c8..e66a117a 100644 --- a/layers/parameter_validation.cpp +++ b/layers/parameter_validation.cpp @@ -1275,6 +1275,30 @@ static std::string EnumeratorString(VkImageAspectFlagBits const &enumerator) { return enumeratorString; } +static bool validate_queue_family_indices(VkDevice device, const char *function_name, const uint32_t count, + const uint32_t *indices) { + bool skipCall = false; + layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + + for (auto i = 0u; i < count; i++) { + if (indices[i] == VK_QUEUE_FAMILY_IGNORED) { + skipCall |= + log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", + "%s: the specified queueFamilyIndex cannot be VK_QUEUE_FAMILY_IGNORED.", function_name); + } else { + const auto &queue_data = my_device_data->queueFamilyIndexMap.find(indices[i]); + if (queue_data == my_device_data->queueFamilyIndexMap.end()) { + skipCall |= log_msg( + mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", + "VkGetDeviceQueue parameter, uint32_t queueFamilyIndex %d, must have been given when the device was created.", + indices[i]); + return false; + } + } + } + return skipCall; +} + static bool ValidateEnumerator(VkQueryControlFlagBits const &enumerator) { VkQueryControlFlagBits allFlags = (VkQueryControlFlagBits)(VK_QUERY_CONTROL_PRECISE_BIT); if (enumerator & (~allFlags)) { @@ -1756,15 +1780,9 @@ bool PreGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queu layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); assert(my_device_data != nullptr); - const auto &queue_data = my_device_data->queueFamilyIndexMap.find(queueFamilyIndex); - - if (queue_data == my_device_data->queueFamilyIndexMap.end()) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "VkGetDeviceQueue parameter, uint32_t queueFamilyIndex %d, must have been given when the device was created.", - queueFamilyIndex); - return false; - } + validate_queue_family_indices(device, "vkGetDeviceQueue", 1, &queueFamilyIndex); + const auto &queue_data = my_device_data->queueFamilyIndexMap.find(queueFamilyIndex); if (queue_data->second <= queueIndex) { log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", "VkGetDeviceQueue parameter, uint32_t queueIndex %d, must be less than the number of queues given when the device " @@ -2552,6 +2570,9 @@ bool PreCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo) { log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", "vkCreateBuffer parameter, VkSharingMode pCreateInfo->sharingMode, is an unrecognized enumerator"); return false; + } else if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { + validate_queue_family_indices(device, "vkCreateBuffer", pCreateInfo->queueFamilyIndexCount, + pCreateInfo->pQueueFamilyIndices); } } @@ -2679,6 +2700,9 @@ bool PreCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo) { log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", "vkCreateImage parameter, VkSharingMode pCreateInfo->sharingMode, is an unrecognized enumerator"); return false; + } else if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { + validate_queue_family_indices(device, "vkCreateImage", pCreateInfo->queueFamilyIndexCount, + pCreateInfo->pQueueFamilyIndices); } } @@ -3935,10 +3959,12 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice devi const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; - VkBool32 skipCall = VK_FALSE; + bool skipCall = false; layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); assert(my_data != NULL); + skipCall |= validate_queue_family_indices(device, "vkCreateCommandPool", 1, &(pCreateInfo->queueFamilyIndex)); + skipCall |= parameter_validation_vkCreateCommandPool(my_data->report_data, pCreateInfo, pAllocator, pCommandPool); if (skipCall == VK_FALSE) { |
