diff options
| author | Tobin Ehlis <tobine@google.com> | 2016-10-12 09:29:26 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-10-13 19:13:33 -0600 |
| commit | ad69bb638f91659f9b2c079d9ce2bf45910f622e (patch) | |
| tree | 3cac7b2ce1380403b51356571f2d4fa85c390639 /layers/core_validation.cpp | |
| parent | a275509eb92eac647a885f1d4aa65adecacb88f9 (diff) | |
| download | usermoji-ad69bb638f91659f9b2c079d9ce2bf45910f622e.tar.xz | |
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.
Diffstat (limited to 'layers/core_validation.cpp')
| -rw-r--r-- | layers/core_validation.cpp | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index a16b699c..ac690b18 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<uint64_t &>(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<std::mutex> 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 |
