From 5c042f62d00bca26fd1c6d77ef276aa5cf8fa6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 16 Oct 2019 19:08:54 +0200 Subject: [PATCH] GL: if timer queries are not available, SKIP the benchmarks. Requiring each benchmark to handle this on its own would be silly. --- src/Magnum/GL/OpenGLTester.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Magnum/GL/OpenGLTester.cpp b/src/Magnum/GL/OpenGLTester.cpp index 3445965e7..fd7e97117 100644 --- a/src/Magnum/GL/OpenGLTester.cpp +++ b/src/Magnum/GL/OpenGLTester.cpp @@ -42,8 +42,22 @@ OpenGLTester::~OpenGLTester() = default; void OpenGLTester::gpuTimeBenchmarkBegin() { setBenchmarkName("GPU time"); - /* Initialize, if not already */ - if(!_gpuTimeQuery.id()) _gpuTimeQuery = TimeQuery{TimeQuery::Target::TimeElapsed}; + /* Initialize, if not already; check for extension presence and skip if not + available. This function is always called from inside CORRADE_BENCHMARK, + which does the test case registration on a proper function. */ + if(!_gpuTimeQuery.id()) { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + skip("GL_ARB_timer_query is not supported"); + #elif defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) + if(!Context::current().isExtensionSupported()) + skip("GL_EXT_disjoint_timer_query_webgl2 is not supported"); + #else + if(!Context::current().isExtensionSupported()) + skip("GL_EXT_disjoint_timer_query is not supported"); + #endif + _gpuTimeQuery = TimeQuery{TimeQuery::Target::TimeElapsed}; + } _gpuTimeQuery.begin(); }