aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2016-03-22 10:07:26 -0600
committerTobin Ehlis <tobine@google.com>2016-03-24 07:09:15 -0600
commit47892024546c67e8db98b51b2ddb962c21088894 (patch)
treef00b41ec64d4bf2ffc605230b2a75b303373b375
parent87e0afcd98dcf3c1e5e2cbb3023fe89d9dd10cd2 (diff)
downloadvulkan-validation-layers-47892024546c67e8db98b51b2ddb962c21088894.tar.gz
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
-rw-r--r--layers/core_validation.cpp39
-rw-r--r--layers/parameter_validation.cpp44
2 files changed, 43 insertions, 40 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 4ea26ba5e..625079034 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -6293,30 +6293,11 @@ vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocation
loader_platform_thread_unlock_mutex(&globalLock);
}
-VkBool32 validate_queue_family_indices(layer_data *dev_data, const char *function_name, const uint32_t count,
- const uint32_t *indices) {
- VkBool32 skipCall = VK_FALSE;
- for (auto i = 0; i < count; i++) {
- if (indices[i] >= dev_data->physDevProperties.queue_family_properties.size()) {
- skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__,
- DRAWSTATE_INVALID_QUEUE_INDEX, "DS",
- "%s has QueueFamilyIndex greater than the number of QueueFamilies (" PRINTF_SIZE_T_SPECIFIER
- ") for this device.",
- function_name, dev_data->physDevProperties.queue_family_properties.size());
- }
- }
- return skipCall;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
-vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) {
- VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
+VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) {
layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
- bool skipCall = validate_queue_family_indices(dev_data, "vkCreateBuffer", pCreateInfo->queueFamilyIndexCount,
- pCreateInfo->pQueueFamilyIndices);
- if (!skipCall) {
- result = dev_data->device_dispatch_table->CreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
- }
+
+ VkResult result = dev_data->device_dispatch_table->CreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
if (VK_SUCCESS == result) {
loader_platform_thread_lock_mutex(&globalLock);
@@ -6350,15 +6331,11 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice devic
return result;
}
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
-vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage) {
- VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
+VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator, VkImage *pImage) {
layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
- bool skipCall = validate_queue_family_indices(dev_data, "vkCreateImage", pCreateInfo->queueFamilyIndexCount,
- pCreateInfo->pQueueFamilyIndices);
- if (!skipCall) {
- result = dev_data->device_dispatch_table->CreateImage(device, pCreateInfo, pAllocator, pImage);
- }
+
+ VkResult result = dev_data->device_dispatch_table->CreateImage(device, pCreateInfo, pAllocator, pImage);
if (VK_SUCCESS == result) {
loader_platform_thread_lock_mutex(&globalLock);
diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp
index 4302e9c8e..e66a117a0 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) {