summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhigles2_p_p.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-09-30 21:15:14 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-10-02 13:14:27 +0200
commitb1101fce301e83fe5dcac3c735959378789a8d16 (patch)
treef0e039b43e85010ed17b9ec713d5ea31acae422f /src/gui/rhi/qrhigles2_p_p.h
parent387a61adfb2c4e0ea2fd1c17f00c783e4bb6d3a0 (diff)
rhi: gl: Best uniform is no uniform
Artificial tests with tens of thousands of meshes drawn with the same program (graphics pipeline) and almost the same uniform values (the difference being in the normal and model and view matrices) do benefit - strongly depending on the GL implementation probably - from doing fewer glUniformNf[v] calls. Building on the fact that uniform location values will typically be an int value starting at 0 (not guaranteed of course, we just skip the smartness in that case), we can dedicate a small 16K block to keep track of float/vec3/vec3/vec4 values in the graphics and compute pipeline objects. Change-Id: I217c31ccdeb511b3e8b8286078d7fbde399c8e3b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhigles2_p_p.h')
-rw-r--r--src/gui/rhi/qrhigles2_p_p.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h
index 95bf85f0b4..07e0466b30 100644
--- a/src/gui/rhi/qrhigles2_p_p.h
+++ b/src/gui/rhi/qrhigles2_p_p.h
@@ -269,6 +269,13 @@ Q_DECLARE_TYPEINFO(QGles2SamplerDescription, Q_MOVABLE_TYPE);
using QGles2UniformDescriptionVector = QVarLengthArray<QGles2UniformDescription, 8>;
using QGles2SamplerDescriptionVector = QVarLengthArray<QGles2SamplerDescription, 4>;
+struct QGles2UniformState
+{
+ static constexpr int MAX_TRACKED_LOCATION = 1023;
+ int componentCount;
+ float v[4];
+};
+
struct QGles2GraphicsPipeline : public QRhiGraphicsPipeline
{
QGles2GraphicsPipeline(QRhiImplementation *rhi);
@@ -280,6 +287,7 @@ struct QGles2GraphicsPipeline : public QRhiGraphicsPipeline
GLenum drawMode = GL_TRIANGLES;
QGles2UniformDescriptionVector uniforms;
QGles2SamplerDescriptionVector samplers;
+ QGles2UniformState uniformState[QGles2UniformState::MAX_TRACKED_LOCATION + 1];
uint generation = 0;
friend class QRhiGles2;
};
@@ -294,6 +302,7 @@ struct QGles2ComputePipeline : public QRhiComputePipeline
GLuint program = 0;
QGles2UniformDescriptionVector uniforms;
QGles2SamplerDescriptionVector samplers;
+ QGles2UniformState uniformState[QGles2UniformState::MAX_TRACKED_LOCATION + 1];
uint generation = 0;
friend class QRhiGles2;
};