Fix missing GPU events when using shaders profiling/debugging or graphics dev tools are enabled
This commit is contained in:
@@ -188,11 +188,13 @@ bool GraphicsService::Init()
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
if (device->IsDebugToolAttached)
|
if (device->IsDebugToolAttached ||
|
||||||
|
CommandLine::Options.ShaderProfile ||
|
||||||
|
CommandLine::Options.ShaderDebug)
|
||||||
{
|
{
|
||||||
#if COMPILE_WITH_PROFILER
|
#if COMPILE_WITH_PROFILER
|
||||||
// Auto-enable GPU profiler
|
// Auto-enable GPU events
|
||||||
ProfilerGPU::Enabled = true;
|
ProfilerGPU::EventsEnabled = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (device->LoadContent())
|
if (device->LoadContent())
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ int32 ProfilerGPU::_depth = 0;
|
|||||||
Array<GPUTimerQuery*> ProfilerGPU::_timerQueriesPool;
|
Array<GPUTimerQuery*> ProfilerGPU::_timerQueriesPool;
|
||||||
Array<GPUTimerQuery*> ProfilerGPU::_timerQueriesFree;
|
Array<GPUTimerQuery*> ProfilerGPU::_timerQueriesFree;
|
||||||
bool ProfilerGPU::Enabled = false;
|
bool ProfilerGPU::Enabled = false;
|
||||||
|
bool ProfilerGPU::EventsEnabled = false;
|
||||||
int32 ProfilerGPU::CurrentBuffer = 0;
|
int32 ProfilerGPU::CurrentBuffer = 0;
|
||||||
ProfilerGPU::EventBuffer ProfilerGPU::Buffers[PROFILER_GPU_EVENTS_FRAMES];
|
ProfilerGPU::EventBuffer ProfilerGPU::Buffers[PROFILER_GPU_EVENTS_FRAMES];
|
||||||
|
|
||||||
@@ -95,11 +96,12 @@ GPUTimerQuery* ProfilerGPU::GetTimerQuery()
|
|||||||
|
|
||||||
int32 ProfilerGPU::BeginEvent(const Char* name)
|
int32 ProfilerGPU::BeginEvent(const Char* name)
|
||||||
{
|
{
|
||||||
|
#if GPU_ALLOW_PROFILE_EVENTS
|
||||||
|
if (EventsEnabled)
|
||||||
|
GPUDevice::Instance->GetMainContext()->EventBegin(name);
|
||||||
|
#endif
|
||||||
if (!Enabled)
|
if (!Enabled)
|
||||||
return -1;
|
return -1;
|
||||||
#if GPU_ALLOW_PROFILE_EVENTS
|
|
||||||
GPUDevice::Instance->GetMainContext()->EventBegin(name);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Event e;
|
Event e;
|
||||||
e.Name = name;
|
e.Name = name;
|
||||||
@@ -115,6 +117,10 @@ int32 ProfilerGPU::BeginEvent(const Char* name)
|
|||||||
|
|
||||||
void ProfilerGPU::EndEvent(int32 index)
|
void ProfilerGPU::EndEvent(int32 index)
|
||||||
{
|
{
|
||||||
|
#if GPU_ALLOW_PROFILE_EVENTS
|
||||||
|
if (EventsEnabled)
|
||||||
|
GPUDevice::Instance->GetMainContext()->EventEnd();
|
||||||
|
#endif
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
_depth--;
|
_depth--;
|
||||||
@@ -123,10 +129,6 @@ void ProfilerGPU::EndEvent(int32 index)
|
|||||||
auto e = buffer.Get(index);
|
auto e = buffer.Get(index);
|
||||||
e->Stats.Mix(RenderStatsData::Counter);
|
e->Stats.Mix(RenderStatsData::Counter);
|
||||||
e->Timer->End();
|
e->Timer->End();
|
||||||
|
|
||||||
#if GPU_ALLOW_PROFILE_EVENTS
|
|
||||||
GPUDevice::Instance->GetMainContext()->EventEnd();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfilerGPU::BeginFrame()
|
void ProfilerGPU::BeginFrame()
|
||||||
|
|||||||
@@ -134,13 +134,18 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
API_FIELD() static bool Enabled;
|
API_FIELD() static bool Enabled;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True if GPU events are enabled (see GPUContext::EventBegin), otherwise false. Cannot be changed during rendering.
|
||||||
|
/// </summary>
|
||||||
|
API_FIELD() static bool EventsEnabled;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current frame buffer to collect events.
|
/// The current frame buffer to collect events.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static int32 CurrentBuffer;
|
static int32 CurrentBuffer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The events buffers (one per frame).
|
/// The event buffers (one per frame).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static EventBuffer Buffers[PROFILER_GPU_EVENTS_FRAMES];
|
static EventBuffer Buffers[PROFILER_GPU_EVENTS_FRAMES];
|
||||||
|
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ void ProfilingTools::SetEnabled(bool enabled)
|
|||||||
{
|
{
|
||||||
ProfilerCPU::Enabled = enabled;
|
ProfilerCPU::Enabled = enabled;
|
||||||
ProfilerGPU::Enabled = enabled;
|
ProfilerGPU::Enabled = enabled;
|
||||||
|
ProfilerGPU::EventsEnabled = enabled;
|
||||||
NetworkInternal::EnableProfiling = enabled;
|
NetworkInternal::EnableProfiling = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -344,6 +344,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context)
|
|||||||
#if COMPILE_WITH_PROFILER
|
#if COMPILE_WITH_PROFILER
|
||||||
auto gpuProfilerEnabled = ProfilerGPU::Enabled;
|
auto gpuProfilerEnabled = ProfilerGPU::Enabled;
|
||||||
ProfilerGPU::Enabled = false;
|
ProfilerGPU::Enabled = false;
|
||||||
|
ProfilerGPU::EventsEnabled = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Render hemispheres
|
// Render hemispheres
|
||||||
@@ -432,6 +433,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context)
|
|||||||
}
|
}
|
||||||
#if COMPILE_WITH_PROFILER
|
#if COMPILE_WITH_PROFILER
|
||||||
ProfilerGPU::Enabled = gpuProfilerEnabled;
|
ProfilerGPU::Enabled = gpuProfilerEnabled;
|
||||||
|
ProfilerGPU::EventsEnabled = gpuProfilerEnabled;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Report progress
|
// Report progress
|
||||||
|
|||||||
Reference in New Issue
Block a user