Add support for disabling Vulkan timer queries per-platform via define
This commit is contained in:
@@ -254,11 +254,13 @@ void CmdBufferManagerVulkan::SubmitActiveCmdBuffer(SemaphoreVulkan* signalSemaph
|
||||
_activeCmdBuffer->EndRenderPass();
|
||||
}
|
||||
|
||||
#if VULKAN_USE_QUERIES
|
||||
// Pause all active queries
|
||||
for (int32 i = 0; i < _queriesInProgress.Count(); i++)
|
||||
{
|
||||
_queriesInProgress[i]->Interrupt(_activeCmdBuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
_activeCmdBuffer->End();
|
||||
|
||||
@@ -305,21 +307,27 @@ void CmdBufferManagerVulkan::PrepareForNewActiveCommandBuffer()
|
||||
_activeCmdBuffer = _pool.Create();
|
||||
_activeCmdBuffer->Begin();
|
||||
|
||||
#if VULKAN_USE_QUERIES
|
||||
// Resume any paused queries with the new command buffer
|
||||
for (int32 i = 0; i < _queriesInProgress.Count(); i++)
|
||||
{
|
||||
_queriesInProgress[i]->Resume(_activeCmdBuffer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CmdBufferManagerVulkan::OnQueryBegin(GPUTimerQueryVulkan* query)
|
||||
{
|
||||
#if VULKAN_USE_QUERIES
|
||||
_queriesInProgress.Add(query);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CmdBufferManagerVulkan::OnQueryEnd(GPUTimerQueryVulkan* query)
|
||||
{
|
||||
#if VULKAN_USE_QUERIES
|
||||
_queriesInProgress.Remove(query);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#define VULKAN_HASH_POOLS_WITH_TYPES_USAGE_ID 1
|
||||
#define VULKAN_USE_DEBUG_LAYER GPU_ENABLE_DIAGNOSTICS
|
||||
|
||||
#ifndef VULKAN_USE_QUERIES
|
||||
#define VULKAN_USE_QUERIES 1
|
||||
#endif
|
||||
#ifndef VULKAN_HAS_PHYSICAL_DEVICE_PROPERTIES2
|
||||
#define VULKAN_HAS_PHYSICAL_DEVICE_PROPERTIES2 0
|
||||
#endif
|
||||
|
||||
@@ -71,6 +71,7 @@ void GPUTimerQueryVulkan::WriteTimestamp(CmdBufferVulkan* cmdBuffer, Query& quer
|
||||
|
||||
bool GPUTimerQueryVulkan::TryGetResult()
|
||||
{
|
||||
#if VULKAN_USE_QUERIES
|
||||
// Try get queries value (if not already)
|
||||
for (int32 i = 0; i < _queries.Count(); i++)
|
||||
{
|
||||
@@ -115,13 +116,20 @@ bool GPUTimerQueryVulkan::TryGetResult()
|
||||
}
|
||||
}
|
||||
_queries.Clear();
|
||||
|
||||
#else
|
||||
_timeDelta = 0.0f;
|
||||
_hasResult = true;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GPUTimerQueryVulkan::UseQueries()
|
||||
{
|
||||
#if VULKAN_USE_QUERIES
|
||||
return _device->PhysicalDeviceLimits.timestampComputeAndGraphics == VK_TRUE;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GPUTimerQueryVulkan::OnReleaseGPU()
|
||||
@@ -149,6 +157,7 @@ void GPUTimerQueryVulkan::OnReleaseGPU()
|
||||
|
||||
void GPUTimerQueryVulkan::Begin()
|
||||
{
|
||||
#if VULKAN_USE_QUERIES
|
||||
if (UseQueries())
|
||||
{
|
||||
const auto context = (GPUContextVulkan*)_device->GetMainContext();
|
||||
@@ -165,6 +174,7 @@ void GPUTimerQueryVulkan::Begin()
|
||||
ASSERT(_queries.IsEmpty());
|
||||
_queries.Add(e);
|
||||
}
|
||||
#endif
|
||||
|
||||
_hasResult = false;
|
||||
_endCalled = false;
|
||||
@@ -175,6 +185,7 @@ void GPUTimerQueryVulkan::End()
|
||||
if (_endCalled)
|
||||
return;
|
||||
|
||||
#if VULKAN_USE_QUERIES
|
||||
if (UseQueries())
|
||||
{
|
||||
const auto context = (GPUContextVulkan*)_device->GetMainContext();
|
||||
@@ -186,8 +197,28 @@ void GPUTimerQueryVulkan::End()
|
||||
}
|
||||
context->GetCmdBufferManager()->OnQueryEnd(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
_endCalled = true;
|
||||
}
|
||||
|
||||
bool GPUTimerQueryVulkan::HasResult()
|
||||
{
|
||||
if (!_endCalled)
|
||||
return false;
|
||||
if (_hasResult)
|
||||
return true;
|
||||
|
||||
return TryGetResult();
|
||||
}
|
||||
|
||||
float GPUTimerQueryVulkan::GetResult()
|
||||
{
|
||||
if (_hasResult)
|
||||
return _timeDelta;
|
||||
|
||||
TryGetResult();
|
||||
return _timeDelta;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -68,28 +68,8 @@ public:
|
||||
// [GPUTimerQuery]
|
||||
void Begin() override;
|
||||
void End() override;
|
||||
|
||||
bool HasResult() override
|
||||
{
|
||||
if (!_endCalled)
|
||||
return false;
|
||||
if (_hasResult)
|
||||
return true;
|
||||
|
||||
return TryGetResult();
|
||||
}
|
||||
|
||||
float GetResult() override
|
||||
{
|
||||
if (_hasResult)
|
||||
{
|
||||
return _timeDelta;
|
||||
}
|
||||
|
||||
TryGetResult();
|
||||
|
||||
return _timeDelta;
|
||||
}
|
||||
bool HasResult() override;
|
||||
float GetResult() override;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Core/Common.h"
|
||||
#include "Engine/Graphics/PixelFormat.h"
|
||||
#include "Engine/Core/Collections/Array.h"
|
||||
#include "IncludeVulkanHeaders.h"
|
||||
|
||||
#if GRAPHICS_API_VULKAN
|
||||
|
||||
Reference in New Issue
Block a user