From f2dd0c5d75ede139b034e187070985f5a51318a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 16 Oct 2023 13:50:07 +0200 Subject: [PATCH] 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. --- src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp b/src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp index 117d4f167..9d60d20d7 100644 --- a/src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp +++ b/src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp @@ -44,6 +44,7 @@ #include "Magnum/DebugTools/TextureImage.h" #include "Magnum/GL/Context.h" #include "Magnum/GL/Extensions.h" +#include "Magnum/GL/Framebuffer.h" #include "Magnum/GL/OpenGLTester.h" #include "Magnum/GL/PixelFormat.h" #include "Magnum/GL/Texture.h" @@ -336,6 +337,9 @@ void DistanceFieldGLTest::benchmark() { .setMagnificationFilter(GL::SamplerFilter::Nearest) .setStorage(1, outputFormat, Vector2i{64}); + GL::Framebuffer framebuffer{{{}, Vector2i{64}}}; + framebuffer.attachTexture(GL::Framebuffer::ColorAttachment(0), output, 0); + MAGNUM_VERIFY_NO_GL_ERROR(); DistanceField distanceField{32}; @@ -343,16 +347,16 @@ void DistanceFieldGLTest::benchmark() { /* So it doesn't spam too much */ GL::DebugOutput::setCallback(nullptr); - CORRADE_BENCHMARK(5) { - distanceField(input, output, {{}, Vector2i{64}} + CORRADE_BENCHMARK(25) { + distanceField(input, framebuffer, {{}, Vector2i{64}} #ifdef MAGNUM_TARGET_GLES , inputImage->size() #endif ); - - MAGNUM_VERIFY_NO_GL_ERROR(); } + MAGNUM_VERIFY_NO_GL_ERROR(); + GL::DebugOutput::setDefaultCallback(); } #endif