aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2016-07-08 14:22:01 -0600
committerTobin Ehlis <tobine@google.com>2016-07-13 11:29:38 -0600
commit54091cf3b7b2068543a931aca5af206adfa475f8 (patch)
treea43c8b0310efd5cae351c34069f89800a24b67a8
parent947aad8ad391dca912ede308bb7b885c63d86148 (diff)
downloadusermoji-54091cf3b7b2068543a931aca5af206adfa475f8.tar.xz
layers: Handle binding between cmd buffer and query pools
For the CmdBind* functions that involve queryPool object, add a binding between the cmd buffer and the queryPool. In the event that a queryPool is destroyed, invalidate any bound cmd buffers and make sure invalid reporting is handled correctly for query pools. When a cmd buffer is destroyed that has query pool bindings, those bindings will be cleared under existing object_binding cleanup in resetCB.
-rw-r--r--layers/core_validation.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 8883a00a..126345a8 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -335,6 +335,14 @@ EVENT_NODE *getEventNode(layer_data *dev_data, VkEvent event) {
return &it->second;
}
+QUERY_POOL_NODE *getQueryPoolNode(layer_data *dev_data, VkQueryPool query_pool) {
+ auto it = dev_data->queryPoolMap.find(query_pool);
+ if (it == dev_data->queryPoolMap.end()) {
+ return nullptr;
+ }
+ return &it->second;
+}
+
QUEUE_NODE *getQueueNode(layer_data *dev_data, VkQueue queue) {
auto it = dev_data->queueMap.find(queue);
if (it == dev_data->queueMap.end()) {
@@ -648,6 +656,8 @@ static const char *object_type_to_string(VkDebugReportObjectTypeEXT type) {
return "buffer";
case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT:
return "event";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT:
+ return "query pool";
default:
return "unknown";
}
@@ -3745,6 +3755,12 @@ static void removeCommandBufferBinding(layer_data *dev_data, VK_OBJECT const *ob
evt_node->cb_bindings.erase(cb_node);
break;
}
+ case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT: {
+ auto qp_node = getQueryPoolNode(dev_data, reinterpret_cast<VkQueryPool>(object->handle));
+ if (qp_node)
+ qp_node->cb_bindings.erase(cb_node);
+ break;
+ }
default:
assert(0); // unhandled object type
}
@@ -5041,9 +5057,17 @@ VKAPI_ATTR void VKAPI_CALL DestroyEvent(VkDevice device, VkEvent event, const Vk
VKAPI_ATTR void VKAPI_CALL
DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks *pAllocator) {
- get_my_data_ptr(get_dispatch_key(device), layer_data_map)
- ->device_dispatch_table->DestroyQueryPool(device, queryPool, pAllocator);
- // TODO : Clean up any internal data structures using this obj.
+ layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
+ dev_data->device_dispatch_table->DestroyQueryPool(device, queryPool, pAllocator);
+
+ std::unique_lock<std::mutex> lock(global_lock);
+ auto qp_node = getQueryPoolNode(dev_data, queryPool);
+ if (qp_node) {
+ // Any bound cmd buffers are now invalid
+ invalidateCommandBuffers(qp_node->cb_bindings,
+ {reinterpret_cast<uint64_t &>(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT});
+ dev_data->queryPoolMap.erase(queryPool);
+ }
}
VKAPI_ATTR VkResult VKAPI_CALL GetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
@@ -8164,6 +8188,8 @@ CmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slo
pCB->startedQueries.insert(query);
}
skip_call |= addCmd(dev_data, pCB, CMD_BEGINQUERY, "vkCmdBeginQuery()");
+ addCommandBufferBinding(&getQueryPoolNode(dev_data, queryPool)->cb_bindings,
+ {reinterpret_cast<uint64_t &>(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, pCB);
}
lock.unlock();
if (!skip_call)
@@ -8192,6 +8218,8 @@ VKAPI_ATTR void VKAPI_CALL CmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPoo
} else {
skip_call |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdEndQuery()");
}
+ addCommandBufferBinding(&getQueryPoolNode(dev_data, queryPool)->cb_bindings,
+ {reinterpret_cast<uint64_t &>(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, pCB);
}
lock.unlock();
if (!skip_call)
@@ -8217,6 +8245,8 @@ CmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t
skip_call |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdResetQueryPool()");
}
skip_call |= insideRenderPass(dev_data, pCB, "vkCmdQueryPool");
+ addCommandBufferBinding(&getQueryPoolNode(dev_data, queryPool)->cb_bindings,
+ {reinterpret_cast<uint64_t &>(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, pCB);
}
lock.unlock();
if (!skip_call)
@@ -8286,6 +8316,8 @@ CmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, ui
skip_call |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdCopyQueryPoolResults()");
}
skip_call |= insideRenderPass(dev_data, cb_node, "vkCmdCopyQueryPoolResults");
+ addCommandBufferBinding(&getQueryPoolNode(dev_data, queryPool)->cb_bindings,
+ {reinterpret_cast<uint64_t &>(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, cb_node);
} else {
assert(0);
}