diff --git a/doc/changelog.dox b/doc/changelog.dox index b5c57d1ec..9d5c3b76d 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -116,6 +116,11 @@ See also: - Fixed a bad interaction of @ref GL::Mesh and @ref GL::Buffer state trackers resulting in corrupted rendering on ES/WebGL platforms and systems without @gl_extension{ARB,direct_state_access} / @gl_extension{EXT,direct_state_access} +- Fixed @ref GL::Mesh instanced drawing to properly take into account all + five @gl_extension{ANGLE,instanced_arrays}, + @gl_extension{EXT,instanced_arrays}, @gl_extension{EXT,draw_instanced}, + @gl_extension{NV,instanced_arrays} and @gl_extension{NV,draw_instanced} + extensions - Updated the `base-qt` bootstrap project to correctly reset state tracker when going from and back to Qt code, and to use the framebuffer provided by Qt instead of @ref GL::defaultFramebuffer (see diff --git a/src/Magnum/GL/Implementation/MeshState.cpp b/src/Magnum/GL/Implementation/MeshState.cpp index 40cd635c1..a96df4466 100644 --- a/src/Magnum/GL/Implementation/MeshState.cpp +++ b/src/Magnum/GL/Implementation/MeshState.cpp @@ -120,14 +120,20 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { - extensions.push_back(Extensions::EXT::draw_instanced::string()); + else if(context.isExtensionSupported() || + context.isExtensionSupported()) { + extensions.push_back(context.isExtensionSupported() ? + Extensions::EXT::instanced_arrays::string() : + Extensions::EXT::draw_instanced::string()); drawArraysInstancedImplementation = &Mesh::drawArraysInstancedImplementationEXT; drawElementsInstancedImplementation = &Mesh::drawElementsInstancedImplementationEXT; - } else if(context.isExtensionSupported()) { - extensions.push_back(Extensions::NV::draw_instanced::string()); + } else if(context.isExtensionSupported() || + context.isExtensionSupported()) { + extensions.push_back(context.isExtensionSupported() ? + Extensions::NV::instanced_arrays::string() : + Extensions::NV::draw_instanced::string()); drawArraysInstancedImplementation = &Mesh::drawArraysInstancedImplementationNV; drawElementsInstancedImplementation = &Mesh::drawElementsInstancedImplementationNV; diff --git a/src/Magnum/GL/Mesh.h b/src/Magnum/GL/Mesh.h index 097a902f6..d1b0c8c60 100644 --- a/src/Magnum/GL/Mesh.h +++ b/src/Magnum/GL/Mesh.h @@ -618,7 +618,9 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject { * @requires_gl42 Extension @gl_extension{ARB,transform_feedback_instanced} * if using @ref draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt) * @requires_gles30 Extension @gl_extension{ANGLE,instanced_arrays}, - * @gl_extension2{EXT,draw_instanced,draw_instanced} or + * @gl_extension{EXT,instanced_arrays}, + * @gl_extension{EXT,draw_instanced}, + * @gl_extension{NV,instanced_arrays}, * @gl_extension{NV,draw_instanced} in OpenGL ES 2.0. * @requires_webgl20 Extension @webgl_extension{ANGLE,instanced_arrays} * in WebGL 1.0. @@ -944,8 +946,10 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject { * @requires_gl42 Extension @gl_extension{ARB,base_instance} if * @ref baseInstance() is not `0`. * @requires_gles30 Extension @gl_extension{ANGLE,instanced_arrays}, - * @gl_extension{EXT,instanced_arrays} or - * @gl_extension{NV,instanced_arrays} in OpenGL ES 2.0 if + * @gl_extension{EXT,instanced_arrays}, + * @gl_extension{EXT,draw_instanced}, + * @gl_extension{NV,instanced_arrays}, + * @gl_extension{NV,draw_instanced} in OpenGL ES 2.0 if * @ref instanceCount() is more than `1`. * @requires_webgl20 Extension @webgl_extension{ANGLE,instanced_arrays} * in WebGL 1.0 if @ref instanceCount() is more than `1`. diff --git a/src/Magnum/GL/MeshView.h b/src/Magnum/GL/MeshView.h index 7448a2d2c..d0e53d0fb 100644 --- a/src/Magnum/GL/MeshView.h +++ b/src/Magnum/GL/MeshView.h @@ -204,7 +204,9 @@ class MAGNUM_GL_EXPORT MeshView { * @requires_gl42 Extension @gl_extension{ARB,transform_feedback_instanced} * if using @ref draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt) * @requires_gles30 Extension @gl_extension{ANGLE,instanced_arrays}, - * @gl_extension2{EXT,draw_instanced,draw_instanced} or + * @gl_extension{EXT,instanced_arrays}, + * @gl_extension{EXT,draw_instanced}, + * @gl_extension{NV,instanced_arrays}, * @gl_extension{NV,draw_instanced} in OpenGL ES 2.0. * @requires_webgl20 Extension @webgl_extension{ANGLE,instanced_arrays} * in WebGL 1.0. @@ -248,8 +250,10 @@ class MAGNUM_GL_EXPORT MeshView { * @requires_gl42 Extension @gl_extension{ARB,base_instance} if * @ref baseInstance() is not `0`. * @requires_gles30 Extension @gl_extension{ANGLE,instanced_arrays}, - * @gl_extension{EXT,instanced_arrays} or - * @gl_extension{NV,instanced_arrays} in OpenGL ES 2.0 if + * @gl_extension{EXT,instanced_arrays}, + * @gl_extension{EXT,draw_instanced}, + * @gl_extension{NV,instanced_arrays}, + * @gl_extension{NV,draw_instanced} in OpenGL ES 2.0 if * @ref instanceCount() is more than `1`. * @requires_webgl20 Extension @webgl_extension{ANGLE,instanced_arrays} * in WebGL 1.0 if @ref instanceCount() is more than `1`. diff --git a/src/Magnum/GL/Test/MeshGLTest.cpp b/src/Magnum/GL/Test/MeshGLTest.cpp index 421ce9810..83db1db3d 100644 --- a/src/Magnum/GL/Test/MeshGLTest.cpp +++ b/src/Magnum/GL/Test/MeshGLTest.cpp @@ -2307,7 +2307,9 @@ void MeshGLTest::setInstanceCount() { #elif defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_WEBGL if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported() && !Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported() && !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available."); #else @@ -2353,7 +2355,9 @@ void MeshGLTest::setInstanceCountIndexed() { #elif defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_WEBGL if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported() && !Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported() && !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available."); #else @@ -2540,11 +2544,7 @@ void MeshGLTest::addVertexBufferInstancedFloat() { if(!Context::current().isExtensionSupported() && !Context::current().isExtensionSupported() && !Context::current().isExtensionSupported()) - CORRADE_SKIP("Required instancing extension is not available."); - if(!Context::current().isExtensionSupported() && - !Context::current().isExtensionSupported() && - !Context::current().isExtensionSupported()) - CORRADE_SKIP("Required drawing extension is not available."); + CORRADE_SKIP("Required extension is not available."); #else if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::ANGLE::instanced_arrays::string() + std::string(" is not available.")); @@ -2664,11 +2664,7 @@ void MeshGLTest::resetDivisorAfterInstancedDraw() { if(!Context::current().isExtensionSupported() && !Context::current().isExtensionSupported() && !Context::current().isExtensionSupported()) - CORRADE_SKIP("Required instancing extension is not available."); - if(!Context::current().isExtensionSupported() && - !Context::current().isExtensionSupported() && - !Context::current().isExtensionSupported()) - CORRADE_SKIP("Required drawing extension is not available."); + CORRADE_SKIP("Required extension is not available."); #else if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::ANGLE::instanced_arrays::string() + std::string(" is not available."));