diff options
author | Jean-Michaƫl Celerier <jean-michael.celerier@kdab.com> | 2020-04-24 15:41:56 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2020-05-27 15:31:41 +0200 |
commit | 9d9305184ea0b19809baac844ae32bf9323d19d2 (patch) | |
tree | 61df2db25347adaf21c10c59b478807440ebf6e7 /src/plugins/renderers/opengl/graphicshelpers | |
parent | d52cba5b86cdfc5077a0ee1cc7cf868cb4d6cd87 (diff) |
Reduce uniform copies
Change-Id: I322e97d9d0da185a98ced5e782a801b3474a892a
Reviewed-by: Mike Krus <mike.krus@kdab.com>
(cherry picked from commit 897b6cd5de7042edcdaf610f80d97d2b422c73c2)
Diffstat (limited to 'src/plugins/renderers/opengl/graphicshelpers')
-rw-r--r-- | src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp index 95f4758ba..34f31f23f 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp @@ -1270,21 +1270,20 @@ bool SubmissionContext::setParameters(ShaderParameterPack ¶meterPack, GLShad } // Update uniforms in the Default Uniform Block - const PackUniformHash values = parameterPack.uniforms(); - const QVector<int> &activeUniformsIndices = parameterPack.submissionUniformIndices(); + const PackUniformHash& values = parameterPack.uniforms(); + const auto &activeUniformsIndices = parameterPack.submissionUniformIndices(); const QVector<ShaderUniform> &shaderUniforms = shader->uniforms(); for (const int shaderUniformIndex : activeUniformsIndices) { const ShaderUniform &uniform = shaderUniforms[shaderUniformIndex]; - const UniformValue &v = values.value(uniform.m_nameId); + values.apply(uniform.m_nameId, [&] (const UniformValue& v) { + // skip invalid textures/images + if (!((v.valueType() == UniformValue::TextureValue || + v.valueType() == UniformValue::ShaderImageValue) && + *v.constData<int>() == -1)) + applyUniform(uniform, v); + }); - // skip invalid textures/images - if ((v.valueType() == UniformValue::TextureValue || - v.valueType() == UniformValue::ShaderImageValue) && - *v.constData<int>() == -1) - continue; - - applyUniform(uniform, v); } // if not all data is valid, the next frame will be rendered immediately return true; |