From 4caf92cf5d8d2c200f114d7798c3b666e2619c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 12 Oct 2021 18:43:15 +0200 Subject: [PATCH] GL: add some other rather crappy ways to detect ANGLE. Not proud-- actually, WHAT A TRASH FIRE THIS WEBDEV IS FFS --- src/Magnum/GL/Context.h | 9 +++++++-- src/Magnum/GL/Implementation/driverSpecific.cpp | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Magnum/GL/Context.h b/src/Magnum/GL/Context.h index 3893f8230..071f3af83 100644 --- a/src/Magnum/GL/Context.h +++ b/src/Magnum/GL/Context.h @@ -430,8 +430,13 @@ class MAGNUM_GL_EXPORT Context { * browsers on Windows for WebGL. See also * @ref DetectedDriver::SwiftShader. On WebGL, if * @webgl_extension{WEBGL,debug_renderer_info} is not available, - * the detection is done by checking if the line size range is just - * 1, which is always the case on D3D but not always on GL. + * the detection is attempted by checking for a presence of + * @webgl_extension{ANGLE,instanced_arrays} on WebGL 1 (which may + * also be implemented by other drivers than ANGLE) or + * @webgl_extension{WEBGL,multi_draw} on WebGL 2 (which may not be + * available yet on older ANGLE versions), and as a fallback by + * checking if the line size range is just 1, which is always the + * case on D3D but not always on GL. * @requires_gles ANGLE doesn't support desktop OpenGL contexts. */ Angle = 1 << 1, diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index a158a0c60..b03749699 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -487,6 +487,23 @@ auto Context::detectedDriver() -> DetectedDrivers { if(renderer.contains("ANGLE"_s)) *_detectedDrivers |= DetectedDriver::Angle; #ifdef MAGNUM_TARGET_WEBGL + /* Otherwise assume ANGLE is present if WEBGL_debug_renderer_info isn't + present (which would tell us so already) and the ANGLE_instanced_arrays + is present on WebGL 1. Although e.g. Firefox exposes it even though it + renders directly through GL drivers on Linux, so this may catch more + drivers than just ANGLE. */ + /** @todo this (and below) incorrectly detects ANGLE on FF 92+, as it has + the WEBGL_debug_renderer_info disabled */ + #ifdef MAGNUM_TARGET_GLES2 + else if(!isExtensionSupported() && isExtensionSupported()) + /* Or if WEBGL_debug_renderer_info isn't present and WEBGL_multi_draw + (which is based on ANGLE_multi_draw) is present on WebGL 2. This + extension is rather recent (appearing in browsers in late 2020) so it + may not catch all ANGLE implementations. */ + #else + else if(!isExtensionSupported() && isExtensionSupported()) + #endif + *_detectedDrivers |= DetectedDriver::Angle; /* Otherwise try to detect a D3D ANGLE backend by querying line width. It's always exactly just 1 on D3D, usually more on GL, not sure about Metal. so this is not a 100% match. Sources: http://stackoverflow.com/a/20149090