diff options
author | Volker Krause <volker.krause@kdab.com> | 2016-01-06 13:38:27 +0100 |
---|---|---|
committer | Volker Krause <volker.krause@kdab.com> | 2016-01-06 18:05:14 +0000 |
commit | ba2c6593ae21326565bf40723148ee29eff22802 (patch) | |
tree | b4a9f8c8fab0bc0216f719b48806cab645f38daa | |
parent | 45902994198374a02f7c127120d8980a66796fb6 (diff) |
Avoid expensive multiple QString::arg usage on this hot path.
The string operations in here are still one of the largest contributors
to per-frame allocations, but at least this spot is now down to three
allocations per frame and per light.
Change-Id: Ieab3b882c87e8fa8d4d4dedb46a3a482ebb07d6f
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/render/backend/renderview.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp index e630e7a8b..36ad2a33c 100644 --- a/src/render/backend/renderview.cpp +++ b/src/render/backend/renderview.cpp @@ -764,9 +764,8 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, RenderPass *rPass, } // Lights - const QString LIGHT_ARRAY_NAME = QStringLiteral("lights"); const QString LIGHT_COUNT_NAME = QStringLiteral("lightCount"); - const QString LIGHT_POSITION_NAME = QStringLiteral("position"); + const QString LIGHT_POSITION_NAME = QStringLiteral(".position"); int lightIdx = 0; Q_FOREACH (const LightSource &lightSource, activeLightSources) { @@ -777,8 +776,8 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, RenderPass *rPass, Q_FOREACH (Light *light, lightSource.lights) { if (lightIdx == MAX_LIGHTS) break; - QString structName = QString(QStringLiteral("%1[%2]")).arg(LIGHT_ARRAY_NAME).arg(lightIdx); - setUniformValue(command->m_uniforms, structName + QLatin1Char('.') + LIGHT_POSITION_NAME, worldPos); + const QString structName = QStringLiteral("lights[") + QString::number(lightIdx) + QLatin1Char(']'); + setUniformValue(command->m_uniforms, structName + LIGHT_POSITION_NAME, worldPos); setDefaultUniformBlockShaderDataValue(command->m_uniforms, shader, light, structName); ++lightIdx; } |