summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-13 02:21:37 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-13 02:21:37 +0000
commit23e8bdd5556a684787c03b1e3b339ec8a2a329d6 (patch)
treef553c7845001e0de675e69c0d23f73fbbbe958e4 /Graphics/GraphicsEngineVulkan
parentMade ICommandQueue{D3D12/Vk}::GetNextFenceValue method constant (diff)
downloadDiligentCore-23e8bdd5556a684787c03b1e3b339ec8a2a329d6.tar.gz
DiligentCore-23e8bdd5556a684787c03b1e3b339ec8a2a329d6.zip
Vk query manager: improved query reuse order
Added Vk and D3D12 query usage reporting
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/QueryManagerVk.h8
-rw-r--r--Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp22
2 files changed, 21 insertions, 9 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/QueryManagerVk.h b/Graphics/GraphicsEngineVulkan/include/QueryManagerVk.h
index 9472c132..a435527d 100644
--- a/Graphics/GraphicsEngineVulkan/include/QueryManagerVk.h
+++ b/Graphics/GraphicsEngineVulkan/include/QueryManagerVk.h
@@ -79,9 +79,11 @@ private:
{
VulkanUtilities::QueryPoolWrapper vkQueryPool;
- std::deque<Uint32> AvailableQueries;
- std::deque<Uint32> StaleQueries;
- Uint32 PoolSize = 0;
+ std::deque<Uint32> AvailableQueries;
+ std::vector<Uint32> StaleQueries;
+
+ Uint32 PoolSize = 0;
+ Uint32 MaxAllocatedQueries = 0;
};
std::mutex m_HeapMutex;
diff --git a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp
index 0756420c..30aafc88 100644
--- a/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/QueryManagerVk.cpp
@@ -26,6 +26,7 @@
*/
#include "pch.h"
+#include <algorithm>
#include "QueryManagerVk.h"
#include "RenderDeviceVkImpl.h"
#include "GraphicsAccessories.h"
@@ -133,6 +134,8 @@ QueryManagerVk::QueryManagerVk(RenderDeviceVkImpl* pRenderDeviceVk,
QueryManagerVk::~QueryManagerVk()
{
+ std::stringstream QueryUsageSS;
+ QueryUsageSS << "Vulkan query manager peak usage:";
for (Uint32 QueryType = QUERY_TYPE_UNDEFINED + 1; QueryType < QUERY_TYPE_NUM_TYPES; ++QueryType)
{
auto& HeapInfo = m_Heaps[QueryType];
@@ -152,19 +155,26 @@ QueryManagerVk::~QueryManagerVk()
" have not been returned to the query manager");
}
}
+ QueryUsageSS << std::endl
+ << std::setw(30) << std::left << GetQueryTypeString(static_cast<QUERY_TYPE>(QueryType)) << ": "
+ << std::setw(4) << std::right << HeapInfo.MaxAllocatedQueries
+ << '/' << std::setw(4) << HeapInfo.PoolSize;
}
+ LOG_INFO_MESSAGE(QueryUsageSS.str());
}
Uint32 QueryManagerVk::AllocateQuery(QUERY_TYPE Type)
{
std::lock_guard<std::mutex> Lock(m_HeapMutex);
- Uint32 Index = InvalidIndex;
- auto& HeapInfo = m_Heaps[Type];
- if (!HeapInfo.AvailableQueries.empty())
+ Uint32 Index = InvalidIndex;
+ auto& HeapInfo = m_Heaps[Type];
+ auto& AvailableQueries = HeapInfo.AvailableQueries;
+ if (!AvailableQueries.empty())
{
- Index = HeapInfo.AvailableQueries.front();
- HeapInfo.AvailableQueries.pop_front();
+ Index = HeapInfo.AvailableQueries.back();
+ AvailableQueries.pop_back();
+ HeapInfo.MaxAllocatedQueries = std::max(HeapInfo.MaxAllocatedQueries, HeapInfo.PoolSize - static_cast<Uint32>(AvailableQueries.size()));
}
return Index;
@@ -199,7 +209,7 @@ Uint32 QueryManagerVk::ResetStaleQueries(VulkanUtilities::VulkanCommandBuffer& C
for (auto& StaleQuery : HeapInfo.StaleQueries)
{
CmdBuff.ResetQueryPool(HeapInfo.vkQueryPool, StaleQuery, 1);
- HeapInfo.AvailableQueries.push_back(StaleQuery);
+ HeapInfo.AvailableQueries.push_front(StaleQuery);
++NumQueriesReset;
}
HeapInfo.StaleQueries.clear();