From: Tobin Ehlis Date: Wed, 12 Oct 2016 15:29:26 +0000 (-0600) Subject: layers:Add validation to DestroyDescriptorPool X-Git-Tag: upstream/1.1.92~2344 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad69bb638f91659f9b2c079d9ce2bf45910f622e;p=platform%2Fupstream%2FVulkan-Tools.git layers:Add validation to DestroyDescriptorPool Add validation flag for DestroyDescriptorPool and update it with validation code using the Pre/Post pattern. Flag error if descriptor pool is in use and invalidate any cmd buffers that it was bound to. Remove pool state from map when it's destroyed. When the pool is destroyed make sure all of its descriptor sets are also freed. --- diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index a16b699..ac690b1 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -6084,12 +6084,44 @@ DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetL ->dispatch_table.DestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator); } +static bool PreCallValidateDestroyDescriptorPool(layer_data *dev_data, VkDescriptorPool pool, + DESCRIPTOR_POOL_NODE **desc_pool_state, VK_OBJECT *obj_struct) { + if (dev_data->instance_state->disabled.destroy_descriptor_pool) + return false; + bool skip = false; + *desc_pool_state = getPoolNode(dev_data, pool); + if (*desc_pool_state) { + *obj_struct = {reinterpret_cast(pool), VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT}; + skip |= ValidateObjectNotInUse(dev_data, *desc_pool_state, *obj_struct); + } + return skip; +} + +static void PostCallRecordDestroyDescriptorPool(layer_data *dev_data, VkDescriptorPool descriptorPool, + DESCRIPTOR_POOL_NODE *desc_pool_state, VK_OBJECT obj_struct) { + // Any bound cmd buffers are now invalid + invalidateCommandBuffers(desc_pool_state->cb_bindings, obj_struct); + // Free sets that were in this pool + for (auto ds : desc_pool_state->sets) { + freeDescriptorSet(dev_data, ds); + } + dev_data->descriptorPoolMap.erase(descriptorPool); +} + VKAPI_ATTR void VKAPI_CALL DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator) { // TODO : Add checks for VALIDATION_ERROR_00901 - // TODO : Clean up any internal data structures using this obj. - get_my_data_ptr(get_dispatch_key(device), layer_data_map) - ->dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator); + layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + DESCRIPTOR_POOL_NODE *desc_pool_state = nullptr; + VK_OBJECT obj_struct; + std::unique_lock lock(global_lock); + bool skip = PreCallValidateDestroyDescriptorPool(dev_data, descriptorPool, &desc_pool_state, &obj_struct); + if (!skip) { + lock.unlock(); + dev_data->dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator); + lock.lock(); + PostCallRecordDestroyDescriptorPool(dev_data, descriptorPool, desc_pool_state, obj_struct); + } } // Verify cmdBuffer in given cb_node is not in global in-flight set, and return skip_call result // If this is a secondary command buffer, then make sure its primary is also in-flight diff --git a/layers/core_validation.h b/layers/core_validation.h index b39ed60..26d87f8 100644 --- a/layers/core_validation.h +++ b/layers/core_validation.h @@ -74,6 +74,7 @@ struct CHECK_DISABLED { bool destroy_buffer_view; // Skip validation at DestroyBufferView time bool destroy_image_view; // Skip validation at DestroyImageView time bool destroy_pipeline; // Skip validation at DestroyPipeline time + bool destroy_descriptor_pool; // Skip validation at DestroyDescriptorPool time bool object_in_use; // Skip all object in_use checking bool idle_descriptor_set; // Skip check to verify that descriptor set is no in-use bool push_constant_range; // Skip push constant range checks