Browse Source

GL: advertise WEBGL_multi_draw only on Emscripten 2.0.0 and up.

pull/495/head
Vladimír Vondruš 5 years ago
parent
commit
acdbcc2ef4
  1. 4
      src/Magnum/GL/AbstractShaderProgram.h
  2. 9
      src/Magnum/GL/Implementation/MeshState.cpp
  3. 10
      src/Magnum/GL/Implementation/driverSpecific.cpp

4
src/Magnum/GL/AbstractShaderProgram.h

@ -844,7 +844,9 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @m_class{m-doc-external} [ANGLE_multi_draw](https://chromium.googlesource.com/angle/angle/+/master/extensions/ANGLE_multi_draw.txt) * @m_class{m-doc-external} [ANGLE_multi_draw](https://chromium.googlesource.com/angle/angle/+/master/extensions/ANGLE_multi_draw.txt)
* is present, and on WebGL if @webgl_extension{WEBGL,multi_draw} is * is present, and on WebGL if @webgl_extension{WEBGL,multi_draw} is
* not present, the functionality is emulated using a sequence of * not present, the functionality is emulated using a sequence of
* @ref draw(MeshView&) calls. * @ref draw(MeshView&) calls. Note that @webgl_extension{WEBGL,multi_draw}
* is only implemented since Emscripten 2.0.0, so it's not even
* advertised on older versions.
* *
* If @gl_extension{ARB,vertex_array_object} (part of OpenGL 3.0), * If @gl_extension{ARB,vertex_array_object} (part of OpenGL 3.0),
* OpenGL ES 3.0, WebGL 2.0, @gl_extension{OES,vertex_array_object} in * OpenGL ES 3.0, WebGL 2.0, @gl_extension{OES,vertex_array_object} in

9
src/Magnum/GL/Implementation/MeshState.cpp

@ -136,9 +136,16 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector<s
extensions.push_back(Extensions::WEBGL::multi_draw::string()); extensions.push_back(Extensions::WEBGL::multi_draw::string());
/* The WEBGL extension uses the same entrypoints as the ANGLE /* The WEBGL extension uses the same entrypoints as the ANGLE
extension it was based on */ extension it was based on. Only available since 2.0.0:
https://github.com/emscripten-core/emscripten/pull/11650 */
#if __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20000
multiDrawArraysImplementation = glMultiDrawArraysANGLE; multiDrawArraysImplementation = glMultiDrawArraysANGLE;
multiDrawElementsImplementation = glMultiDrawElementsANGLE; multiDrawElementsImplementation = glMultiDrawElementsANGLE;
#else
/* In Context::setupDriverWorkarounds() we make sure the extension
is not even advertised, so this shouldn't be reached. */
CORRADE_INTERNAL_ASSERT_UNREACHABLE();
#endif
} }
#endif #endif

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

@ -560,6 +560,16 @@ void Context::setupDriverWorkarounds() {
_setRequiredVersion(EXT::disjoint_timer_query, None); _setRequiredVersion(EXT::disjoint_timer_query, None);
#endif #endif
#ifdef MAGNUM_TARGET_WEBGL
/* The WEBGL_multi_draw entrypoints are only available since Emscripten
2.0.0: https://github.com/emscripten-core/emscripten/pull/11650
However, the extension is advertised even on older versions and we have
no way to link to those entrypoints there. */
#if __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ < 20000
_setRequiredVersion(WEBGL::multi_draw, None);
#endif
#endif
#undef _setRequiredVersion #undef _setRequiredVersion
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

Loading…
Cancel
Save