From c9123fa78325215f14b9f034580f5b4e07a71958 Mon Sep 17 00:00:00 2001 From: Petr Kraus Date: Wed, 27 Sep 2017 18:56:51 +0200 Subject: layers: Implement vkCreateDescriptorPool() checks Check explicit validity of vkCreateDescriptorPool(): - maxSets > 0 - pPoolSizes[].descriptorCount > 0 + implement relevant tests --- layers/parameter_validation_utils.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'layers/parameter_validation_utils.cpp') diff --git a/layers/parameter_validation_utils.cpp b/layers/parameter_validation_utils.cpp index 4f6f5b8c..d40c7eaf 100644 --- a/layers/parameter_validation_utils.cpp +++ b/layers/parameter_validation_utils.cpp @@ -2344,6 +2344,35 @@ bool pv_vkDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObject return false; } +bool pv_vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool) { + auto device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); + bool skip = false; + + if (pCreateInfo) { + if (pCreateInfo->maxSets <= 0) { + skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_0480025a, + LayerName, "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0. %s", + validation_error_map[VALIDATION_ERROR_0480025a]); + } + + if (pCreateInfo->pPoolSizes) { + for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { + if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { + skip |= log_msg( + device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, + VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_04a0025c, LayerName, + "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0. %s", + i, validation_error_map[VALIDATION_ERROR_04a0025c]); + } + } + } + } + + return skip; +} + VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *funcName) { const auto item = name_to_funcptr_map.find(funcName); if (item != name_to_funcptr_map.end()) { @@ -2378,7 +2407,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetPhysicalDeviceProcAddr(VkInstance // If additional validation is needed outside of the generated checks, a manual routine can be added to this file // and the address filled in here. The autogenerated source will call these routines if the pointers are not NULL. -void InitializeManualParameterValidationFunctionPointers(void) { +void InitializeManualParameterValidationFunctionPointers() { custom_functions["vkGetDeviceQueue"] = (void*)pv_vkGetDeviceQueue; custom_functions["vkCreateBuffer"] = (void*)pv_vkCreateBuffer; custom_functions["vkCreateImage"] = (void*)pv_vkCreateImage; @@ -2404,6 +2433,7 @@ void InitializeManualParameterValidationFunctionPointers(void) { custom_functions["vkCmdFillBuffer"] = (void*)pv_vkCmdFillBuffer; custom_functions["vkCreateSwapchainKHR"] = (void*)pv_vkCreateSwapchainKHR; custom_functions["vkQueuePresentKHR"] = (void*)pv_vkQueuePresentKHR; + custom_functions["vkCreateDescriptorPool"] = (void*)pv_vkCreateDescriptorPool; } } // namespace parameter_validation -- cgit v1.2.3