Browse Source

DebugTools: rename GLFrameProfiler to FrameProfilerGL.

This makes more sense regarding autocompletion and grouping of common
things together when sorted alphabetically. Sorry it didn't occur
sooner to me.
pull/518/head
Vladimír Vondruš 5 years ago
parent
commit
a90e67edaa
  1. 4
      doc/changelog.dox
  2. 10
      doc/snippets/MagnumDebugTools-gl.cpp
  3. 12
      doc/snippets/debugtools-frameprofiler.cpp
  4. 5
      src/Magnum/DebugTools/DebugTools.h
  5. 94
      src/Magnum/DebugTools/FrameProfiler.cpp
  6. 65
      src/Magnum/DebugTools/FrameProfiler.h
  7. 50
      src/Magnum/DebugTools/Test/FrameProfilerGLTest.cpp
  8. 68
      src/Magnum/DebugTools/Test/FrameProfilerTest.cpp

4
doc/changelog.dox

@ -437,6 +437,10 @@ See also:
the canvas and status elements from the JS `Module`. See
@ref platforms-html5-apps and [mosra/magnum#481](https://github.com/mosra/magnum/pull/481)
for details.
- @cpp DebugTools::GLFrameProfiler @ce is deprecated in favor of
@ref DebugTools::FrameProfilerGL. The new name plays better with IDE
autocompletion and makes the GL-specific class appear next to the
API-independent base in alphabetically sorted lists.
- @ref Shaders::Phong::setLightPositions() and
@ref Shaders::Phong::setLightPosition() taking three-component vectors are
deprecated in favor of variants taking four-component vectors, where the

10
doc/snippets/MagnumDebugTools-gl.cpp

@ -149,11 +149,11 @@ new DebugTools::ObjectRenderer3D{manager, *object, "my", &debugDrawables};
}
{
/* [GLFrameProfiler-usage] */
DebugTools::GLFrameProfiler profiler{
DebugTools::GLFrameProfiler::Value::FrameTime|
DebugTools::GLFrameProfiler::Value::GpuDuration, 50};
/* [GLFrameProfiler-usage] */
/* [FrameProfilerGL-usage] */
DebugTools::FrameProfilerGL profiler{
DebugTools::FrameProfilerGL::Value::FrameTime|
DebugTools::FrameProfilerGL::Value::GpuDuration, 50};
/* [FrameProfilerGL-usage] */
}
{

12
doc/snippets/debugtools-frameprofiler.cpp

@ -43,12 +43,12 @@ class FrameProfiler: public Platform::WindowlessApplication {
FrameProfiler::FrameProfiler(const Arguments& arguments): Platform::WindowlessApplication{arguments} {
/* Enable everything in the GL profiler and then introspect it to fake
its output 1:1 */
DebugTools::GLFrameProfiler glProfiler{
DebugTools::GLFrameProfiler::Value::FrameTime|
DebugTools::GLFrameProfiler::Value::CpuDuration|
DebugTools::GLFrameProfiler::Value::GpuDuration|
DebugTools::GLFrameProfiler::Value::VertexFetchRatio|
DebugTools::GLFrameProfiler::Value::PrimitiveClipRatio
DebugTools::FrameProfilerGL glProfiler{
DebugTools::FrameProfilerGL::Value::FrameTime|
DebugTools::FrameProfilerGL::Value::CpuDuration|
DebugTools::FrameProfilerGL::Value::GpuDuration|
DebugTools::FrameProfilerGL::Value::VertexFetchRatio|
DebugTools::FrameProfilerGL::Value::PrimitiveClipRatio
, 50};
DebugTools::FrameProfiler profiler{{

5
src/Magnum/DebugTools/DebugTools.h

@ -44,7 +44,10 @@ class CORRADE_DEPRECATED("use FrameProfiler instead") Profiler;
class FrameProfiler;
#ifdef MAGNUM_TARGET_GL
class GLFrameProfiler;
class FrameProfilerGL;
#ifdef MAGNUM_BUILD_DEPRECATED
typedef CORRADE_DEPRECATED("use FrameProfilerGL instead") FrameProfilerGL GLFrameProfiler;
#endif
template<UnsignedInt> class ForceRenderer;
typedef ForceRenderer<2> ForceRenderer2D;

94
src/Magnum/DebugTools/FrameProfiler.cpp

@ -429,7 +429,7 @@ Debug& operator<<(Debug& debug, const FrameProfiler::Units value) {
}
#ifdef MAGNUM_TARGET_GL
struct GLFrameProfiler::State {
struct FrameProfilerGL::State {
UnsignedShort cpuDurationIndex = 0xffff,
gpuDurationIndex = 0xffff,
frameTimeIndex = 0xffff;
@ -448,20 +448,20 @@ struct GLFrameProfiler::State {
#endif
};
GLFrameProfiler::GLFrameProfiler(): _state{InPlaceInit} {}
FrameProfilerGL::FrameProfilerGL(): _state{InPlaceInit} {}
GLFrameProfiler::GLFrameProfiler(const Values values, const UnsignedInt maxFrameCount): GLFrameProfiler{}
FrameProfilerGL::FrameProfilerGL(const Values values, const UnsignedInt maxFrameCount): FrameProfilerGL{}
{
setup(values, maxFrameCount);
}
GLFrameProfiler::GLFrameProfiler(GLFrameProfiler&&) noexcept = default;
FrameProfilerGL::FrameProfilerGL(FrameProfilerGL&&) noexcept = default;
GLFrameProfiler& GLFrameProfiler::operator=(GLFrameProfiler&&) noexcept = default;
FrameProfilerGL& FrameProfilerGL::operator=(FrameProfilerGL&&) noexcept = default;
GLFrameProfiler::~GLFrameProfiler() = default;
FrameProfilerGL::~FrameProfilerGL() = default;
void GLFrameProfiler::setup(const Values values, const UnsignedInt maxFrameCount) {
void FrameProfilerGL::setup(const Values values, const UnsignedInt maxFrameCount) {
UnsignedShort index = 0;
Containers::Array<Measurement> measurements;
if(values & Value::FrameTime) {
@ -565,7 +565,7 @@ void GLFrameProfiler::setup(const Values values, const UnsignedInt maxFrameCount
setup(std::move(measurements), maxFrameCount);
}
auto GLFrameProfiler::values() const -> Values {
auto FrameProfilerGL::values() const -> Values {
Values values;
if(_state->frameTimeIndex != 0xffff) values |= Value::FrameTime;
if(_state->cpuDurationIndex != 0xffff) values |= Value::CpuDuration;
@ -577,7 +577,7 @@ auto GLFrameProfiler::values() const -> Values {
return values;
}
bool GLFrameProfiler::isMeasurementAvailable(const Value value) const {
bool FrameProfilerGL::isMeasurementAvailable(const Value value) const {
const UnsignedShort* index = nullptr;
switch(value) {
case Value::FrameTime: index = &_state->frameTimeIndex; break;
@ -590,45 +590,45 @@ bool GLFrameProfiler::isMeasurementAvailable(const Value value) const {
}
CORRADE_INTERNAL_ASSERT(index);
CORRADE_ASSERT(*index < measurementCount(),
"DebugTools::GLFrameProfiler::isMeasurementAvailable():" << value << "not enabled", {});
"DebugTools::FrameProfilerGL::isMeasurementAvailable():" << value << "not enabled", {});
return isMeasurementAvailable(*index);
}
Double GLFrameProfiler::frameTimeMean() const {
Double FrameProfilerGL::frameTimeMean() const {
CORRADE_ASSERT(_state->frameTimeIndex < measurementCount(),
"DebugTools::GLFrameProfiler::frameTimeMean(): not enabled", {});
"DebugTools::FrameProfilerGL::frameTimeMean(): not enabled", {});
return measurementMean(_state->frameTimeIndex);
}
Double GLFrameProfiler::cpuDurationMean() const {
Double FrameProfilerGL::cpuDurationMean() const {
CORRADE_ASSERT(_state->cpuDurationIndex < measurementCount(),
"DebugTools::GLFrameProfiler::cpuDurationMean(): not enabled", {});
"DebugTools::FrameProfilerGL::cpuDurationMean(): not enabled", {});
return measurementMean(_state->cpuDurationIndex);
}
Double GLFrameProfiler::gpuDurationMean() const {
Double FrameProfilerGL::gpuDurationMean() const {
CORRADE_ASSERT(_state->gpuDurationIndex < measurementCount(),
"DebugTools::GLFrameProfiler::gpuDurationMean(): not enabled", {});
"DebugTools::FrameProfilerGL::gpuDurationMean(): not enabled", {});
return measurementMean(_state->gpuDurationIndex);
}
#ifndef MAGNUM_TARGET_GLES
Double GLFrameProfiler::vertexFetchRatioMean() const {
Double FrameProfilerGL::vertexFetchRatioMean() const {
CORRADE_ASSERT(_state->vertexFetchRatioIndex < measurementCount(),
"DebugTools::GLFrameProfiler::vertexFetchRatioMean(): not enabled", {});
"DebugTools::FrameProfilerGL::vertexFetchRatioMean(): not enabled", {});
return measurementMean(_state->vertexFetchRatioIndex);
}
Double GLFrameProfiler::primitiveClipRatioMean() const {
Double FrameProfilerGL::primitiveClipRatioMean() const {
CORRADE_ASSERT(_state->primitiveClipRatioIndex < measurementCount(),
"DebugTools::GLFrameProfiler::primitiveClipRatioMean(): not enabled", {});
"DebugTools::FrameProfilerGL::primitiveClipRatioMean(): not enabled", {});
return measurementMean(_state->primitiveClipRatioIndex);
}
#endif
namespace {
constexpr const char* GLFrameProfilerValueNames[] {
constexpr const char* FrameProfilerGLValueNames[] {
"FrameTime",
"CpuDuration",
"GpuDuration",
@ -638,24 +638,24 @@ constexpr const char* GLFrameProfilerValueNames[] {
}
Debug& operator<<(Debug& debug, const GLFrameProfiler::Value value) {
debug << "DebugTools::GLFrameProfiler::Value" << Debug::nospace;
Debug& operator<<(Debug& debug, const FrameProfilerGL::Value value) {
debug << "DebugTools::FrameProfilerGL::Value" << Debug::nospace;
const UnsignedInt bit = Math::log2(UnsignedShort(value));
if(1 << bit == UnsignedShort(value))
return debug << "::" << Debug::nospace << GLFrameProfilerValueNames[bit];
return debug << "::" << Debug::nospace << FrameProfilerGLValueNames[bit];
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const GLFrameProfiler::Values value) {
return Containers::enumSetDebugOutput(debug, value, "DebugTools::GLFrameProfiler::Values{}", {
GLFrameProfiler::Value::FrameTime,
GLFrameProfiler::Value::CpuDuration,
GLFrameProfiler::Value::GpuDuration,
Debug& operator<<(Debug& debug, const FrameProfilerGL::Values value) {
return Containers::enumSetDebugOutput(debug, value, "DebugTools::FrameProfilerGL::Values{}", {
FrameProfilerGL::Value::FrameTime,
FrameProfilerGL::Value::CpuDuration,
FrameProfilerGL::Value::GpuDuration,
#ifndef MAGNUM_TARGET_GLES
GLFrameProfiler::Value::VertexFetchRatio,
GLFrameProfiler::Value::PrimitiveClipRatio
FrameProfilerGL::Value::VertexFetchRatio,
FrameProfilerGL::Value::PrimitiveClipRatio
#endif
});
}
@ -668,43 +668,43 @@ namespace Corrade { namespace Utility {
using namespace Magnum;
#ifdef MAGNUM_TARGET_GL
std::string ConfigurationValue<DebugTools::GLFrameProfiler::Value>::toString(const DebugTools::GLFrameProfiler::Value value, ConfigurationValueFlags) {
std::string ConfigurationValue<DebugTools::FrameProfilerGL::Value>::toString(const DebugTools::FrameProfilerGL::Value value, ConfigurationValueFlags) {
const UnsignedInt bit = Math::log2(UnsignedShort(value));
if(1 << bit == UnsignedShort(value))
return DebugTools::GLFrameProfilerValueNames[bit];
return DebugTools::FrameProfilerGLValueNames[bit];
return "";
}
DebugTools::GLFrameProfiler::Value ConfigurationValue<DebugTools::GLFrameProfiler::Value>::fromString(const std::string& value, ConfigurationValueFlags) {
for(std::size_t i = 0; i != Containers::arraySize(DebugTools::GLFrameProfilerValueNames); ++i)
if(DebugTools::GLFrameProfilerValueNames[i] == value)
return DebugTools::GLFrameProfiler::Value(1 << i);
DebugTools::FrameProfilerGL::Value ConfigurationValue<DebugTools::FrameProfilerGL::Value>::fromString(const std::string& value, ConfigurationValueFlags) {
for(std::size_t i = 0; i != Containers::arraySize(DebugTools::FrameProfilerGLValueNames); ++i)
if(DebugTools::FrameProfilerGLValueNames[i] == value)
return DebugTools::FrameProfilerGL::Value(1 << i);
return DebugTools::GLFrameProfiler::Value{};
return DebugTools::FrameProfilerGL::Value{};
}
std::string ConfigurationValue<DebugTools::GLFrameProfiler::Values>::toString(const DebugTools::GLFrameProfiler::Values value, ConfigurationValueFlags) {
std::string ConfigurationValue<DebugTools::FrameProfilerGL::Values>::toString(const DebugTools::FrameProfilerGL::Values value, ConfigurationValueFlags) {
std::string out;
for(std::size_t i = 0; i != Containers::arraySize(DebugTools::GLFrameProfilerValueNames); ++i) {
const auto bit = DebugTools::GLFrameProfiler::Value(1 << i);
for(std::size_t i = 0; i != Containers::arraySize(DebugTools::FrameProfilerGLValueNames); ++i) {
const auto bit = DebugTools::FrameProfilerGL::Value(1 << i);
if(value & bit) {
if(!out.empty()) out += ' ';
out += DebugTools::GLFrameProfilerValueNames[i];
out += DebugTools::FrameProfilerGLValueNames[i];
}
}
return out;
}
DebugTools::GLFrameProfiler::Values ConfigurationValue<DebugTools::GLFrameProfiler::Values>::fromString(const std::string& value, ConfigurationValueFlags) {
DebugTools::FrameProfilerGL::Values ConfigurationValue<DebugTools::FrameProfilerGL::Values>::fromString(const std::string& value, ConfigurationValueFlags) {
const std::vector<std::string> bits = Utility::String::splitWithoutEmptyParts(value);
DebugTools::GLFrameProfiler::Values values;
DebugTools::FrameProfilerGL::Values values;
for(const std::string& bit: bits)
for(std::size_t i = 0; i != Containers::arraySize(DebugTools::GLFrameProfilerValueNames); ++i)
if(DebugTools::GLFrameProfilerValueNames[i] == bit)
values |= DebugTools::GLFrameProfiler::Value(1 << i);
for(std::size_t i = 0; i != Containers::arraySize(DebugTools::FrameProfilerGLValueNames); ++i)
if(DebugTools::FrameProfilerGLValueNames[i] == bit)
values |= DebugTools::FrameProfilerGL::Value(1 << i);
return values;
}

65
src/Magnum/DebugTools/FrameProfiler.h

@ -26,7 +26,7 @@
*/
/** @file
* @brief Class @ref Magnum::DebugTools::FrameProfiler, @ref Magnum::DebugTools::GLFrameProfiler
* @brief Class @ref Magnum::DebugTools::FrameProfiler, @ref Magnum::DebugTools::FrameProfilerGL
* @m_since{2020,06}
*/
@ -46,7 +46,7 @@ namespace Magnum { namespace DebugTools {
A generic implementation of a frame profiler supporting a moving average over
a set of frames as well as delayed measurements to avoid stalls when querying
the results. This class alone doesn't provide any pre-defined measurements, see
for example @ref GLFrameProfiler that provides common measurements like CPU and
for example @ref FrameProfilerGL that provides common measurements like CPU and
GPU time.
@experimental
@ -78,13 +78,13 @@ frames:
@snippet MagnumDebugTools.cpp FrameProfiler-usage-console
And here's a sample output on the terminal --- using a fully configured
@link GLFrameProfiler @endlink:
@link FrameProfilerGL @endlink:
@include debugtools-frameprofiler.ansi
@section DebugTools-FrameProfiler-setup Setting up measurements
Unless you're using this class through @ref GLFrameProfiler, measurements
Unless you're using this class through @ref FrameProfilerGL, measurements
have to be set up by passing @ref Measurement instances to the @ref setup()
function or to the constructor, together with specifying count of frames for
the moving average. A CPU duration measurements using the @ref std::chrono APIs
@ -499,7 +499,7 @@ A @ref FrameProfiler with OpenGL-specific measurements. Instantiate with a
desired subset of measured values and then continue the same way as described
in the @ref DebugTools-FrameProfiler-usage "FrameProfiler usage documentation":
@snippet MagnumDebugTools-gl.cpp GLFrameProfiler-usage
@snippet MagnumDebugTools-gl.cpp FrameProfilerGL-usage
If none if @ref Value::GpuDuration, @ref Value::VertexFetchRatio and
@ref Value::PrimitiveClipRatio is not enabled, the class can operate without an
@ -507,12 +507,12 @@ active OpenGL context.
@experimental
*/
class MAGNUM_DEBUGTOOLS_EXPORT GLFrameProfiler: public FrameProfiler {
class MAGNUM_DEBUGTOOLS_EXPORT FrameProfilerGL: public FrameProfiler {
public:
/**
* @brief Measured value
*
* @see @ref Values, @ref GLFrameProfiler(Values, UnsignedInt),
* @see @ref Values, @ref FrameProfilerGL(Values, UnsignedInt),
* @ref setup()
*/
enum class Value: UnsignedShort {
@ -572,7 +572,7 @@ class MAGNUM_DEBUGTOOLS_EXPORT GLFrameProfiler: public FrameProfiler {
/**
* @brief Measured values
*
* @see @ref GLFrameProfiler(Values, UnsignedInt), @ref setup()
* @see @ref FrameProfilerGL(Values, UnsignedInt), @ref setup()
*/
typedef Containers::EnumSet<Value> Values;
@ -581,7 +581,7 @@ class MAGNUM_DEBUGTOOLS_EXPORT GLFrameProfiler: public FrameProfiler {
*
* Call @ref setup() to populate the profiler with measurements.
*/
explicit GLFrameProfiler();
explicit FrameProfilerGL();
/**
* @brief Constructor
@ -589,21 +589,21 @@ class MAGNUM_DEBUGTOOLS_EXPORT GLFrameProfiler: public FrameProfiler {
* Equivalent to default-constructing an instance and calling
* @ref setup() afterwards.
*/
explicit GLFrameProfiler(Values values, UnsignedInt maxFrameCount);
explicit FrameProfilerGL(Values values, UnsignedInt maxFrameCount);
/** @brief Copying is not allowed */
GLFrameProfiler(const GLFrameProfiler&) = delete;
FrameProfilerGL(const FrameProfilerGL&) = delete;
/** @brief Move constructor */
GLFrameProfiler(GLFrameProfiler&&) noexcept;
FrameProfilerGL(FrameProfilerGL&&) noexcept;
/** @brief Copying is not allowed */
GLFrameProfiler& operator=(const GLFrameProfiler&) = delete;
FrameProfilerGL& operator=(const FrameProfilerGL&) = delete;
/** @brief Move assignment */
GLFrameProfiler& operator=(GLFrameProfiler&&) noexcept;
FrameProfilerGL& operator=(FrameProfilerGL&&) noexcept;
~GLFrameProfiler();
~FrameProfilerGL();
/**
* @brief Setup measured values
@ -621,7 +621,7 @@ class MAGNUM_DEBUGTOOLS_EXPORT GLFrameProfiler: public FrameProfiler {
* @brief Measured values
*
* Corresponds to the @p values parameter passed to
* @ref GLFrameProfiler(Values, UnsignedInt) or @ref setup().
* @ref FrameProfilerGL(Values, UnsignedInt) or @ref setup().
*/
Values values() const;
@ -696,19 +696,26 @@ class MAGNUM_DEBUGTOOLS_EXPORT GLFrameProfiler: public FrameProfiler {
Containers::Pointer<State> _state;
};
CORRADE_ENUMSET_OPERATORS(GLFrameProfiler::Values)
CORRADE_ENUMSET_OPERATORS(FrameProfilerGL::Values)
/**
@debugoperatorclassenum{GLFrameProfiler,GLFrameProfiler::Value}
@debugoperatorclassenum{FrameProfilerGL,FrameProfilerGL::Value}
@m_since{2020,06}
*/
MAGNUM_DEBUGTOOLS_EXPORT Debug& operator<<(Debug& debug, GLFrameProfiler::Value value);
MAGNUM_DEBUGTOOLS_EXPORT Debug& operator<<(Debug& debug, FrameProfilerGL::Value value);
/**
@debugoperatorclassenum{GLFrameProfiler,GLFrameProfiler::Values}
@debugoperatorclassenum{FrameProfilerGL,FrameProfilerGL::Values}
@m_since{2020,06}
*/
MAGNUM_DEBUGTOOLS_EXPORT Debug& operator<<(Debug& debug, GLFrameProfiler::Values value);
MAGNUM_DEBUGTOOLS_EXPORT Debug& operator<<(Debug& debug, FrameProfilerGL::Values value);
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief FrameProfilerGL
* @m_deprecated_since_latest Use @ref FrameProfilerGL instead.
*/
typedef CORRADE_DEPRECATED("use FrameProfilerGL instead") FrameProfilerGL GLFrameProfiler;
#endif
#endif
}}
@ -717,10 +724,10 @@ namespace Corrade { namespace Utility {
#ifdef MAGNUM_TARGET_GL
/**
@configurationvalue{Magnum::DebugTools::GLFrameProfiler::Value}
@configurationvalue{Magnum::DebugTools::FrameProfilerGL::Value}
@m_since{2020,06}
*/
template<> struct MAGNUM_DEBUGTOOLS_EXPORT ConfigurationValue<Magnum::DebugTools::GLFrameProfiler::Value> {
template<> struct MAGNUM_DEBUGTOOLS_EXPORT ConfigurationValue<Magnum::DebugTools::FrameProfilerGL::Value> {
ConfigurationValue() = delete;
/**
@ -728,21 +735,21 @@ template<> struct MAGNUM_DEBUGTOOLS_EXPORT ConfigurationValue<Magnum::DebugTools
*
* If the value is invalid, returns an empty string.
*/
static std::string toString(Magnum::DebugTools::GLFrameProfiler::Value value, ConfigurationValueFlags);
static std::string toString(Magnum::DebugTools::FrameProfilerGL::Value value, ConfigurationValueFlags);
/**
* @brief Reads enum value as a string
*
* If the string is invalid, returns a zero (invalid) value.
*/
static Magnum::DebugTools::GLFrameProfiler::Value fromString(const std::string& stringValue, ConfigurationValueFlags);
static Magnum::DebugTools::FrameProfilerGL::Value fromString(const std::string& stringValue, ConfigurationValueFlags);
};
/**
@configurationvalue{Magnum::DebugTools::GLFrameProfiler::Values}
@configurationvalue{Magnum::DebugTools::FrameProfilerGL::Values}
@m_since{2020,06}
*/
template<> struct MAGNUM_DEBUGTOOLS_EXPORT ConfigurationValue<Magnum::DebugTools::GLFrameProfiler::Values> {
template<> struct MAGNUM_DEBUGTOOLS_EXPORT ConfigurationValue<Magnum::DebugTools::FrameProfilerGL::Values> {
ConfigurationValue() = delete;
/**
@ -751,7 +758,7 @@ template<> struct MAGNUM_DEBUGTOOLS_EXPORT ConfigurationValue<Magnum::DebugTools
* Writes the enum set as a sequence of flag names separated by spaces. If
* the value is invalid, returns an empty string.
*/
static std::string toString(Magnum::DebugTools::GLFrameProfiler::Values value, ConfigurationValueFlags);
static std::string toString(Magnum::DebugTools::FrameProfilerGL::Values value, ConfigurationValueFlags);
/**
* @brief Reads enum set value as a string
@ -759,7 +766,7 @@ template<> struct MAGNUM_DEBUGTOOLS_EXPORT ConfigurationValue<Magnum::DebugTools
* Assumes the string is a sequence of flag names separated by spaces. If
* the value is invalid, returns an empty set.
*/
static Magnum::DebugTools::GLFrameProfiler::Values fromString(const std::string& stringValue, ConfigurationValueFlags);
static Magnum::DebugTools::FrameProfilerGL::Values fromString(const std::string& stringValue, ConfigurationValueFlags);
};
#endif

50
src/Magnum/DebugTools/Test/FrameProfilerGLTest.cpp

@ -53,14 +53,14 @@ struct FrameProfilerGLTest: GL::OpenGLTester {
struct {
const char* name;
GLFrameProfiler::Values values;
FrameProfilerGL::Values values;
} Data[]{
{"gpu duration", GLFrameProfiler::Value::GpuDuration},
{"cpu duration + gpu duration", GLFrameProfiler::Value::CpuDuration|GLFrameProfiler::Value::GpuDuration},
{"frame time + gpu duration", GLFrameProfiler::Value::FrameTime|GLFrameProfiler::Value::GpuDuration},
{"gpu duration", FrameProfilerGL::Value::GpuDuration},
{"cpu duration + gpu duration", FrameProfilerGL::Value::CpuDuration|FrameProfilerGL::Value::GpuDuration},
{"frame time + gpu duration", FrameProfilerGL::Value::FrameTime|FrameProfilerGL::Value::GpuDuration},
#ifndef MAGNUM_TARGET_GLES
{"gpu duration + vertex fetch ratio", GLFrameProfiler::Value::GpuDuration|GLFrameProfiler::Value::VertexFetchRatio},
{"vertex fetch ratio + primitive clip ratio", GLFrameProfiler::Value::VertexFetchRatio|GLFrameProfiler::Value::PrimitiveClipRatio}
{"gpu duration + vertex fetch ratio", FrameProfilerGL::Value::GpuDuration|FrameProfilerGL::Value::VertexFetchRatio},
{"vertex fetch ratio + primitive clip ratio", FrameProfilerGL::Value::VertexFetchRatio|FrameProfilerGL::Value::PrimitiveClipRatio}
#endif
};
@ -78,7 +78,7 @@ void FrameProfilerGLTest::test() {
auto&& data = Data[testCaseInstanceId()];
setTestCaseDescription(data.name);
if(data.values & GLFrameProfiler::Value::GpuDuration) {
if(data.values & FrameProfilerGL::Value::GpuDuration) {
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::timer_query>())
CORRADE_SKIP(GL::Extensions::ARB::timer_query::string() << "is not supported.");
@ -92,7 +92,7 @@ void FrameProfilerGLTest::test() {
}
#ifndef MAGNUM_TARGET_GLES
if((data.values & GLFrameProfiler::Value::VertexFetchRatio) && !GL::Context::current().isExtensionSupported<GL::Extensions::ARB::pipeline_statistics_query>())
if((data.values & FrameProfilerGL::Value::VertexFetchRatio) && !GL::Context::current().isExtensionSupported<GL::Extensions::ARB::pipeline_statistics_query>())
CORRADE_SKIP(GL::Extensions::ARB::pipeline_statistics_query::string() << "is not supported.");
#endif
@ -112,15 +112,15 @@ void FrameProfilerGLTest::test() {
Shaders::Flat3D shader;
GL::Mesh mesh = MeshTools::compile(Primitives::cubeSolid());
GLFrameProfiler profiler{data.values, 4};
FrameProfilerGL profiler{data.values, 4};
CORRADE_COMPARE(profiler.maxFrameCount(), 4);
/* MSVC 2015 needs the {} */
for(auto value: {GLFrameProfiler::Value::CpuDuration,
GLFrameProfiler::Value::GpuDuration,
for(auto value: {FrameProfilerGL::Value::CpuDuration,
FrameProfilerGL::Value::GpuDuration,
#ifndef MAGNUM_TARGET_GLES
GLFrameProfiler::Value::VertexFetchRatio,
GLFrameProfiler::Value::PrimitiveClipRatio
FrameProfilerGL::Value::VertexFetchRatio,
FrameProfilerGL::Value::PrimitiveClipRatio
#endif
}) {
if(data.values & value)
@ -153,8 +153,8 @@ void FrameProfilerGLTest::test() {
/* The GPU time should not be a total zero. Can't test upper bound because
(especially on overloaded CIs) it all takes a magnitude more than
expected. */
if(data.values & GLFrameProfiler::Value::GpuDuration) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(GLFrameProfiler::Value::GpuDuration));
if(data.values & FrameProfilerGL::Value::GpuDuration) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(FrameProfilerGL::Value::GpuDuration));
CORRADE_COMPARE_AS(profiler.gpuDurationMean(), 100,
TestSuite::Compare::Greater);
}
@ -162,24 +162,24 @@ void FrameProfilerGLTest::test() {
/* 3/4 frames took 1 ms, the ideal average is 0.75 ms. Can't test upper
bound because (especially on overloaded CIs) it all takes a magnitude
more than expected. */
if(data.values & GLFrameProfiler::Value::CpuDuration) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(GLFrameProfiler::Value::CpuDuration));
if(data.values & FrameProfilerGL::Value::CpuDuration) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(FrameProfilerGL::Value::CpuDuration));
CORRADE_COMPARE_AS(profiler.cpuDurationMean(), 0.70*1000*1000,
TestSuite::Compare::GreaterOrEqual);
}
#ifndef MAGNUM_TARGET_GLES
/* 24 unique vertices in 12 triangles, ideal ratio is 24/36 */
if(data.values & GLFrameProfiler::Value::VertexFetchRatio) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(GLFrameProfiler::Value::VertexFetchRatio));
if(data.values & FrameProfilerGL::Value::VertexFetchRatio) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(FrameProfilerGL::Value::VertexFetchRatio));
CORRADE_COMPARE_WITH(profiler.vertexFetchRatioMean()/1000, 0.6667,
TestSuite::Compare::around(0.1));
}
/* We use a default transformation, which means the whole cube should be
visible, nothing clipped */
if(data.values & GLFrameProfiler::Value::PrimitiveClipRatio) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(GLFrameProfiler::Value::PrimitiveClipRatio));
if(data.values & FrameProfilerGL::Value::PrimitiveClipRatio) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(FrameProfilerGL::Value::PrimitiveClipRatio));
CORRADE_COMPARE(profiler.primitiveClipRatioMean()/1000, 0.0);
}
#endif
@ -190,7 +190,7 @@ void FrameProfilerGLTest::vertexFetchRatioDivisionByZero() {
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::pipeline_statistics_query>())
CORRADE_SKIP(GL::Extensions::ARB::pipeline_statistics_query::string() << "is not supported.");
GLFrameProfiler profiler{GLFrameProfiler::Value::VertexFetchRatio, 4};
FrameProfilerGL profiler{FrameProfilerGL::Value::VertexFetchRatio, 4};
profiler.beginFrame();
profiler.endFrame();
@ -208,7 +208,7 @@ void FrameProfilerGLTest::vertexFetchRatioDivisionByZero() {
/* No draws happened, so the ratio should be 0 (and not crashing with a
division by zero) */
CORRADE_VERIFY(profiler.isMeasurementAvailable(GLFrameProfiler::Value::VertexFetchRatio));
CORRADE_VERIFY(profiler.isMeasurementAvailable(FrameProfilerGL::Value::VertexFetchRatio));
CORRADE_COMPARE(profiler.vertexFetchRatioMean(), 0.0);
}
@ -216,7 +216,7 @@ void FrameProfilerGLTest::primitiveClipRatioDivisionByZero() {
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::pipeline_statistics_query>())
CORRADE_SKIP(GL::Extensions::ARB::pipeline_statistics_query::string() << "is not supported.");
GLFrameProfiler profiler{GLFrameProfiler::Value::PrimitiveClipRatio, 4};
FrameProfilerGL profiler{FrameProfilerGL::Value::PrimitiveClipRatio, 4};
profiler.beginFrame();
profiler.endFrame();
@ -234,7 +234,7 @@ void FrameProfilerGLTest::primitiveClipRatioDivisionByZero() {
/* No draws happened, so the ratio should be 0 (and not crashing with a
division by zero) */
CORRADE_VERIFY(profiler.isMeasurementAvailable(GLFrameProfiler::Value::PrimitiveClipRatio));
CORRADE_VERIFY(profiler.isMeasurementAvailable(FrameProfilerGL::Value::PrimitiveClipRatio));
CORRADE_COMPARE(profiler.primitiveClipRatioMean(), 0.0);
}
#endif

68
src/Magnum/DebugTools/Test/FrameProfilerTest.cpp

@ -98,14 +98,14 @@ struct {
#ifdef MAGNUM_TARGET_GL
struct {
const char* name;
GLFrameProfiler::Values values;
FrameProfilerGL::Values values;
UnsignedInt measurementCount;
UnsignedInt measurementDelay;
} GLData[]{
{"empty", {}, 0, 1},
{"frame time", GLFrameProfiler::Value::FrameTime, 1, 2},
{"cpu duration", GLFrameProfiler::Value::CpuDuration, 1, 1},
{"frame time + cpu duration", GLFrameProfiler::Value::FrameTime|GLFrameProfiler::Value::CpuDuration, 2, 2}
{"frame time", FrameProfilerGL::Value::FrameTime, 1, 2},
{"cpu duration", FrameProfilerGL::Value::CpuDuration, 1, 1},
{"frame time + cpu duration", FrameProfilerGL::Value::FrameTime|FrameProfilerGL::Value::CpuDuration, 2, 2}
};
#endif
@ -1114,16 +1114,16 @@ void FrameProfilerTest::gl() {
setTestCaseDescription(data.name);
/* Test that we use the right state pointers to survive a move */
Containers::Pointer<GLFrameProfiler> profiler_{InPlaceInit, data.values, 4u};
GLFrameProfiler profiler = std::move(*profiler_);
Containers::Pointer<FrameProfilerGL> profiler_{InPlaceInit, data.values, 4u};
FrameProfilerGL profiler = std::move(*profiler_);
profiler_ = nullptr;
CORRADE_COMPARE(profiler.values(), data.values);
CORRADE_COMPARE(profiler.maxFrameCount(), 4);
CORRADE_COMPARE(profiler.measurementCount(), data.measurementCount);
/* MSVC 2015 needs the {} */
for(auto value: {GLFrameProfiler::Value::CpuDuration,
GLFrameProfiler::Value::FrameTime}) {
for(auto value: {FrameProfilerGL::Value::CpuDuration,
FrameProfilerGL::Value::FrameTime}) {
if(data.values & value)
CORRADE_VERIFY(!profiler.isMeasurementAvailable(value));
}
@ -1152,8 +1152,8 @@ void FrameProfilerTest::gl() {
bound because (especially on overloaded CIs) it all takes a magnitude
more than expected. Emscripten builds have it as low as 0.5, account for
that. */
if(data.values & GLFrameProfiler::Value::CpuDuration) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(GLFrameProfiler::Value::CpuDuration));
if(data.values & FrameProfilerGL::Value::CpuDuration) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(FrameProfilerGL::Value::CpuDuration));
CORRADE_COMPARE_AS(profiler.cpuDurationMean(), 0.50*1000*1000,
TestSuite::Compare::GreaterOrEqual);
}
@ -1161,8 +1161,8 @@ void FrameProfilerTest::gl() {
/* 3/4 frames took 1 ms, and one 10 ms, the ideal average is 3.25 ms. Can't
test upper bound because (especially on overloaded CIs) it all takes a
magnitude more than expected. */
if(data.values & GLFrameProfiler::Value::FrameTime) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(GLFrameProfiler::Value::FrameTime));
if(data.values & FrameProfilerGL::Value::FrameTime) {
CORRADE_VERIFY(profiler.isMeasurementAvailable(FrameProfilerGL::Value::FrameTime));
CORRADE_COMPARE_AS(profiler.frameTimeMean(), 3.20*1000*1000,
TestSuite::Compare::GreaterOrEqual);
}
@ -1175,19 +1175,19 @@ void FrameProfilerTest::glNotEnabled() {
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
GLFrameProfiler profiler{{}, 5};
FrameProfilerGL profiler{{}, 5};
std::ostringstream out;
Error redirectError{&out};
profiler.isMeasurementAvailable(GLFrameProfiler::Value::CpuDuration);
profiler.isMeasurementAvailable(FrameProfilerGL::Value::CpuDuration);
profiler.frameTimeMean();
profiler.cpuDurationMean();
profiler.gpuDurationMean();
CORRADE_COMPARE(out.str(),
"DebugTools::GLFrameProfiler::isMeasurementAvailable(): DebugTools::GLFrameProfiler::Value::CpuDuration not enabled\n"
"DebugTools::GLFrameProfiler::frameTimeMean(): not enabled\n"
"DebugTools::GLFrameProfiler::cpuDurationMean(): not enabled\n"
"DebugTools::GLFrameProfiler::gpuDurationMean(): not enabled\n");
"DebugTools::FrameProfilerGL::isMeasurementAvailable(): DebugTools::FrameProfilerGL::Value::CpuDuration not enabled\n"
"DebugTools::FrameProfilerGL::frameTimeMean(): not enabled\n"
"DebugTools::FrameProfilerGL::cpuDurationMean(): not enabled\n"
"DebugTools::FrameProfilerGL::gpuDurationMean(): not enabled\n");
}
#endif
@ -1202,47 +1202,47 @@ void FrameProfilerTest::debugUnits() {
void FrameProfilerTest::debugGLValue() {
std::ostringstream out;
Debug{&out} << GLFrameProfiler::Value::GpuDuration << GLFrameProfiler::Value(0xfff0);
CORRADE_COMPARE(out.str(), "DebugTools::GLFrameProfiler::Value::GpuDuration DebugTools::GLFrameProfiler::Value(0xfff0)\n");
Debug{&out} << FrameProfilerGL::Value::GpuDuration << FrameProfilerGL::Value(0xfff0);
CORRADE_COMPARE(out.str(), "DebugTools::FrameProfilerGL::Value::GpuDuration DebugTools::FrameProfilerGL::Value(0xfff0)\n");
}
void FrameProfilerTest::debugGLValues() {
std::ostringstream out;
Debug{&out} << (GLFrameProfiler::Value::CpuDuration|GLFrameProfiler::Value::FrameTime) << GLFrameProfiler::Values{};
CORRADE_COMPARE(out.str(), "DebugTools::GLFrameProfiler::Value::FrameTime|DebugTools::GLFrameProfiler::Value::CpuDuration DebugTools::GLFrameProfiler::Values{}\n");
Debug{&out} << (FrameProfilerGL::Value::CpuDuration|FrameProfilerGL::Value::FrameTime) << FrameProfilerGL::Values{};
CORRADE_COMPARE(out.str(), "DebugTools::FrameProfilerGL::Value::FrameTime|DebugTools::FrameProfilerGL::Value::CpuDuration DebugTools::FrameProfilerGL::Values{}\n");
}
void FrameProfilerTest::configurationGLValue() {
Utility::ConfigurationGroup c;
c.setValue("value", GLFrameProfiler::Value::GpuDuration);
c.setValue("value", FrameProfilerGL::Value::GpuDuration);
CORRADE_COMPARE(c.value("value"), "GpuDuration");
CORRADE_COMPARE(c.value<GLFrameProfiler::Value>("value"), GLFrameProfiler::Value::GpuDuration);
CORRADE_COMPARE(c.value<FrameProfilerGL::Value>("value"), FrameProfilerGL::Value::GpuDuration);
c.setValue("zero", GLFrameProfiler::Value{});
c.setValue("zero", FrameProfilerGL::Value{});
CORRADE_COMPARE(c.value("zero"), "");
CORRADE_COMPARE(c.value<GLFrameProfiler::Value>("zero"), GLFrameProfiler::Value{});
CORRADE_COMPARE(c.value<FrameProfilerGL::Value>("zero"), FrameProfilerGL::Value{});
c.setValue("invalid", GLFrameProfiler::Value(0xdead));
c.setValue("invalid", FrameProfilerGL::Value(0xdead));
CORRADE_COMPARE(c.value("invalid"), "");
CORRADE_COMPARE(c.value<GLFrameProfiler::Value>("invalid"), GLFrameProfiler::Value{});
CORRADE_COMPARE(c.value<FrameProfilerGL::Value>("invalid"), FrameProfilerGL::Value{});
}
void FrameProfilerTest::configurationGLValues() {
Utility::ConfigurationGroup c;
c.setValue("value", GLFrameProfiler::Value::FrameTime|GLFrameProfiler::Value::CpuDuration|GLFrameProfiler::Value::GpuDuration);
c.setValue("value", FrameProfilerGL::Value::FrameTime|FrameProfilerGL::Value::CpuDuration|FrameProfilerGL::Value::GpuDuration);
CORRADE_COMPARE(c.value("value"), "FrameTime CpuDuration GpuDuration");
CORRADE_COMPARE(c.value<GLFrameProfiler::Values>("value"), GLFrameProfiler::Value::FrameTime|GLFrameProfiler::Value::CpuDuration|GLFrameProfiler::Value::GpuDuration);
CORRADE_COMPARE(c.value<FrameProfilerGL::Values>("value"), FrameProfilerGL::Value::FrameTime|FrameProfilerGL::Value::CpuDuration|FrameProfilerGL::Value::GpuDuration);
c.setValue("empty", GLFrameProfiler::Values{});
c.setValue("empty", FrameProfilerGL::Values{});
CORRADE_COMPARE(c.value("empty"), "");
CORRADE_COMPARE(c.value<GLFrameProfiler::Values>("empty"), GLFrameProfiler::Values{});
CORRADE_COMPARE(c.value<FrameProfilerGL::Values>("empty"), FrameProfilerGL::Values{});
c.setValue("invalid", GLFrameProfiler::Value::CpuDuration|GLFrameProfiler::Value::GpuDuration|GLFrameProfiler::Value(0xff00));
c.setValue("invalid", FrameProfilerGL::Value::CpuDuration|FrameProfilerGL::Value::GpuDuration|FrameProfilerGL::Value(0xff00));
CORRADE_COMPARE(c.value("invalid"), "CpuDuration GpuDuration");
CORRADE_COMPARE(c.value<GLFrameProfiler::Values>("invalid"), GLFrameProfiler::Value::CpuDuration|GLFrameProfiler::Value::GpuDuration);
CORRADE_COMPARE(c.value<FrameProfilerGL::Values>("invalid"), FrameProfilerGL::Value::CpuDuration|FrameProfilerGL::Value::GpuDuration);
}
#endif

Loading…
Cancel
Save