From 38e26abbaa884eb48bfec4ddb4e0ae2c90634e06 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Mon, 26 Sep 2016 17:38:00 -0600 Subject: [PATCH] layers: Add in-use detection for VkBufferView When VkBufferView is destroyed, flag error if in-use and mark any bound cmd buffers as invalid. --- layers/core_validation.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 9f7dec9..bf6d957 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5711,14 +5711,20 @@ VKAPI_ATTR void VKAPI_CALL DestroyBuffer(VkDevice device, VkBuffer buffer, VKAPI_ATTR void VKAPI_CALL DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks *pAllocator) { layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); - + bool skip = false; std::unique_lock lock(global_lock); auto view_state = getBufferViewState(dev_data, bufferView); if (view_state) { + VK_OBJECT obj_struct = {reinterpret_cast(bufferView), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT}; + skip |= ValidateObjectNotInUse(dev_data, view_state, obj_struct); + // Any bound cmd buffers are now invalid + invalidateCommandBuffers(view_state->cb_bindings, obj_struct); + } + if (!skip) { dev_data->bufferViewMap.erase(bufferView); + lock.unlock(); + dev_data->device_dispatch_table->DestroyBufferView(device, bufferView, pAllocator); } - lock.unlock(); - dev_data->device_dispatch_table->DestroyBufferView(device, bufferView, pAllocator); } VKAPI_ATTR void VKAPI_CALL DestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator) { -- 2.7.4