From 6acaa69d91f8309907767860620cbf2de55cf8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 25 Feb 2021 18:53:26 +0100 Subject: [PATCH] Platform: deduplicate verbose logging logic in WindowlessEglApplication. --- src/Magnum/Platform/WindowlessEglApplication.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Magnum/Platform/WindowlessEglApplication.cpp b/src/Magnum/Platform/WindowlessEglApplication.cpp index bad8f68b6..251c5dce1 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessEglApplication.cpp @@ -102,6 +102,8 @@ WindowlessEglContext::WindowlessEglContext(const Configuration& configuration, G /* Otherwise find the display and initialize EGL */ { #ifndef MAGNUM_TARGET_WEBGL + const bool displayVerboseLog = magnumContext && (magnumContext->configurationFlags() >= GL::Context::Configuration::Flag::VerboseLog); + /* If relevant extensions are supported, try to find some display using those APIs, as that works reliably also when running headless. This would ideally use EGL 1.5 APIs but since we still want to support @@ -195,7 +197,7 @@ WindowlessEglContext::WindowlessEglContext(const Configuration& configuration, G if(eglGetError() == EGL_BAD_DEVICE_EXT && !magnumContext->isDriverWorkaroundDisabled("nv-egl-crashy-query-device-attrib"_s)) continue; - if(magnumContext && (magnumContext->configurationFlags() >= GL::Context::Configuration::Flag::VerboseLog)) + if(displayVerboseLog) Debug{} << "Platform::WindowlessEglApplication: eglQueryDeviceStringEXT(EGLDevice=" << Debug::nospace << selectedDevice << Debug::nospace << "):" << eglExtensions; EGLAttrib cudaDeviceNumber; @@ -210,7 +212,7 @@ WindowlessEglContext::WindowlessEglContext(const Configuration& configuration, G return; } - if(magnumContext && (magnumContext->configurationFlags() >= GL::Context::Configuration::Flag::VerboseLog)) { + if(displayVerboseLog) { Debug{} << "Platform::WindowlessEglApplication: found" << count << "EGL devices, choosing EGL device" << selectedDevice << "for CUDA device" << configuration.cudaDevice(); } @@ -218,7 +220,7 @@ WindowlessEglContext::WindowlessEglContext(const Configuration& configuration, G } else { /* Print the log *before* calling eglQueryDevices() again, as the `count` gets overwritten by it */ - if(magnumContext && (magnumContext->configurationFlags() >= GL::Context::Configuration::Flag::VerboseLog)) { + if(displayVerboseLog) { Debug{} << "Platform::WindowlessEglApplication: found" << count << "EGL devices, choosing device" << configuration.device(); }