Magnum::DebugTools::GLFrameProfiler class new in Git master

OpenGL frame profiler.

A FrameProfiler with OpenGL-specific measurements. Instantiate with a desired subset of measured values and then continue the same way as described in the FrameProfiler usage documentation:

DebugTools::GLFrameProfiler profiler{
    DebugTools::GLFrameProfiler::Value::FrameTime|
    DebugTools::GLFrameProfiler::Value::GpuDuration, 50};

If none if Value::GpuDuration, Value::VertexFetchRatio and Value::PrimitiveClipRatio is not enabled, the class can operate without an active OpenGL context.

Base classes

class FrameProfiler new in Git master
Frame profiler.

Public types

enum class Value: UnsignedShort { FrameTime = 1 << 0, CpuDuration = 1 << 1, GpuDuration = 1 << 2, VertexFetchRatio = 1 << 3, PrimitiveClipRatio = 1 << 4 }
Measured value.
using Values = Containers::EnumSet<Value>
Measured values.

Constructors, destructors, conversion operators

GLFrameProfiler() explicit
Default constructor.
GLFrameProfiler(Values values, UnsignedInt maxFrameCount) explicit
Constructor.
GLFrameProfiler(const GLFrameProfiler&) deleted
Copying is not allowed.
GLFrameProfiler(GLFrameProfiler&&) noexcept
Move constructor.

Public functions

auto operator=(const GLFrameProfiler&) -> GLFrameProfiler& deleted
Copying is not allowed.
auto operator=(GLFrameProfiler&&) -> GLFrameProfiler& noexcept
Move assignment.
void setup(Values values, UnsignedInt maxFrameCount)
Setup measured values.
auto values() const -> Values
Measured values.
auto isMeasurementAvailable(Value value) const -> bool
Whether given measurement is available.
auto frameTimeMean() const -> Double
Mean frame time in nanoseconds.
auto cpuDurationMean() const -> Double
Mean CPU frame duration in nanoseconds.
auto gpuDurationMean() const -> Double
Mean GPU frame duration in nanoseconds.
auto vertexFetchRatioMean() const -> Double
Mean vertex fetch ratio in thousandths.
auto primitiveClipRatioMean() const -> Double
Mean primitive clip ratio in percentage thousandths.
auto isMeasurementAvailable(UnsignedInt id) const -> bool
Whether given measurement is available.

Enum documentation

enum class Magnum::DebugTools::GLFrameProfiler::Value: UnsignedShort

Measured value.

Enumerators
FrameTime

Measure total frame time (i.e., time between consecutive beginFrame() calls). Reported in Units::Nanoseconds with a delay of 2 frames. When converted to seconds, the value is an inverse of FPS.

CpuDuration

Measure CPU frame duration (i.e., CPU time spent between beginFrame() and endFrame()). Reported in Units::Nanoseconds with a delay of 1 frame.

GpuDuration

Measure GPU frame duration (i.e., time between beginFrame() and endFrame()). Reported in Units::Nanoseconds with a delay of 3 frames. This value requires an active OpenGL context.

VertexFetchRatio

Ratio of vertex shader invocations to count of vertices submitted. For a non-indexed draw the ratio will be 1, for indexed draws ratio is less than 1. The lower the value is, the better a mesh is optimized for post-transform vertex cache. Reported in Units::RatioThousandths with a delay of 3 frames. This value requires an active OpenGL context.

PrimitiveClipRatio

Ratio of primitives discarded by the clipping stage to count of primitives submitted. The ratio is 0 when all primitives pass the clipping stage and 1 when all are discarded. Can be used to measure efficiency of a frustum culling algorithm. Reported in Units::PercentageThousandths with a delay of 3 frames. This value requires an active OpenGL context.

Typedef documentation

typedef Containers::EnumSet<Value> Magnum::DebugTools::GLFrameProfiler::Values

Measured values.

Function documentation

Magnum::DebugTools::GLFrameProfiler::GLFrameProfiler() explicit

Default constructor.

Call setup() to populate the profiler with measurements.

Magnum::DebugTools::GLFrameProfiler::GLFrameProfiler(Values values, UnsignedInt maxFrameCount) explicit

Constructor.

Equivalent to default-constructing an instance and calling setup() afterwards.

void Magnum::DebugTools::GLFrameProfiler::setup(Values values, UnsignedInt maxFrameCount)

Setup measured values.

Parameters
values List of measuremed values
maxFrameCount Max frame count over which to calculate a moving average. Expected to be at least 1.

Calling setup() on an already set up profiler will replace existing measurements with measurements and reset measuredFrameCount() back to 0.

Values Magnum::DebugTools::GLFrameProfiler::values() const

Measured values.

Corresponds to the values parameter passed to GLFrameProfiler(Values, UnsignedInt) or setup().

bool Magnum::DebugTools::GLFrameProfiler::isMeasurementAvailable(Value value) const

Whether given measurement is available.

Returns true if enough frames was captured to calculate given value, false otherwise. Expects that value was enabled.

Double Magnum::DebugTools::GLFrameProfiler::frameTimeMean() const

Mean frame time in nanoseconds.

Expects that Value::FrameTime was enabled, and that measurement data is available. See the flag documentation for more information.

Double Magnum::DebugTools::GLFrameProfiler::cpuDurationMean() const

Mean CPU frame duration in nanoseconds.

Expects that Value::CpuDuration was enabled, and that measurement data is available. See the flag documentation for more information.

Double Magnum::DebugTools::GLFrameProfiler::gpuDurationMean() const

Mean GPU frame duration in nanoseconds.

Expects that Value::GpuDuration was enabled, and that measurement data is available. See the flag documentation for more information.

Double Magnum::DebugTools::GLFrameProfiler::vertexFetchRatioMean() const

Mean vertex fetch ratio in thousandths.

Expects that Value::VertexFetchRatio was enabled, and that measurement data is available. See the flag documentation for more information.

Double Magnum::DebugTools::GLFrameProfiler::primitiveClipRatioMean() const

Mean primitive clip ratio in percentage thousandths.

Expects that Value::PrimitiveClipRatio was enabled, and that measurement data is available. See the flag documentation for more information.

bool Magnum::DebugTools::GLFrameProfiler::isMeasurementAvailable(UnsignedInt id) const

Whether given measurement is available.

Returns true if measuredFrameCount() is at least measurementDelay() for given id, false otherwise. The id corresponds to the index of the measurement in the list passed to setup(). Expects that id is less than measurementCount().