Ion
|
Singleton class that augments CallTraceManager with GPU tracing support. More...
#include "gpuprofiler.h"
Public Member Functions | |
GpuProfiler () | |
~GpuProfiler () | |
bool | IsGpuProfilingSupported (const ion::gfx::GraphicsManagerPtr &gfx_mgr) const |
void | SetGraphicsManager (const gfx::GraphicsManagerPtr &gfx_mgr) |
Sets the GraphicsManager that is required for performing GPU tracing via OpenGL. More... | |
void | SetEnableGpuTracing (bool enabled) |
Enables runtime GPU tracing. More... | |
gfx::GraphicsManager * | GetGraphicsManagerOrNull () const |
Gets the GraphicsManager if GPU tracing is enabled. More... | |
void | PollGlTimerQueries () |
Polls (non-blocking) for completed GL timer query data and adds events into the trace buffer. More... | |
void | EnterGlScope (uint32 id) |
Records the beginning of a scoped GL trace event. More... | |
void | LeaveGlScope () |
Records the end of a scoped GL trace event. More... | |
Static Public Member Functions | |
static GpuProfiler * | Get () |
Gets the GpuProfiler singleton instance. More... | |
Friends | |
class | ion::profile::CallTraceTest |
Singleton class that augments CallTraceManager with GPU tracing support.
See calltracemanager_test.cc for tests.
While enabled, GL commands will be submitted each frame to query timestamps of GPU workloads that have been traced using the ION_PROFILE_GPU macro defined below.
Basic workflow:
Definition at line 55 of file gpuprofiler.h.
ion::gfxprofile::GpuProfiler::GpuProfiler | ( | ) |
Definition at line 31 of file gpuprofiler.cc.
ion::gfxprofile::GpuProfiler::~GpuProfiler | ( | ) |
Definition at line 43 of file gpuprofiler.cc.
void ion::gfxprofile::GpuProfiler::EnterGlScope | ( | uint32 | id | ) |
Records the beginning of a scoped GL trace event.
Definition at line 88 of file gpuprofiler.cc.
References GetGraphicsManagerOrNull(), ion::profile::CallTraceManager::GetTimeInNs(), GL_TIMESTAMP_EXT, and id.
Referenced by ion::gfxprofile::ScopedGlTracer::ScopedGlTracer().
|
static |
Gets the GpuProfiler singleton instance.
Definition at line 26 of file gpuprofiler.cc.
References ION_DECLARE_SAFE_STATIC_POINTER.
|
inline |
Gets the GraphicsManager if GPU tracing is enabled.
NULL is returned if GPU tracing is not enabled.
Definition at line 80 of file gpuprofiler.h.
References ion::base::SharedPtr< T >::Get().
Referenced by EnterGlScope(), LeaveGlScope(), and PollGlTimerQueries().
bool ion::gfxprofile::GpuProfiler::IsGpuProfilingSupported | ( | const ion::gfx::GraphicsManagerPtr & | gfx_mgr | ) | const |
Definition at line 45 of file gpuprofiler.cc.
References GL_QUERY_COUNTER_BITS_EXT, and GL_TIMESTAMP_EXT.
Referenced by SetGraphicsManager().
void ion::gfxprofile::GpuProfiler::LeaveGlScope | ( | ) |
Records the end of a scoped GL trace event.
Definition at line 103 of file gpuprofiler.cc.
References GetGraphicsManagerOrNull(), ion::profile::CallTraceManager::GetTimeInNs(), and GL_TIMESTAMP_EXT.
Referenced by ion::gfxprofile::ScopedGlTracer::~ScopedGlTracer().
void ion::gfxprofile::GpuProfiler::PollGlTimerQueries | ( | ) |
Polls (non-blocking) for completed GL timer query data and adds events into the trace buffer.
Must call once close to the start of each frame.
Definition at line 156 of file gpuprofiler.cc.
References ion::profile::TraceRecorder::EnterScopeAtTime(), GetGraphicsManagerOrNull(), ion::profile::CallTraceManager::GetNamedTraceRecorder(), ion::gfx::GraphicsManager::GetQueryObjectiv, ion::profile::CallTraceManager::GetTimeInNs(), GL_GPU_DISJOINT_EXT, GL_QUERY_RESULT_AVAILABLE_EXT, GL_QUERY_RESULT_EXT, GL_TIMESTAMP_EXT, ion::profile::CallTraceManager::kRecorderGpu, ion::profile::TraceRecorder::LeaveScopeAtTime(), LOG, and ion::port::WARNING.
|
inline |
Enables runtime GPU tracing.
While enabled, GL commands will be submitted each frame to query timestamps of GPU workloads that have been traced using the ION_PROFILE_GPU macro defined below. Note that this has no effect if GPU tracing is not supported or if SetGraphicsManager was not called.
Definition at line 74 of file gpuprofiler.h.
void ion::gfxprofile::GpuProfiler::SetGraphicsManager | ( | const gfx::GraphicsManagerPtr & | gfx_mgr | ) |
Sets the GraphicsManager that is required for performing GPU tracing via OpenGL.
Definition at line 60 of file gpuprofiler.cc.
References IsGpuProfilingSupported().
|
friend |
Definition at line 156 of file gpuprofiler.h.