aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Lentine <mlentine@google.com>2016-01-27 17:52:20 -0600
committerMark Lobodzinski <mark@lunarg.com>2016-01-27 17:57:43 -0700
commitd7de4f5fb7954a889abe9384afd279c9c5a7c0e7 (patch)
treecdde682e8a808320f5245eae41a58e5dd3b83cea
parenta3a7fd6cb59a00866de2b46763522351d0d1f7c5 (diff)
downloadusermoji-d7de4f5fb7954a889abe9384afd279c9c5a7c0e7.tar.xz
layers: MR172, Add draw_state cmdbuffer lifetime checks to cmd pool destruction
-rw-r--r--layers/draw_state.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index e3b9e218..1bc59df1 100644
--- a/layers/draw_state.cpp
+++ b/layers/draw_state.cpp
@@ -3636,6 +3636,24 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice devi
}
return result;
}
+
+bool validateCommandBuffersNotInUse(const layer_data* dev_data, VkCommandPool commandPool) {
+ bool skip_call = false;
+ loader_platform_thread_lock_mutex(&globalLock);
+ auto pool_data = dev_data->commandPoolMap.find(commandPool);
+ if (pool_data != dev_data->commandPoolMap.end()) {
+ for (auto cmdBuffer : pool_data->second.commandBuffers) {
+ if (dev_data->inFlightCmdBuffers.count(cmdBuffer)) {
+ skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT, reinterpret_cast<uint64_t>(commandPool),
+ __LINE__, DRAWSTATE_OBJECT_INUSE, "DS", "Cannot reset command pool %" PRIx64 " when allocated command buffer %" PRIx64 " is in use.",
+ reinterpret_cast<uint64_t>(commandPool), reinterpret_cast<uint64_t>(cmdBuffer));
+ }
+ }
+ }
+ loader_platform_thread_unlock_mutex(&globalLock);
+ return skip_call;
+}
+
// Destroy commandPool along with all of the commandBuffers allocated from that pool
VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator)
{
@@ -3654,6 +3672,10 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device,
dev_data->commandPoolMap.erase(commandPool);
loader_platform_thread_unlock_mutex(&globalLock);
+
+ if (validateCommandBuffersNotInUse(dev_data, commandPool))
+ return;
+
dev_data->device_dispatch_table->DestroyCommandPool(device, commandPool, pAllocator);
}
@@ -3665,21 +3687,7 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(
layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
- bool skip_call = false;
- loader_platform_thread_lock_mutex(&globalLock);
- auto pool_data = dev_data->commandPoolMap.find(commandPool);
- if (pool_data != dev_data->commandPoolMap.end()) {
- for (auto cmdBuffer : pool_data->second.commandBuffers) {
- if (dev_data->inFlightCmdBuffers.count(cmdBuffer)) {
- skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT, reinterpret_cast<uint64_t>(commandPool),
- __LINE__, DRAWSTATE_OBJECT_INUSE, "DS", "Cannot reset command pool %" PRIx64 " when allocated command buffer %" PRIx64 " is in use.",
- reinterpret_cast<uint64_t>(commandPool), reinterpret_cast<uint64_t>(cmdBuffer));
- }
- }
- }
- loader_platform_thread_unlock_mutex(&globalLock);
-
- if (skip_call)
+ if (validateCommandBuffersNotInUse(dev_data, commandPool))
return VK_ERROR_VALIDATION_FAILED_EXT;
result = dev_data->device_dispatch_table->ResetCommandPool(device, commandPool, flags);