18 #ifndef ION_GFXPROFILE_GPUPROFILER_H_
19 #define ION_GFXPROFILE_GPUPROFILER_H_
28 #include "base/integral_types.h"
39 namespace gfxprofile {
75 enable_gpu_tracing_ = enabled;
81 if (enable_gpu_tracing_) {
82 return graphics_manager_.
Get();
101 struct GpuTimerQuery {
109 GpuTimerQuery(
uint64 timestamp_ns,
113 : cpu_timestamp_ns(timestamp_ns),
114 scope_event_id(scope_id),
115 gl_query_id(query_id),
121 QueryType query_type;
129 void SyncGlTimebase();
132 GLuint TryAllocateGlQueryId();
138 base::Setting<bool> enable_gpu_tracing_;
141 int64 gl_timer_offset_ns_;
149 std::deque<GpuTimerQuery> pending_gpu_queries_;
154 std::stack<GLuint, std::vector<GLuint> > gl_timer_query_id_pool_;
179 #define ION_PROFILE_GPU(group_name)
181 #define ION_PROFILE_GPU(group_name) \
185 (void) group_name " must be a literal string."; \
186 ION_PROFILE_FUNCTION(group_name); \
187 ION_DECLARE_SAFE_STATIC_POINTER_WITH_CONSTRUCTOR( \
188 int, ION_PROFILING_PASTE3(gpu_scope_event_id_), \
189 new int(::ion::profile::GetCallTraceManager()-> \
190 GetScopeEnterEvent("GPU_" group_name))); \
191 ::ion::gfxprofile::ScopedGlTracer ION_PROFILING_PASTE3(gpu_scope_tracer_)( \
192 ::ion::gfxprofile::GpuProfiler::Get(), \
193 *ION_PROFILING_PASTE3(gpu_scope_event_id_))
194 #endif // ION_PRODUCTION
196 #endif // ION_GFXPROFILE_GPUPROFILER_H_
GraphicsManager manages the graphics library for an application.
Traces the GPU start and end times of the GL commands submitted in the same scope.
bool IsGpuProfilingSupported(const ion::gfx::GraphicsManagerPtr &gfx_mgr) const
friend class ion::profile::CallTraceTest
void EnterGlScope(uint32 id)
Records the beginning of a scoped GL trace event.
static GpuProfiler * Get()
Gets the GpuProfiler singleton instance.
T * Get() const
Returns a raw pointer to the instance, which may be NULL.
void SetGraphicsManager(const gfx::GraphicsManagerPtr &gfx_mgr)
Sets the GraphicsManager that is required for performing GPU tracing via OpenGL.
ScopedGlTracer(GpuProfiler *profiler, int id)
Singleton class that augments CallTraceManager with GPU tracing support.
base::ReferentPtr< GraphicsManager >::Type GraphicsManagerPtr
Convenience typedef for shared pointer to a GraphicsManager.
Manages call trace recording for visualization in Web Tracing Framework (WTF) format.
void SetEnableGpuTracing(bool enabled)
Enables runtime GPU tracing.
gfx::GraphicsManager * GetGraphicsManagerOrNull() const
Gets the GraphicsManager if GPU tracing is enabled.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
void LeaveGlScope()
Records the end of a scoped GL trace event.
void PollGlTimerQueries()
Polls (non-blocking) for completed GL timer query data and adds events into the trace buffer...