diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-10-11 16:01:22 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-10-11 16:01:22 +0300 |
commit | e1b1a0d2970fd384bd52c734a72536d8452ad070 (patch) | |
tree | 494b70bc1a1e115d7ecce39e698d9621af717971 /src/plugins/renderers/opengl | |
parent | c1f8fa2578d99e07f5e581f26bd532695b9534f9 (diff) | |
parent | b59fdcefdbce6a1870e49b0da14d30b51293dea6 (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.12' into tqtc/lts-5.15-opensourcev5.15.12-lts-lgpl
Change-Id: If1ce1579db02b74dde74731fcf6163614961841f
Diffstat (limited to 'src/plugins/renderers/opengl')
8 files changed, 44 insertions, 11 deletions
diff --git a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3.cpp b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3.cpp index 97a256b9c..2a0f449fb 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3.cpp @@ -263,6 +263,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 65108800b..5f5bc8578 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_2.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_2.cpp @@ -140,7 +140,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 5c34a8abb..9ac9ea159 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_p.h +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelperes3_p.h @@ -76,6 +76,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 8e843bca7..d220fb16d 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp @@ -105,7 +105,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 3a8c8bde8..065cb1c0b 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp @@ -104,7 +104,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 a472da774..7130bb0be 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp @@ -188,16 +188,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, diff --git a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp index ef32594e1..7ba67fed9 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp @@ -481,6 +481,10 @@ bool SubmissionContext::beginDrawing(QSurface *surface) } m_boundArrayBuffer = nullptr; + + // Record the default FBO value as there's no guarantee it remains constant over time + m_defaultFBO = m_gl->defaultFramebufferObject(); + return true; } @@ -1226,6 +1230,10 @@ bool SubmissionContext::setParameters(ShaderParameterPack ¶meterPack, GLShad } } + // Set the pinned images of the previous material + // to pinable so that we should easily find an available image unit + m_imageContext.deactivateImages(); + // Fill Image Uniform Value with proper image units // so that they can be applied as regular uniforms in a second step for (int i = 0; i < parameterPack.images().size(); ++i) { diff --git a/src/plugins/renderers/opengl/renderer/shaderparameterpack.cpp b/src/plugins/renderers/opengl/renderer/shaderparameterpack.cpp index 43b0b90c1..bf7d5fce6 100644 --- a/src/plugins/renderers/opengl/renderer/shaderparameterpack.cpp +++ b/src/plugins/renderers/opengl/renderer/shaderparameterpack.cpp @@ -100,12 +100,28 @@ void ShaderParameterPack::setImage(const int glslNameId, int uniformArrayIndex, // Contains Uniform Block Index and QNodeId of the ShaderData (UBO) void ShaderParameterPack::setUniformBuffer(BlockToUBO blockToUBO) { - m_uniformBuffers.push_back(std::move(blockToUBO)); + const auto uEnd = m_uniformBuffers.end(); + auto it = std::find_if(m_uniformBuffers.begin(), uEnd, [&] (const BlockToUBO &block) { + return blockToUBO.m_blockIndex == block.m_blockIndex; + }); + + if (it == uEnd) + m_uniformBuffers.push_back(std::move(blockToUBO)); + else + *it = std::move(blockToUBO); } void ShaderParameterPack::setShaderStorageBuffer(BlockToSSBO blockToSSBO) { - m_shaderStorageBuffers.push_back(std::move(blockToSSBO)); + const auto uEnd = m_shaderStorageBuffers.end(); + auto it = std::find_if(m_shaderStorageBuffers.begin(), uEnd, [&] (const BlockToSSBO &block) { + return blockToSSBO.m_blockIndex == block.m_blockIndex; + }); + + if (it == uEnd) + m_shaderStorageBuffers.push_back(std::move(blockToSSBO)); + else + *it = std::move(blockToSSBO); } void ShaderParameterPack::setSubmissionUniformIndex(const int uniformIdx) |