From ab4e56a3b14867ece89152071d2eeee91ad1da3b Mon Sep 17 00:00:00 2001 From: Eskil Sund Date: Fri, 6 Apr 2018 16:56:32 +0200 Subject: layers: Add VALIDATION_ERROR_32a00272 This adds VALIDATION_ERROR_32a00272 to core validation layer to catch reset of descriptor pool in-flight. Also adding an accompanying test case and an update of the validation layer database to reflect new validation and test. --- layers/core_validation.cpp | 34 +++++++++++++++++++++++++++++++-- layers/vk_validation_error_database.txt | 2 +- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 30d6f3cb..5dd1e098 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -1584,6 +1584,32 @@ static bool validateIdleDescriptorSet(const layer_data *dev_data, VkDescriptorSe return skip; } +// Validate that given pool does not store any descriptor sets used by an in-flight CmdBuffer +// pool stores the descriptor sets to be validated +// Return false if no errors occur +// Return true if validation error occurs and callback returns true (to skip upcoming API call down the chain) +static bool validateIdleDescriptorSetForPoolReset(const layer_data *dev_data, const VkDescriptorPool pool) { + if (dev_data->instance_data->disabled.idle_descriptor_set) return false; + bool skip = false; + DESCRIPTOR_POOL_STATE *pPool = GetDescriptorPoolState(dev_data, pool); + for (auto ds : pPool->sets) { + if (ds != VK_NULL_HANDLE) { + auto set_node = dev_data->setMap.find(ds->GetSet()); + if (set_node != dev_data->setMap.end()) { + if (set_node->second->in_use.load()) { + skip |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, HandleToUint64(pool), VALIDATION_ERROR_32a00272, + "It is invalid to call vkResetDescriptorPool() with descriptor sets in use by a command buffer. %s", + validation_error_map[VALIDATION_ERROR_32a00272]); + if (skip) break; + } + } + } + } + return skip; +} + // Remove set from setMap and delete the set static void freeDescriptorSet(layer_data *dev_data, cvdescriptorset::DescriptorSet *descriptor_set) { dev_data->setMap.erase(descriptor_set->GetSet()); @@ -5733,11 +5759,15 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorPool(VkDevice device, const VkDes VKAPI_ATTR VkResult VKAPI_CALL ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) { - // TODO : Add checks for VALIDATION_ERROR_32a00272 + lock_guard_t lock(global_lock); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); + + // Make sure sets being destroyed are not currently in-use + bool skip = validateIdleDescriptorSetForPoolReset(dev_data, descriptorPool); + if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; + VkResult result = dev_data->dispatch_table.ResetDescriptorPool(device, descriptorPool, flags); if (VK_SUCCESS == result) { - lock_guard_t lock(global_lock); clearDescriptorPool(dev_data, device, descriptorPool, flags); } return result; diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt index fcafa9cd..7a81ebed 100644 --- a/layers/vk_validation_error_database.txt +++ b/layers/vk_validation_error_database.txt @@ -3380,7 +3380,7 @@ VALIDATION_ERROR_32802801~^~Y~^~None~^~vkResetCommandPool~^~VUID-vkResetCommandP VALIDATION_ERROR_32802807~^~Y~^~Unknown~^~vkResetCommandPool~^~VUID-vkResetCommandPool-commandPool-parent~^~core~^~The spec valid usage text states 'commandPool must have been created, allocated, or retrieved from device' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetCommandPool-commandPool-parent)~^~implicit VALIDATION_ERROR_32805601~^~Y~^~None~^~vkResetCommandPool~^~VUID-vkResetCommandPool-device-parameter~^~core~^~The spec valid usage text states 'device must be a valid VkDevice handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetCommandPool-device-parameter)~^~implicit VALIDATION_ERROR_32809001~^~Y~^~Unknown~^~vkResetCommandPool~^~VUID-vkResetCommandPool-flags-parameter~^~core~^~The spec valid usage text states 'flags must be a valid combination of VkCommandPoolResetFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetCommandPool-flags-parameter)~^~implicit, TBD in parameter validation layer. -VALIDATION_ERROR_32a00272~^~N~^~Unknown~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-descriptorPool-00313~^~core~^~The spec valid usage text states 'All uses of descriptorPool (via any allocated descriptor sets) must have completed execution' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-descriptorPool-00313)~^~ +VALIDATION_ERROR_32a00272~^~Y~^~Unknown~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-descriptorPool-00313~^~core~^~The spec valid usage text states 'All uses of descriptorPool (via any allocated descriptor sets) must have completed execution' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-descriptorPool-00313)~^~ VALIDATION_ERROR_32a04601~^~Y~^~InvalidDescriptorPool~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-descriptorPool-parameter~^~core~^~The spec valid usage text states 'descriptorPool must be a valid VkDescriptorPool handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-descriptorPool-parameter)~^~implicit VALIDATION_ERROR_32a04607~^~Y~^~Unknown~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-descriptorPool-parent~^~core~^~The spec valid usage text states 'descriptorPool must have been created, allocated, or retrieved from device' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-descriptorPool-parent)~^~implicit VALIDATION_ERROR_32a05601~^~Y~^~None~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-device-parameter~^~core~^~The spec valid usage text states 'device must be a valid VkDevice handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-device-parameter)~^~implicit -- cgit v1.2.3