diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp index 8c91501d7..93819cfb5 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp @@ -1349,6 +1349,24 @@ GPUDeviceVulkan::~GPUDeviceVulkan() GPUDeviceVulkan::Dispose(); } +BufferedQueryPoolVulkan* GPUDeviceVulkan::FindAvailableQueryPool(VkQueryType queryType) +{ + auto& pools = queryType == VK_QUERY_TYPE_OCCLUSION ? OcclusionQueryPools : TimestampQueryPools; + + // Try to use pool with available space inside + for (int32 i = 0; i < pools.Count(); i++) + { + auto pool = pools.Get()[i]; + if (pool->HasRoom()) + return pool; + } + + // Create new pool + const auto pool = New(this, queryType == VK_QUERY_TYPE_OCCLUSION ? 4096 : 1024, queryType); + pools.Add(pool); + return pool; +} + RenderPassVulkan* GPUDeviceVulkan::GetOrCreateRenderPass(RenderTargetLayoutVulkan& layout) { RenderPassVulkan* renderPass; @@ -2075,6 +2093,7 @@ void GPUDeviceVulkan::Dispose() HelperResources.Dispose(); StagingManager.Dispose(); TimestampQueryPools.ClearDelete(); + OcclusionQueryPools.ClearDelete(); SAFE_DELETE_GPU_RESOURCE(UniformBufferUploader); Delete(DescriptorPoolsManager); SAFE_DELETE(MainContext); diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h index 5e7fa6aa1..b593315d8 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h @@ -531,37 +531,13 @@ public: VkPhysicalDeviceFeatures PhysicalDeviceFeatures; Array TimestampQueryPools; + Array OcclusionQueryPools; #if VULKAN_RESET_QUERY_POOLS Array QueriesToReset; #endif - inline BufferedQueryPoolVulkan* FindAvailableQueryPool(Array& pools, VkQueryType queryType) - { - // Try to use pool with available space inside - for (int32 i = 0; i < pools.Count(); i++) - { - auto pool = pools.Get()[i]; - if (pool->HasRoom()) - return pool; - } - - // Create new pool - enum - { - NUM_OCCLUSION_QUERIES_PER_POOL = 4096, - NUM_TIMESTAMP_QUERIES_PER_POOL = 1024, - }; - const auto pool = New(this, queryType == VK_QUERY_TYPE_OCCLUSION ? NUM_OCCLUSION_QUERIES_PER_POOL : NUM_TIMESTAMP_QUERIES_PER_POOL, queryType); - pools.Add(pool); - return pool; - } - - inline BufferedQueryPoolVulkan* FindAvailableTimestampQueryPool() - { - return FindAvailableQueryPool(TimestampQueryPools, VK_QUERY_TYPE_TIMESTAMP); - } - + BufferedQueryPoolVulkan* FindAvailableQueryPool(VkQueryType queryType); RenderPassVulkan* GetOrCreateRenderPass(RenderTargetLayoutVulkan& layout); FramebufferVulkan* GetOrCreateFramebuffer(FramebufferVulkan::Key& key, VkExtent2D& extent, uint32 layers); PipelineLayoutVulkan* GetOrCreateLayout(DescriptorSetLayoutInfoVulkan& key); diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUTimerQueryVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUTimerQueryVulkan.cpp index 19c90b447..2dd3b07d5 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUTimerQueryVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUTimerQueryVulkan.cpp @@ -58,7 +58,7 @@ bool GPUTimerQueryVulkan::GetResult(Query& query) void GPUTimerQueryVulkan::WriteTimestamp(CmdBufferVulkan* cmdBuffer, Query& query, VkPipelineStageFlagBits stage) const { - auto pool = _device->FindAvailableTimestampQueryPool(); + auto pool = _device->FindAvailableQueryPool(VK_QUERY_TYPE_TIMESTAMP); uint32 index; if (pool->AcquireQuery(cmdBuffer, index)) {