VTK  9.1.0
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
vtkOpenGLRenderTimer Class Reference

Asynchronously measures GPU execution time for a single event. More...

#include <vtkOpenGLRenderTimer.h>

Public Member Functions

 vtkOpenGLRenderTimer ()
 
 ~vtkOpenGLRenderTimer ()
 
void Reset ()
 Clear out any previous results and prepare for a new query.
 
void Start ()
 Mark the start of a timed event.
 
void Stop ()
 Mark the end of a timed event.
 
bool Started ()
 Returns true if the timer has been started.
 
bool Stopped ()
 Returns true if the timer has been stopped.
 
bool Ready ()
 Returns true when the timing results are available.
 
void ReleaseGraphicsResources ()
 Simply calls Reset() to ensure that query ids are freed.
 
float GetElapsedSeconds ()
 If Ready() returns true, get the elapsed time in the requested units.
 
float GetElapsedMilliseconds ()
 If Ready() returns true, get the elapsed time in the requested units.
 
vtkTypeUInt64 GetElapsedNanoseconds ()
 If Ready() returns true, get the elapsed time in the requested units.
 
void ReusableStart ()
 This class can also be used in a reusable manner where the start and stop events stay in flight until they are both completed.
 
void ReusableStop ()
 This class can also be used in a reusable manner where the start and stop events stay in flight until they are both completed.
 
float GetReusableElapsedSeconds ()
 This class can also be used in a reusable manner where the start and stop events stay in flight until they are both completed.
 
vtkTypeUInt64 GetStartTime ()
 If Ready() returns true, return the start or stop time in nanoseconds.
 
vtkTypeUInt64 GetStopTime ()
 If Ready() returns true, return the start or stop time in nanoseconds.
 

Static Public Member Functions

static bool IsSupported ()
 Returns true if timer events are supported by the current OpenGL implementation.
 

Protected Attributes

bool StartReady
 
bool EndReady
 
vtkTypeUInt32 StartQuery
 
vtkTypeUInt32 EndQuery
 
vtkTypeUInt64 StartTime
 
vtkTypeUInt64 EndTime
 
bool ReusableStarted
 
bool ReusableEnded
 

Detailed Description

Asynchronously measures GPU execution time for a single event.

This class posts events to the OpenGL server to measure execution times of GPU processes. The queries are asynchronous and multiple vtkOpenGLRenderTimers may overlap / be nested.

This uses GL_TIMESTAMP rather than GL_ELAPSED_TIME, since only one GL_ELAPSED_TIME query may be active at a time. Since GL_TIMESTAMP is not available on OpenGL ES, timings will not be available on those platforms. Use the static IsSupported() method to determine if the timer is available.

Definition at line 37 of file vtkOpenGLRenderTimer.h.

Constructor & Destructor Documentation

◆ vtkOpenGLRenderTimer()

vtkOpenGLRenderTimer::vtkOpenGLRenderTimer ( )

◆ ~vtkOpenGLRenderTimer()

vtkOpenGLRenderTimer::~vtkOpenGLRenderTimer ( )

Member Function Documentation

◆ IsSupported()

static bool vtkOpenGLRenderTimer::IsSupported ( )
static

Returns true if timer events are supported by the current OpenGL implementation.

◆ Reset()

void vtkOpenGLRenderTimer::Reset ( )

Clear out any previous results and prepare for a new query.

◆ Start()

void vtkOpenGLRenderTimer::Start ( )

Mark the start of a timed event.

◆ Stop()

void vtkOpenGLRenderTimer::Stop ( )

Mark the end of a timed event.

◆ Started()

bool vtkOpenGLRenderTimer::Started ( )

Returns true if the timer has been started.

The query may not be ready yet.

◆ Stopped()

bool vtkOpenGLRenderTimer::Stopped ( )

Returns true if the timer has been stopped.

The query may not be ready yet.

◆ Ready()

bool vtkOpenGLRenderTimer::Ready ( )

Returns true when the timing results are available.

◆ GetElapsedSeconds()

float vtkOpenGLRenderTimer::GetElapsedSeconds ( )

If Ready() returns true, get the elapsed time in the requested units.

◆ GetElapsedMilliseconds()

float vtkOpenGLRenderTimer::GetElapsedMilliseconds ( )

If Ready() returns true, get the elapsed time in the requested units.

◆ GetElapsedNanoseconds()

vtkTypeUInt64 vtkOpenGLRenderTimer::GetElapsedNanoseconds ( )

If Ready() returns true, get the elapsed time in the requested units.

◆ ReusableStart()

void vtkOpenGLRenderTimer::ReusableStart ( )

This class can also be used in a reusable manner where the start and stop events stay in flight until they are both completed.

Calling ReusableStart while they are in flight is ignored. The Elapsed time is always the result from the most recently completed flight. Typical usage is

render loop timer->ReusableStart(); // do some rendering timer->ReusableStop(); time = timer->GetReusableElapsedSeconds();

the elapsed seconds will return zero until a flight has completed.

The idea being that with OpenGL render commands are asynchronous. You might render multiple times before the first render on the GPU is completed. These reusable methods provide a method for provinding a constant measure of the time required for a command with the efficiency of only having one timing in process/flight at a time. Making this a lightweight timer in terms of OpenGL API calls.

These reusable methods are not meant to be mixed with other methods in this class.

◆ ReusableStop()

void vtkOpenGLRenderTimer::ReusableStop ( )

This class can also be used in a reusable manner where the start and stop events stay in flight until they are both completed.

Calling ReusableStart while they are in flight is ignored. The Elapsed time is always the result from the most recently completed flight. Typical usage is

render loop timer->ReusableStart(); // do some rendering timer->ReusableStop(); time = timer->GetReusableElapsedSeconds();

the elapsed seconds will return zero until a flight has completed.

The idea being that with OpenGL render commands are asynchronous. You might render multiple times before the first render on the GPU is completed. These reusable methods provide a method for provinding a constant measure of the time required for a command with the efficiency of only having one timing in process/flight at a time. Making this a lightweight timer in terms of OpenGL API calls.

These reusable methods are not meant to be mixed with other methods in this class.

◆ GetReusableElapsedSeconds()

float vtkOpenGLRenderTimer::GetReusableElapsedSeconds ( )

This class can also be used in a reusable manner where the start and stop events stay in flight until they are both completed.

Calling ReusableStart while they are in flight is ignored. The Elapsed time is always the result from the most recently completed flight. Typical usage is

render loop timer->ReusableStart(); // do some rendering timer->ReusableStop(); time = timer->GetReusableElapsedSeconds();

the elapsed seconds will return zero until a flight has completed.

The idea being that with OpenGL render commands are asynchronous. You might render multiple times before the first render on the GPU is completed. These reusable methods provide a method for provinding a constant measure of the time required for a command with the efficiency of only having one timing in process/flight at a time. Making this a lightweight timer in terms of OpenGL API calls.

These reusable methods are not meant to be mixed with other methods in this class.

◆ GetStartTime()

vtkTypeUInt64 vtkOpenGLRenderTimer::GetStartTime ( )

If Ready() returns true, return the start or stop time in nanoseconds.

◆ GetStopTime()

vtkTypeUInt64 vtkOpenGLRenderTimer::GetStopTime ( )

If Ready() returns true, return the start or stop time in nanoseconds.

◆ ReleaseGraphicsResources()

void vtkOpenGLRenderTimer::ReleaseGraphicsResources ( )

Simply calls Reset() to ensure that query ids are freed.

All stored timing information will be lost.

Member Data Documentation

◆ StartReady

bool vtkOpenGLRenderTimer::StartReady
protected

Definition at line 134 of file vtkOpenGLRenderTimer.h.

◆ EndReady

bool vtkOpenGLRenderTimer::EndReady
protected

Definition at line 135 of file vtkOpenGLRenderTimer.h.

◆ StartQuery

vtkTypeUInt32 vtkOpenGLRenderTimer::StartQuery
protected

Definition at line 137 of file vtkOpenGLRenderTimer.h.

◆ EndQuery

vtkTypeUInt32 vtkOpenGLRenderTimer::EndQuery
protected

Definition at line 138 of file vtkOpenGLRenderTimer.h.

◆ StartTime

vtkTypeUInt64 vtkOpenGLRenderTimer::StartTime
protected

Definition at line 140 of file vtkOpenGLRenderTimer.h.

◆ EndTime

vtkTypeUInt64 vtkOpenGLRenderTimer::EndTime
protected

Definition at line 141 of file vtkOpenGLRenderTimer.h.

◆ ReusableStarted

bool vtkOpenGLRenderTimer::ReusableStarted
protected

Definition at line 143 of file vtkOpenGLRenderTimer.h.

◆ ReusableEnded

bool vtkOpenGLRenderTimer::ReusableEnded
protected

Definition at line 144 of file vtkOpenGLRenderTimer.h.


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