From 1c27ee587b42fc104f4f553e6677beba5620ac66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 12 Dec 2021 21:06:49 +0100 Subject: [PATCH] GL: fix Mesa detection on AMD cards. There it doesn't report Mesa in the renderer, but only in the version string. Broken since d0f57f0153de399e9e529b1e2dba4cc008dd862a. --- .../GL/Implementation/driverSpecific.cpp | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index c290893f1..16333caeb 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -448,6 +448,9 @@ auto Context::detectedDriver() -> DetectedDrivers { #endif ; #endif + #if !defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_WEBGL) + const Containers::StringView version = versionString(); + #endif /* In some cases we can have a combination of drivers (e.g. ANGLE running on top of Mesa, Mesa Zink running on top of NVidia drivers...) so the @@ -466,10 +469,22 @@ auto Context::detectedDriver() -> DetectedDrivers { *_detectedDrivers |= DetectedDriver::IntelWindows; #endif - /* Mesa drivers. On desktop GL and GLES the version string contains Mesa - as well, but not on WebGL. Renderer contains it on all three, except - for Firefox for some reason. */ - if(renderer.contains("Mesa"_s)) { + /* Mesa drivers. + - Intel GL/GLES drivers contain Mesa both in renderer and version + string + - AMD GL/GLES drivers have Mesa only in the version string + - On WebGL the version string is useless, always saying just + "WebGL X.Y (Chromium)" or "WebGL X.Y" + - Mesa is in renderer string in Chromium and nowhere in Firefox for + some reason + + To avoid misdetecting the driver, simply test both where it makes + sense. */ + if(renderer.contains("Mesa"_s) + #ifndef MAGNUM_TARGET_WEBGL + || version.contains("Mesa"_s) + #endif + ) { *_detectedDrivers |= DetectedDriver::Mesa; if(renderer.contains("SVGA3D"_s))