aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Zulauf <jzulauf@lunarg.com>2018-04-04 14:54:11 -0600
committerjzulauf-lunarg <32470354+jzulauf-lunarg@users.noreply.github.com>2018-04-05 10:29:18 -0600
commita2d035a724fb5c031da4b9732a3d5ad438ce8a94 (patch)
tree15f3e619217420b3fc56ac3b0bd629b8dcbc368b
parent3adfafb3f10c49aebd2ca0fec32e602c7df252b4 (diff)
downloadusermoji-a2d035a724fb5c031da4b9732a3d5ad438ce8a94.tar.xz
layers: Add checks for CreateDescriptorUpdateTempl
Added four validation checks for vkCreateDescriptorUpdateTemplate(KHR) and removed a false positive. VALIDATION_ERROR_052002bc VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00350 VALIDATION_ERROR_052002be VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00351 VALIDATION_ERROR_052002c0 VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00352 VALIDATION_ERROR_052002c2 VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00353 Updated autogen of object tracker s.t. that logic for noautovalidation handles matches parameter validation, and spec generation, eliminating a source of false positives. Change-Id: Ib831eabd45a5083168355bca6b0e2beda3a76222
-rw-r--r--layers/core_validation.cpp78
-rw-r--r--layers/vk_validation_error_database.txt8
-rw-r--r--scripts/object_tracker_generator.py5
3 files changed, 77 insertions, 14 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index c02a9a52..a36cc789 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -11962,6 +11962,48 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDeviceGroupsKHR(
return result;
}
+static bool PreCallValidateCreateDescriptorUpdateTemplate(const char *func_name, layer_data *device_data,
+ const VkDescriptorUpdateTemplateCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate) {
+ bool skip = false;
+ const auto layout = GetDescriptorSetLayout(device_data, pCreateInfo->descriptorSetLayout);
+ if (VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET == pCreateInfo->templateType && !layout) {
+ auto ds_uint = HandleToUint64(pCreateInfo->descriptorSetLayout);
+ skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT,
+ ds_uint, VALIDATION_ERROR_052002bc, "%s: Invalid pCreateInfo->descriptorSetLayout (%" PRIx64 ")", func_name,
+ ds_uint);
+ } else if (VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR == pCreateInfo->templateType) {
+ auto bind_point = pCreateInfo->pipelineBindPoint;
+ bool valid_bp = (bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS) || (bind_point == VK_PIPELINE_BIND_POINT_COMPUTE);
+ if (!valid_bp) {
+ skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
+ VALIDATION_ERROR_052002be, "%s: Invalid pCreateInfo->pipelineBindPoint (%" PRIu32 ").", func_name,
+ static_cast<uint32_t>(bind_point));
+ }
+ const auto pipeline_layout = getPipelineLayout(device_data, pCreateInfo->pipelineLayout);
+ if (!pipeline_layout) {
+ uint64_t pl_uint = HandleToUint64(pCreateInfo->pipelineLayout);
+ skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
+ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT, pl_uint, VALIDATION_ERROR_052002c0,
+ "%s: Invalid pCreateInfo->pipelineLayout (%" PRIx64 ")", func_name, pl_uint);
+ } else {
+ const uint32_t pd_set = pCreateInfo->set;
+ if ((pd_set >= pipeline_layout->set_layouts.size()) || !pipeline_layout->set_layouts[pd_set] ||
+ !pipeline_layout->set_layouts[pd_set]->IsPushDescriptor()) {
+ uint64_t pl_uint = HandleToUint64(pCreateInfo->pipelineLayout);
+ skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
+ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT, pl_uint, VALIDATION_ERROR_052002c2,
+ "%s: pCreateInfo->set (%" PRIu32
+ ") does not refer to the push descriptor set layout for "
+ "pCreateInfo->pipelineLayout (%" PRIx64 ").",
+ func_name, pd_set, pl_uint);
+ }
+ }
+ }
+ return skip;
+}
+
static void PostCallRecordCreateDescriptorUpdateTemplate(layer_data *device_data,
const VkDescriptorUpdateTemplateCreateInfoKHR *pCreateInfo,
VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate) {
@@ -11976,11 +12018,19 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorUpdateTemplate(VkDevice device,
const VkAllocationCallbacks *pAllocator,
VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- VkResult result =
- device_data->dispatch_table.CreateDescriptorUpdateTemplate(device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate);
- if (VK_SUCCESS == result) {
- lock_guard_t lock(global_lock);
- PostCallRecordCreateDescriptorUpdateTemplate(device_data, pCreateInfo, pDescriptorUpdateTemplate);
+ unique_lock_t lock(global_lock);
+ bool skip = PreCallValidateCreateDescriptorUpdateTemplate("vkCreateDescriptorUpdateTemplate()", device_data, pCreateInfo,
+ pAllocator, pDescriptorUpdateTemplate);
+
+ VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
+ if (!skip) {
+ lock.unlock();
+ result =
+ device_data->dispatch_table.CreateDescriptorUpdateTemplate(device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate);
+ if (VK_SUCCESS == result) {
+ lock.lock();
+ PostCallRecordCreateDescriptorUpdateTemplate(device_data, pCreateInfo, pDescriptorUpdateTemplate);
+ }
}
return result;
}
@@ -11990,11 +12040,19 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorUpdateTemplateKHR(VkDevice device
const VkAllocationCallbacks *pAllocator,
VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- VkResult result =
- device_data->dispatch_table.CreateDescriptorUpdateTemplateKHR(device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate);
- if (VK_SUCCESS == result) {
- lock_guard_t lock(global_lock);
- PostCallRecordCreateDescriptorUpdateTemplate(device_data, pCreateInfo, pDescriptorUpdateTemplate);
+ unique_lock_t lock(global_lock);
+ bool skip = PreCallValidateCreateDescriptorUpdateTemplate("vkCreateDescriptorUpdateTemplateKHR()", device_data, pCreateInfo,
+ pAllocator, pDescriptorUpdateTemplate);
+
+ VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
+ if (!skip) {
+ lock.unlock();
+ result = device_data->dispatch_table.CreateDescriptorUpdateTemplateKHR(device, pCreateInfo, pAllocator,
+ pDescriptorUpdateTemplate);
+ if (VK_SUCCESS == result) {
+ lock.lock();
+ PostCallRecordCreateDescriptorUpdateTemplate(device_data, pCreateInfo, pDescriptorUpdateTemplate);
+ }
}
return result;
}
diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt
index b9799a4e..103e4c53 100644
--- a/layers/vk_validation_error_database.txt
+++ b/layers/vk_validation_error_database.txt
@@ -353,10 +353,10 @@ VALIDATION_ERROR_0500fc01~^~Y~^~Unknown~^~VkDescriptorSetLayoutCreateInfo~^~VUID
VALIDATION_ERROR_0501c40d~^~Y~^~Unknown~^~VkDescriptorSetLayoutCreateInfo~^~VUID-VkDescriptorSetLayoutCreateInfo-pNext-pNext~^~core~^~The spec valid usage text states 'pNext must be NULL' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetLayoutCreateInfo-pNext-pNext)~^~implicit, TBD in parameter validation layer.
VALIDATION_ERROR_0502b00b~^~Y~^~Unknown~^~VkDescriptorSetLayoutCreateInfo~^~VUID-VkDescriptorSetLayoutCreateInfo-sType-sType~^~core~^~The spec valid usage text states 'sType must be VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetLayoutCreateInfo-sType-sType)~^~implicit, TBD in parameter validation layer.
VALIDATION_ERROR_05200009~^~Y~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-commonparent~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)~^~The spec valid usage text states 'Both of descriptorSetLayout, and pipelineLayout that are valid handles must have been created, allocated, or retrieved from the same VkDevice' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-commonparent)~^~implicit
-VALIDATION_ERROR_052002bc~^~N~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00350~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)~^~The spec valid usage text states 'If templateType is VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET, descriptorSetLayout must be a valid VkDescriptorSetLayout handle' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00350)~^~
-VALIDATION_ERROR_052002be~^~N~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00351~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)+(VK_KHR_push_descriptor)~^~The spec valid usage text states 'If templateType is VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR, pipelineBindPoint must be a valid VkPipelineBindPoint value' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00351)~^~
-VALIDATION_ERROR_052002c0~^~N~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00352~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)+(VK_KHR_push_descriptor)~^~The spec valid usage text states 'If templateType is VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR, pipelineLayout must be a valid VkPipelineLayout handle' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00352)~^~
-VALIDATION_ERROR_052002c2~^~N~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00353~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)+(VK_KHR_push_descriptor)~^~The spec valid usage text states 'If templateType is VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR, set must be the unique set number in the pipeline layout that uses a descriptor set layout that was created with VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00353)~^~
+VALIDATION_ERROR_052002bc~^~Y~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00350~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)~^~The spec valid usage text states 'If templateType is VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET, descriptorSetLayout must be a valid VkDescriptorSetLayout handle' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00350)~^~
+VALIDATION_ERROR_052002be~^~Y~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00351~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)+(VK_KHR_push_descriptor)~^~The spec valid usage text states 'If templateType is VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR, pipelineBindPoint must be a valid VkPipelineBindPoint value' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00351)~^~
+VALIDATION_ERROR_052002c0~^~Y~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00352~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)+(VK_KHR_push_descriptor)~^~The spec valid usage text states 'If templateType is VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR, pipelineLayout must be a valid VkPipelineLayout handle' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00352)~^~
+VALIDATION_ERROR_052002c2~^~Y~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00353~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)+(VK_KHR_push_descriptor)~^~The spec valid usage text states 'If templateType is VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR, set must be the unique set number in the pipeline layout that uses a descriptor set layout that was created with VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00353)~^~
VALIDATION_ERROR_05204c01~^~Y~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-descriptorSetLayout-parameter~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)~^~The spec valid usage text states 'If descriptorSetLayout is not VK_NULL_HANDLE, descriptorSetLayout must be a valid VkDescriptorSetLayout handle' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-descriptorSetLayout-parameter)~^~implicit
VALIDATION_ERROR_0520501b~^~Y~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-descriptorUpdateEntryCount-arraylength~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)~^~The spec valid usage text states 'descriptorUpdateEntryCount must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-descriptorUpdateEntryCount-arraylength)~^~implicit
VALIDATION_ERROR_05209005~^~Y~^~Unknown~^~VkDescriptorUpdateTemplateCreateInfo~^~VUID-VkDescriptorUpdateTemplateCreateInfo-flags-zerobitmask~^~(VK_VERSION_1_1,VK_KHR_descriptor_update_template)~^~The spec valid usage text states 'flags must be 0' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkDescriptorUpdateTemplateCreateInfo-flags-zerobitmask)~^~implicit
diff --git a/scripts/object_tracker_generator.py b/scripts/object_tracker_generator.py
index 5130e0f4..96dabc7a 100644
--- a/scripts/object_tracker_generator.py
+++ b/scripts/object_tracker_generator.py
@@ -290,6 +290,11 @@ class ObjectTrackerOutputGenerator(OutputGenerator):
else:
print('Unrecognized len attribute value',val)
isoptional = opts
+ if not isoptional:
+ # Matching logic in parameter validation and ValidityOutputGenerator.isHandleOptional
+ optString = param.attrib.get('noautovalidity')
+ if optString and optString == 'true':
+ isoptional = True;
return isoptional
#
# Convert decimal number to 8 digit hexadecimal lower-case representation