From 6769505b87b43101a4c44fc9086d2bae3764cdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 19 Apr 2025 18:43:03 +0200 Subject: [PATCH] TextureTools: benchmark DistanceFieldGL with different output formats. No observable difference. Might be useful to benchmark also the texelFetch() vs sampling variant, but I don't feel like adding such a toggle there. --- .../TextureTools/Test/DistanceFieldGLTest.cpp | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp b/src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp index acd6068c8..f134c6986 100644 --- a/src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp +++ b/src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp @@ -104,6 +104,24 @@ const struct { true, {128, 96}, {64, 32}, false, false}, }; +#ifndef MAGNUM_TARGET_WEBGL +const struct { + const char* name; + GL::TextureFormat format; +} BenchmarkData[]{ + /* On ES2 the format selection is too annoying, just skip the variants + altogether and pick *some* format in the function itself */ + #ifdef MAGNUM_TARGET_GLES2 + {"", GL::TextureFormat{}}, + #else + {"R8 output", GL::TextureFormat::R8}, + {"RGB8 output", GL::TextureFormat::RGB8}, + {"RGBA8 output", GL::TextureFormat::RGBA8}, + {"R16 output", GL::TextureFormat::R16}, + #endif +}; +#endif + DistanceFieldGLTest::DistanceFieldGLTest() { addTests({&DistanceFieldGLTest::construct, &DistanceFieldGLTest::constructCopy, @@ -116,7 +134,9 @@ DistanceFieldGLTest::DistanceFieldGLTest() { &DistanceFieldGLTest::sizeRatioNotMultipleOfTwo}); #ifndef MAGNUM_TARGET_WEBGL - addBenchmarks({&DistanceFieldGLTest::benchmark}, 10, BenchmarkType::GpuTime); + addInstancedBenchmarks({&DistanceFieldGLTest::benchmark}, 10, + Containers::arraySize(BenchmarkData), + BenchmarkType::GpuTime); #endif /* Load the plugin directly from the build tree. Otherwise it's either @@ -468,6 +488,9 @@ void DistanceFieldGLTest::sizeRatioNotMultipleOfTwo() { #ifndef MAGNUM_TARGET_WEBGL void DistanceFieldGLTest::benchmark() { + auto&& data = BenchmarkData[testCaseInstanceId()]; + setTestCaseDescription(data.name); + #ifdef MAGNUM_TARGET_GLES if(!GL::Context::current().isExtensionSupported()) CORRADE_SKIP(GL::Extensions::EXT::disjoint_timer_query::string() << "is not supported, can't benchmark"); @@ -507,8 +530,10 @@ void DistanceFieldGLTest::benchmark() { input.setSubImage(0, {}, *inputImage); #endif + /* On ES2 the format selection is too annoying, just skip the variants + altogether and pick *some* format in the function itself */ #ifndef MAGNUM_TARGET_GLES2 - const GL::TextureFormat outputFormat = GL::TextureFormat::R8; + const GL::TextureFormat outputFormat = data.format; #else GL::TextureFormat outputFormat; if(GL::Context::current().isExtensionSupported())