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