Fix missing GPU events when using shaders profiling/debugging or graphics dev tools are enabled

This commit is contained in:
Wojtek Figat
2024-07-03 18:29:42 +02:00
parent b3d77ab9eb
commit b8100e9417
5 changed files with 23 additions and 11 deletions

View File

@@ -15,6 +15,7 @@ int32 ProfilerGPU::_depth = 0;
Array<GPUTimerQuery*> ProfilerGPU::_timerQueriesPool;
Array<GPUTimerQuery*> ProfilerGPU::_timerQueriesFree;
bool ProfilerGPU::Enabled = false;
bool ProfilerGPU::EventsEnabled = false;
int32 ProfilerGPU::CurrentBuffer = 0;
ProfilerGPU::EventBuffer ProfilerGPU::Buffers[PROFILER_GPU_EVENTS_FRAMES];
@@ -95,11 +96,12 @@ GPUTimerQuery* ProfilerGPU::GetTimerQuery()
int32 ProfilerGPU::BeginEvent(const Char* name)
{
#if GPU_ALLOW_PROFILE_EVENTS
if (EventsEnabled)
GPUDevice::Instance->GetMainContext()->EventBegin(name);
#endif
if (!Enabled)
return -1;
#if GPU_ALLOW_PROFILE_EVENTS
GPUDevice::Instance->GetMainContext()->EventBegin(name);
#endif
Event e;
e.Name = name;
@@ -115,6 +117,10 @@ int32 ProfilerGPU::BeginEvent(const Char* name)
void ProfilerGPU::EndEvent(int32 index)
{
#if GPU_ALLOW_PROFILE_EVENTS
if (EventsEnabled)
GPUDevice::Instance->GetMainContext()->EventEnd();
#endif
if (index == -1)
return;
_depth--;
@@ -123,10 +129,6 @@ void ProfilerGPU::EndEvent(int32 index)
auto e = buffer.Get(index);
e->Stats.Mix(RenderStatsData::Counter);
e->Timer->End();
#if GPU_ALLOW_PROFILE_EVENTS
GPUDevice::Instance->GetMainContext()->EventEnd();
#endif
}
void ProfilerGPU::BeginFrame()