Browse Source

GL: improve ANGLE detection on WebGL.

It's quite easy if WEBGL_debug_renderer_info is present, but if it isn't
then our only hope is to check for ANGLE-specific extensions. Which may
cause some false positives, but since we need to enable various
workarounds for ANGLE to avoid issues, it's better than having the
detection too conservative.

The original ANGLE detection based on line size is probably not so
relevant anymore, but let's keep it there.
pull/539/head
Vladimír Vondruš 4 years ago
parent
commit
f231363bb6
  1. 36
      src/Magnum/GL/Implementation/driverSpecific.cpp

36
src/Magnum/GL/Implementation/driverSpecific.cpp

@ -520,33 +520,37 @@ auto Context::detectedDriver() -> DetectedDrivers {
if(renderer.contains("ANGLE"_s)) if(renderer.contains("ANGLE"_s))
*_detectedDrivers |= DetectedDriver::Angle; *_detectedDrivers |= DetectedDriver::Angle;
#ifdef MAGNUM_TARGET_WEBGL #ifdef MAGNUM_TARGET_WEBGL
/* Otherwise assume ANGLE is present if WEBGL_debug_renderer_info isn't /* If the unmasked renderer string is not available, try other means */
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 /** @todo this (and below) incorrectly detects ANGLE on FF 92+, as it has
the WEBGL_debug_renderer_info disabled */ the WEBGL_debug_renderer_info disabled */
else if(!isExtensionSupported<Extensions::WEBGL::debug_renderer_info>()) {
/* Otherwise assume ANGLE is present if 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. */
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
else if(!isExtensionSupported<Extensions::WEBGL::debug_renderer_info>() && isExtensionSupported<Extensions::ANGLE::instanced_arrays>()) if(isExtensionSupported<Extensions::ANGLE::instanced_arrays>())
/* Or if WEBGL_debug_renderer_info isn't present and WEBGL_multi_draw /* Or if WEBGL_multi_draw (which is based on ANGLE_multi_draw) is
(which is based on ANGLE_multi_draw) is present on WebGL 2. This present on WebGL 2. This extension is rather recent (appearing in
extension is rather recent (appearing in browsers in late 2020) so it browsers in late 2020) so it may not catch all ANGLE
may not catch all ANGLE implementations. */ implementations. */
#else #else
else if(!isExtensionSupported<Extensions::WEBGL::debug_renderer_info>() && isExtensionSupported<Extensions::WEBGL::multi_draw>()) if(isExtensionSupported<Extensions::WEBGL::multi_draw>())
#endif #endif
*_detectedDrivers |= DetectedDriver::Angle; *_detectedDrivers |= DetectedDriver::Angle;
/* Otherwise try to detect a D3D ANGLE backend by querying line width. It's /* Otherwise try to detect a D3D ANGLE backend by querying line width.
always exactly just 1 on D3D, usually more on GL, not sure about Metal. It's always exactly just 1 on D3D, usually (but not always) more on
so this is not a 100% match. Sources: http://stackoverflow.com/a/20149090 GL, not sure about Metal. So this is not a 100% match. Sources:
and http://webglreport.com */ http://stackoverflow.com/a/20149090 and http://webglreport.com */
else { else {
Range1Di range; Range1Di range;
glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range.data()); glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range.data());
if(range.min() == 1 && range.max() == 1 && vendor != "Internet Explorer"_s) if(range.min() == 1 && range.max() == 1 && vendor != "Internet Explorer"_s) {
!Debug{};
*_detectedDrivers |= DetectedDriver::Angle; *_detectedDrivers |= DetectedDriver::Angle;
} }
}
}
#endif #endif
/* SwiftShader */ /* SwiftShader */

Loading…
Cancel
Save