Browse Source

GL: implement WEBGL_debug_renderer_info.

Unlike most other extensions, this one has to be explicitly enabled in
Emscripten in order to be used. Which thus done as part of other "driver
workarounds" done on startup. To avoid that, the extension can be
explicitly disabled, and thanks to the previous commit the disabling
will be performed before the extension is attempted to be enabled.
pull/240/head
Vladimír Vondruš 5 years ago
parent
commit
13d62634d8
  1. 7
      doc/changelog.dox
  2. 2
      doc/opengl-support.dox
  3. 23
      src/Magnum/GL/Context.cpp
  4. 50
      src/Magnum/GL/Context.h
  5. 14
      src/Magnum/GL/Implementation/driverSpecific.cpp

7
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

2
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

23
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<Extensions::WEBGL::debug_renderer_info>()) {
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<const char*>(glGetString(GL_VENDOR)), Containers::StringViewFlag::Global};
}
#ifdef MAGNUM_TARGET_WEBGL
Containers::StringView Context::vendorStringUnmasked() const {
return {reinterpret_cast<const char*>(glGetString(
isExtensionSupported<Extensions::WEBGL::debug_renderer_info>() ?
0x9245 /* GL_UNMASKED_VENDOR_WEBGL */ : GL_VENDOR
)), Containers::StringViewFlag::Global};
}
#endif
Containers::StringView Context::rendererString() const {
return {reinterpret_cast<const char*>(glGetString(GL_RENDERER)), Containers::StringViewFlag::Global};
}
#ifdef MAGNUM_TARGET_WEBGL
Containers::StringView Context::rendererStringUnmasked() const {
return {reinterpret_cast<const char*>(glGetString(
isExtensionSupported<Extensions::WEBGL::debug_renderer_info>() ?
0x9246 /* GL_UNMASKED_RENDERER_WEBGL */ : GL_RENDERER
)), Containers::StringViewFlag::Global};
}
#endif
Containers::StringView Context::versionString() const {
return {reinterpret_cast<const char*>(glGetString(GL_VERSION)), Containers::StringViewFlag::Global};
}

50
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
*

14
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 <emscripten/html5.h>
#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<Extensions::WEBGL::debug_renderer_info>()) {
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);

Loading…
Cancel
Save