Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::gfxprofile::GpuProfiler Class Reference

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::GraphicsManagerGetGraphicsManagerOrNull () 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 GpuProfilerGet ()
 Gets the GpuProfiler singleton instance. More...
 

Friends

class ion::profile::CallTraceTest
 

Detailed Description

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:

  • have the app framework call SetGraphicsManager and then call PollGlTimerQueries at the start of each frame.
  • place ION_PROFILE_GPU("MyGlWorkload") at the start of code scopes where GL draw commands are performed that you want to trace.
  • enable the enable_gpu_tracing_ setting via Ion Remote.
  • connect to the WTF tracing output via Ion Remote and view traces.

Definition at line 55 of file gpuprofiler.h.

Constructor & Destructor Documentation

ion::gfxprofile::GpuProfiler::GpuProfiler ( )

Definition at line 31 of file gpuprofiler.cc.

ion::gfxprofile::GpuProfiler::~GpuProfiler ( )

Definition at line 43 of file gpuprofiler.cc.

Member Function Documentation

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().

GpuProfiler * ion::gfxprofile::GpuProfiler::Get ( )
static

Gets the GpuProfiler singleton instance.

Definition at line 26 of file gpuprofiler.cc.

References ION_DECLARE_SAFE_STATIC_POINTER.

gfx::GraphicsManager* ion::gfxprofile::GpuProfiler::GetGraphicsManagerOrNull ( ) const
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::SetEnableGpuTracing ( bool  enabled)
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().

Friends And Related Function Documentation

friend class ion::profile::CallTraceTest
friend

Definition at line 156 of file gpuprofiler.h.


The documentation for this class was generated from the following files: