diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-11-08 10:28:54 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-11-13 07:32:32 +0100 |
commit | 53a780960aa5245eb3e534e6bd0c268c050c52fa (patch) | |
tree | 37877a9cc69a906c3496807c40d4a709397f1f22 | |
parent | 714731b0e8bc34ebd5873c8818830a8ee89045d5 (diff) |
Uniform: use QVarLengthArray<16 ,float> instead of <4, float>
This otherwise yield for lots of reallocations that could be avoided.
The gains seem to be about 2/3% of cpu usage according the analysis
with vTune.
It does indeed mean that for smaller uniforms vec4, float, sampler
we are wasting a bit of memory. The impact of this is likely to be
unsignificant though.
Change-Id: Id72c81a795bf9326ef48b170bb0806de9b430412
Reviewed-by: Mike Krus <mike.krus@kdab.com>
-rw-r--r-- | src/render/backend/uniform_p.h | 2 | ||||
-rw-r--r-- | tests/auto/render/uniform/tst_uniform.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/render/backend/uniform_p.h b/src/render/backend/uniform_p.h index 09575a077..634c0cd96 100644 --- a/src/render/backend/uniform_p.h +++ b/src/render/backend/uniform_p.h @@ -229,7 +229,7 @@ public: private: // Allocate 4 floats on stack // For larger elements, heap allocation will be used - QVarLengthArray<float, 4> m_data; + QVarLengthArray<float, 16> m_data; ValueType m_valueType = ScalarValue; diff --git a/tests/auto/render/uniform/tst_uniform.cpp b/tests/auto/render/uniform/tst_uniform.cpp index 5f946afa3..d7775eb62 100644 --- a/tests/auto/render/uniform/tst_uniform.cpp +++ b/tests/auto/render/uniform/tst_uniform.cpp @@ -112,7 +112,7 @@ private Q_SLOTS: QCOMPARE(v.constData<float>()[0], 572.0f); QCOMPARE(v.constData<float>()[1], 355.0f); QCOMPARE(v.constData<float>()[2], 383.0f); - QCOMPARE(v.constData<float>()[4], 0.0f); + QCOMPARE(v.constData<float>()[3], 0.0f); } { // GIVEN |