diff --git a/doc/changelog.dox b/doc/changelog.dox index 63cb1b67d..b5c57d1ec 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -58,6 +58,8 @@ See also: - New `--magnum-gpu-validation` @ref GL-Context-command-line "command-line option" and a corresponding environment variable to conveniently enable @gl_extension{KHR,debug} debug output +- Detection of SwiftShader drivers with + @ref GL::Context::DetectedDriver::SwiftShader @subsection changelog-latest-changes Changes and improvements diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index dff794fe3..67f1f0084 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -970,9 +970,10 @@ Debug& operator<<(Debug& debug, const Context::DetectedDriver value) { _c(IntelWindows) _c(Mesa) _c(NVidia) - #endif - #ifndef MAGNUM_TARGET_WEBGL _c(Svga3D) + #ifdef MAGNUM_TARGET_GLES + _c(SwiftShader) + #endif #endif #undef _c /* LCOV_EXCL_STOP */ @@ -993,9 +994,10 @@ Debug& operator<<(Debug& debug, const Context::DetectedDrivers value) { Context::DetectedDriver::IntelWindows, Context::DetectedDriver::Mesa, Context::DetectedDriver::NVidia, + Context::DetectedDriver::Svga3D, + #ifdef MAGNUM_TARGET_GLES + Context::DetectedDriver::SwiftShader #endif - #ifndef MAGNUM_TARGET_WEBGL - Context::DetectedDriver::Svga3D #endif }); } diff --git a/src/Magnum/GL/Context.h b/src/Magnum/GL/Context.h index 5e07bc587..35029cdbc 100644 --- a/src/Magnum/GL/Context.h +++ b/src/Magnum/GL/Context.h @@ -323,12 +323,14 @@ class MAGNUM_GL_EXPORT Context { #endif #endif - #ifdef MAGNUM_TARGET_GLES + #if defined(MAGNUM_TARGET_GLES) || defined(DOXYGEN_GENERATING_OUTPUT) /** * OpenGL ES implementation by ANGLE (translated to D3D), used by * browsers on Windows for WebGL. As the WebGL specification * explicitly disallows exposing driver information to the - * application, this check cannot be done reliably. + * application, this check cannot be done reliably. See also + * @ref DetectedDriver::SwiftShader. + * @requires_gles ANGLE doesn't support desktop OpenGL contexts. */ Angle = 1 << 1, @@ -362,9 +364,7 @@ class MAGNUM_GL_EXPORT Context { * intentionally hide most of the driver information. */ NVidia = 1 << 4, - #endif - #ifndef MAGNUM_TARGET_WEBGL /** * VMware guest GL driver SVGA3D, implemented using Mesa, both * Windows and Linux guests. See https://www.mesa3d.org/vmware-guest.html @@ -373,7 +373,19 @@ class MAGNUM_GL_EXPORT Context { * @requires_gles Not detectable on WebGL, as browsers * intentionally hide most of the driver information. */ - Svga3D = 1 << 5 + Svga3D = 1 << 5, + + #if defined(MAGNUM_TARGET_GLES) || defined(DOXYGEN_GENERATING_OUTPUT) + /** + * [SwiftShader](https://github.com/google/swiftshader) software + * renderer for OpenGL ES. Usually used by browsers in cases where + * a GPU isn't available. See also @ref DetectedDriver::Angle. + * @requires_gles SwiftShader doesn't support desktop OpenGL + * contexts. Not detectable on WebGL, as browsers + * intentionally hide most of the driver information. + */ + SwiftShader = 1 << 6 + #endif #endif }; diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index e85d992af..8871dc235 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -254,6 +254,13 @@ auto Context::detectedDriver() -> DetectedDrivers { } #endif + #ifndef MAGNUM_TARGET_WEBGL + /* SwiftShader */ + if(renderer.find("SwiftShader") != std::string::npos) + return *_detectedDrivers |= DetectedDriver::SwiftShader; + #endif + #endif + return *_detectedDrivers; }