Browse Source

TextureTools: make the DistanceField benchmark more stable.

Use a different overload to not have to create a temp framebuffer every
time, move also the error checking outside the loop and increase the
iteration count to actually have a result that isn't wildly different
every time.
pull/168/head
Vladimír Vondruš 3 years ago
parent
commit
f2dd0c5d75
  1. 12
      src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp

12
src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp

@ -44,6 +44,7 @@
#include "Magnum/DebugTools/TextureImage.h" #include "Magnum/DebugTools/TextureImage.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Framebuffer.h"
#include "Magnum/GL/OpenGLTester.h" #include "Magnum/GL/OpenGLTester.h"
#include "Magnum/GL/PixelFormat.h" #include "Magnum/GL/PixelFormat.h"
#include "Magnum/GL/Texture.h" #include "Magnum/GL/Texture.h"
@ -336,6 +337,9 @@ void DistanceFieldGLTest::benchmark() {
.setMagnificationFilter(GL::SamplerFilter::Nearest) .setMagnificationFilter(GL::SamplerFilter::Nearest)
.setStorage(1, outputFormat, Vector2i{64}); .setStorage(1, outputFormat, Vector2i{64});
GL::Framebuffer framebuffer{{{}, Vector2i{64}}};
framebuffer.attachTexture(GL::Framebuffer::ColorAttachment(0), output, 0);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
DistanceField distanceField{32}; DistanceField distanceField{32};
@ -343,16 +347,16 @@ void DistanceFieldGLTest::benchmark() {
/* So it doesn't spam too much */ /* So it doesn't spam too much */
GL::DebugOutput::setCallback(nullptr); GL::DebugOutput::setCallback(nullptr);
CORRADE_BENCHMARK(5) { CORRADE_BENCHMARK(25) {
distanceField(input, output, {{}, Vector2i{64}} distanceField(input, framebuffer, {{}, Vector2i{64}}
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
, inputImage->size() , inputImage->size()
#endif #endif
); );
MAGNUM_VERIFY_NO_GL_ERROR();
} }
MAGNUM_VERIFY_NO_GL_ERROR();
GL::DebugOutput::setDefaultCallback(); GL::DebugOutput::setDefaultCallback();
} }
#endif #endif

Loading…
Cancel
Save