From 4a9ab2415718bfb9eb72acf7304a20de8f0eb6a8 Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Mon, 13 Nov 2017 13:42:20 -0700 Subject: [PATCH] layers: Refactor PreCallValidateGetQueryPoolResults Cleared up logic flow. Change-Id: I32157a408a7ff7e413ab82b05bf86de48f98495b --- layers/core_validation.cpp | 61 +++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index c07fe5b..2940f6d 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -3394,11 +3394,11 @@ static bool PreCallValidateGetQueryPoolResults(layer_data *dev_data, VkQueryPool for (auto cmd_buffer : dev_data->commandBufferMap) { if (cmd_buffer.second->in_use.load()) { for (auto query_state_pair : cmd_buffer.second->queryToStateMap) { - (*queries_in_flight)[query_state_pair.first].push_back( - cmd_buffer.first); + (*queries_in_flight)[query_state_pair.first].push_back(cmd_buffer.first); } } } + if (dev_data->instance_data->disabled.get_query_pool_results) return false; bool skip = false; for (uint32_t i = 0; i < query_count; ++i) { @@ -3407,45 +3407,44 @@ static bool PreCallValidateGetQueryPoolResults(layer_data *dev_data, VkQueryPool auto query_state_pair = dev_data->queryToStateMap.find(query); if (query_state_pair != dev_data->queryToStateMap.end()) { // Available and in flight - if (qif_pair != queries_in_flight->end() && query_state_pair->second) { - for (auto cmd_buffer : qif_pair->second) { - auto cb = GetCBNode(dev_data, cmd_buffer); - auto query_event_pair = cb->waitedEventsBeforeQueryReset.find(query); - if (query_event_pair == cb->waitedEventsBeforeQueryReset.end()) { + if (qif_pair != queries_in_flight->end()) { + if (query_state_pair->second) { + for (auto cmd_buffer : qif_pair->second) { + auto cb = GetCBNode(dev_data, cmd_buffer); + auto query_event_pair = cb->waitedEventsBeforeQueryReset.find(query); + if (query_event_pair == cb->waitedEventsBeforeQueryReset.end()) { + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", + "Cannot get query results on queryPool 0x%" PRIx64 " with index %d which is in flight.", + HandleToUint64(query_pool), first_query + i); + } + } + } else { // Unavailable and in flight + // TODO : Can there be the same query in use by multiple command buffers in flight? + bool make_available = false; + for (auto cmd_buffer : qif_pair->second) { + auto cb = GetCBNode(dev_data, cmd_buffer); + make_available |= cb->queryToStateMap[query]; + } + if (!(((flags & VK_QUERY_RESULT_PARTIAL_BIT) || (flags & VK_QUERY_RESULT_WAIT_BIT)) && make_available)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", - "Cannot get query results on queryPool 0x%" PRIx64 " with index %d which is in flight.", + "Cannot get query results on queryPool 0x%" PRIx64 " with index %d which is unavailable.", HandleToUint64(query_pool), first_query + i); } } - // Unavailable and in flight - } else if (qif_pair != queries_in_flight->end() && !query_state_pair->second) { - // TODO : Can there be the same query in use by multiple command buffers in flight? - bool make_available = false; - for (auto cmd_buffer : qif_pair->second) { - auto cb = GetCBNode(dev_data, cmd_buffer); - make_available |= cb->queryToStateMap[query]; - } - if (!(((flags & VK_QUERY_RESULT_PARTIAL_BIT) || (flags & VK_QUERY_RESULT_WAIT_BIT)) && make_available)) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", - "Cannot get query results on queryPool 0x%" PRIx64 " with index %d which is unavailable.", - HandleToUint64(query_pool), first_query + i); - } - // Unavailable - } else if (!query_state_pair->second) { + } else if (!query_state_pair->second) { // Unavailable and Not in flight skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", "Cannot get query results on queryPool 0x%" PRIx64 " with index %d which is unavailable.", HandleToUint64(query_pool), first_query + i); - // Uninitialized - } else if (query_state_pair == dev_data->queryToStateMap.end()) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, - __LINE__, DRAWSTATE_INVALID_QUERY, "DS", - "Cannot get query results on queryPool 0x%" PRIx64 - " with index %d as data has not been collected for this index.", - HandleToUint64(query_pool), first_query + i); } + } else { // Uninitialized + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, + __LINE__, DRAWSTATE_INVALID_QUERY, "DS", + "Cannot get query results on queryPool 0x%" PRIx64 + " with index %d as data has not been collected for this index.", + HandleToUint64(query_pool), first_query + i); } } return skip; -- 2.7.4