From 28b1ad74c9c98b96934864433353e7c1f14e354c Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Fri, 28 Oct 2022 07:20:59 +0200 Subject: OpenGL graphics helpers fixes - Adjust warning message to match GL version they are used against - Correctly call glDrawElementsInstancedBaseVertexBaseInstance on GL 4 - Overload glDrawArraysInstancedBaseInstance to call glDrawArraysInstanced on ES 3 Change-Id: I54e054cc636327e424e4732362dfa2d79562d958 Reviewed-by: Qt CI Bot Reviewed-by: Mike Krus (cherry picked from commit 7678db1b8ac5a75950b70daf60baa7b42fd826d1) Reviewed-by: Qt Cherry-pick Bot --- .../renderers/opengl/graphicshelpers/graphicshelperes3.cpp | 11 +++++++++++ .../renderers/opengl/graphicshelpers/graphicshelperes3_2.cpp | 2 +- .../renderers/opengl/graphicshelpers/graphicshelperes3_p.h | 1 + .../renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp | 2 +- .../renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp | 2 +- .../renderers/opengl/graphicshelpers/graphicshelpergl4.cpp | 9 +++------ 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3.cpp b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3.cpp index bf9eb3faf..75876686c 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3.cpp @@ -227,6 +227,17 @@ void GraphicsHelperES3::drawArraysInstanced(GLenum primitiveType, GLint first, G instances); } +void GraphicsHelperES3::drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) +{ + if (baseInstance != 0) + qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 3"; + + m_extraFuncs->glDrawArraysInstanced(primitiveType, + first, + count, + instances); +} + void GraphicsHelperES3::readBuffer(GLenum mode) { m_extraFuncs->glReadBuffer(mode); diff --git a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_2.cpp b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_2.cpp index 5b35ce715..ce3f9ac42 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_2.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_2.cpp @@ -104,7 +104,7 @@ void GraphicsHelperES3_2::setVerticesPerPatch(GLint verticesPerPatch) void GraphicsHelperES3_2::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex, GLint baseInstance) { if (baseInstance != 0) - qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2"; + qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 3.2"; m_extraFuncs->glDrawElementsInstancedBaseVertex(primitiveType, primitiveCount, diff --git a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_p.h b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_p.h index eca673a7a..8fc12ca6d 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_p.h +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_p.h @@ -40,6 +40,7 @@ public: void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) override; void drawBuffers(GLsizei n, const int *bufs) override; void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) override; + void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) override; void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) override; void readBuffer(GLenum mode) override; void drawBuffer(GLenum mode) override; diff --git a/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp b/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp index 38c4b743a..6ff7e99d4 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp @@ -63,7 +63,7 @@ void GraphicsHelperGL3_2::drawElementsInstancedBaseVertexBaseInstance(GLenum pri GLint baseInstance) { if (baseInstance != 0) - qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2"; + qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL 3.2"; // glDrawElements OpenGL 3.1 or greater m_funcs->glDrawElementsInstancedBaseVertex(primitiveType, diff --git a/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp b/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp index f2070921e..8e154a1d2 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp @@ -62,7 +62,7 @@ void GraphicsHelperGL3_3::drawElementsInstancedBaseVertexBaseInstance(GLenum pri GLint baseInstance) { if (baseInstance != 0) - qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL 3"; + qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL 3.3"; // glDrawElements OpenGL 3.1 or greater m_funcs->glDrawElementsInstancedBaseVertex(primitiveType, diff --git a/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp b/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp index 2601e44ef..291255d0a 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp @@ -151,16 +151,13 @@ void GraphicsHelperGL4::drawElementsInstancedBaseVertexBaseInstance(GLenum primi GLint baseVertex, GLint baseInstance) { - if (baseInstance != 0) - qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2"; - - // glDrawElements OpenGL 3.1 or greater - m_funcs->glDrawElementsInstancedBaseVertex(primitiveType, + m_funcs->glDrawElementsInstancedBaseVertexBaseInstance(primitiveType, primitiveCount, indexType, indices, instances, - baseVertex); + baseVertex, + baseInstance); } void GraphicsHelperGL4::drawArraysInstanced(GLenum primitiveType, -- cgit v1.2.3