diff --git a/doc/changelog.dox b/doc/changelog.dox index 5394da935..11ea92b37 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -85,8 +85,11 @@ See also: available on all platforms - Implemented @webgl_extension{EXT,frag_depth} WebGL 1.0 extension (shading language only) -- Recognizing @webgl_extension{EXT,float_blend}, - @webgl_extension{WEBGL,debug_renderer_info} and +- Implemented @webgl_extension{WEBGL,debug_renderer_info} as + @ref GL::Context::rendererStringUnmasked() and + @relativeref{GL::Context,vendorStringUnmasked()} together with printing + those in the engine startup log if the extension is available +- Recognizing @webgl_extension{EXT,float_blend} and @webgl_extension{WEBGL,debug_shaders} extensions, no implementation done yet - Recognizing ANGLE GLES and WebGL base vertex, base instance and multi-draw diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 9c8ce2efa..a79d77175 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -565,7 +565,7 @@ Extension | Status @webgl_extension{OES,texture_float_linear} | done @webgl_extension{OVR,multiview2} | | @webgl_extension{WEBGL,lose_context} | | -@webgl_extension{WEBGL,debug_renderer_info} | | +@webgl_extension{WEBGL,debug_renderer_info} | done @webgl_extension{WEBGL,debug_shaders} | | @webgl_extension{WEBGL,compressed_texture_s3tc} | done @webgl_extension{WEBGL,compressed_texture_pvrtc} | done diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index a9451905f..059bc8a70 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -963,6 +963,11 @@ bool Context::tryCreate(const Configuration& configuration) { /* Print some info and initialize state tracker (which also prints some more info). Mesa's renderer string has a space at the end, trim that. */ Debug{output} << "Renderer:" << rendererString().trimmed() << "by" << vendorString(); + #ifdef MAGNUM_TARGET_WEBGL + if(isExtensionSupported()) { + Debug{output} << "Unmasked renderer:" << rendererStringUnmasked() << "by" << vendorStringUnmasked(); + } + #endif Debug{output} << "OpenGL version:" << versionString(); /* Print the extensions that were disabled above */ @@ -1033,10 +1038,28 @@ Containers::StringView Context::vendorString() const { return {reinterpret_cast(glGetString(GL_VENDOR)), Containers::StringViewFlag::Global}; } +#ifdef MAGNUM_TARGET_WEBGL +Containers::StringView Context::vendorStringUnmasked() const { + return {reinterpret_cast(glGetString( + isExtensionSupported() ? + 0x9245 /* GL_UNMASKED_VENDOR_WEBGL */ : GL_VENDOR + )), Containers::StringViewFlag::Global}; +} +#endif + Containers::StringView Context::rendererString() const { return {reinterpret_cast(glGetString(GL_RENDERER)), Containers::StringViewFlag::Global}; } +#ifdef MAGNUM_TARGET_WEBGL +Containers::StringView Context::rendererStringUnmasked() const { + return {reinterpret_cast(glGetString( + isExtensionSupported() ? + 0x9246 /* GL_UNMASKED_RENDERER_WEBGL */ : GL_RENDERER + )), Containers::StringViewFlag::Global}; +} +#endif + Containers::StringView Context::versionString() const { return {reinterpret_cast(glGetString(GL_VERSION)), Containers::StringViewFlag::Global}; } diff --git a/src/Magnum/GL/Context.h b/src/Magnum/GL/Context.h index b845b8990..43246b7f8 100644 --- a/src/Magnum/GL/Context.h +++ b/src/Magnum/GL/Context.h @@ -556,24 +556,70 @@ class MAGNUM_GL_EXPORT Context { * The result is *not* cached, repeated queries will result in repeated * OpenGL calls. The returned view is always * @relativeref{Corrade,Containers::StringViewFlag::NullTerminated} and - * @relativeref{Corrade::Containers::StringViewFlag,Global}. + * @relativeref{Corrade::Containers::StringViewFlag,Global}. In WebGL + * the vendor string is implicitly masked away, use + * @ref vendorStringUnmasked() to access the real vendor string, if + * available. * @see @ref rendererString(), @fn_gl{GetString} with * @def_gl_keyword{VENDOR} */ Containers::StringView vendorString() const; + #if defined(MAGNUM_TARGET_WEBGL) || defined(DOXYGEN_GENERATING_OUTPUT) /** - * @brief Renderer string + * @brief Unmasked vendor string + * @m_since_latest + * + * A WebGL counterpart to @ref vendorString() that returns the real + * vendor string. If @webgl_extension{WEBGL,debug_renderer_info} is not + * available, returns the same as @ref vendorString(). * * The result is *not* cached, repeated queries will result in repeated * OpenGL calls. The returned view is always * @relativeref{Corrade,Containers::StringViewFlag::NullTerminated} and * @relativeref{Corrade::Containers::StringViewFlag,Global}. + * @see @ref rendererStringUnmasked(), @fn_gl{GetString} with + * @def_gl_keyword{UNMASKED_VENDOR_WEBGL} + * @requires_webgl_only Not available on desktop or ES builds. + */ + Containers::StringView vendorStringUnmasked() const; + #endif + + /** + * @brief Renderer string + * + * The result is *not* cached, repeated queries will result in repeated + * OpenGL calls. The returned view is always + * @relativeref{Corrade,Containers::StringViewFlag::NullTerminated} and + * @relativeref{Corrade::Containers::StringViewFlag,Global}. In WebGL + * the renderer string is implicitly masked away, use + * @ref rendererStringUnmasked() to access the real renderer string, if + * available. * @see @ref vendorString(), @fn_gl{GetString} with * @def_gl_keyword{RENDERER} */ Containers::StringView rendererString() const; + #if defined(MAGNUM_TARGET_WEBGL) || defined(DOXYGEN_GENERATING_OUTPUT) + /** + * @brief Unmasked renderer string + * @m_since_latest + * + * A WebGL counterpart to @ref rendererString() that returns the real + * renderer string. If @webgl_extension{WEBGL,debug_renderer_info} is + * not available, returns the same as @ref rendererString(). + * + * The result is *not* cached, repeated queries will result in repeated + * OpenGL calls. The returned view is always + * @relativeref{Corrade,Containers::StringViewFlag::NullTerminated} and + * @relativeref{Corrade::Containers::StringViewFlag,Global}. + * @see @ref vendorStringUnmasked(), @fn_gl{GetString} with + * @def_gl_keyword{UNMASKED_RENDERER_WEBGL} + * @requires_webgl_only Not available on desktop or ES builds. + */ + Containers::StringView rendererStringUnmasked() const; + #endif + /** * @brief Version string * diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index 27b899907..e8a11adcf 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -30,6 +30,10 @@ #include "Magnum/GL/Extensions.h" #include "Magnum/Math/Range.h" +#if defined(MAGNUM_TARGET_WEBGL) && defined(CORRADE_TARGET_EMSCRIPTEN) +#include +#endif + namespace Magnum { namespace GL { namespace { @@ -521,6 +525,16 @@ void Context::setupDriverWorkarounds() { if(_extensionRequiredVersion[Extensions::extension::Index] < Version::version) \ _extensionRequiredVersion[Extensions::extension::Index] = Version::version + /* WEBGL_debug_renderer_info needs to be explicitly requested, + independently of whether Emscripten was told to implicitly request + extensions or not. Has to be done before any call to detectedDriver(), + which relies on this extension. */ + #if defined(MAGNUM_TARGET_WEBGL) && defined(CORRADE_TARGET_EMSCRIPTEN) + if(isExtensionSupported()) { + CORRADE_INTERNAL_ASSERT_OUTPUT(emscripten_webgl_enable_extension(emscripten_webgl_get_current_context(), "WEBGL_debug_renderer_info")); + } + #endif + #ifndef MAGNUM_TARGET_GLES if(!isDriverWorkaroundDisabled("no-layout-qualifiers-on-old-glsl"_s)) { _setRequiredVersion(ARB::explicit_attrib_location, GL320);