Add OcclusionQueryPools to Vulkan and move code to cpp file
This commit is contained in:
@@ -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<BufferedQueryPoolVulkan>(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);
|
||||
|
||||
@@ -531,37 +531,13 @@ public:
|
||||
VkPhysicalDeviceFeatures PhysicalDeviceFeatures;
|
||||
|
||||
Array<BufferedQueryPoolVulkan*> TimestampQueryPools;
|
||||
Array<BufferedQueryPoolVulkan*> OcclusionQueryPools;
|
||||
|
||||
#if VULKAN_RESET_QUERY_POOLS
|
||||
Array<QueryPoolVulkan*> QueriesToReset;
|
||||
#endif
|
||||
|
||||
inline BufferedQueryPoolVulkan* FindAvailableQueryPool(Array<BufferedQueryPoolVulkan*>& 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<BufferedQueryPoolVulkan>(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);
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user