diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-01-07 15:26:53 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-01-12 20:37:20 +0100 |
commit | bfc713530a6354ce786d3f9bd0f4567844e7240f (patch) | |
tree | 5e760c6b936974046802f056c0dae1c71b987863 /src/gui/rhi/qrhigles2.cpp | |
parent | 9d15854138b72be25f4584144eee8f4c0bf8117a (diff) | |
download | qtbase-bfc713530a6354ce786d3f9bd0f4567844e7240f.tar.gz |
rhi: Add queries for vertex input/output limits
Mainly because we do have legacy code in the Qt 5 graphical effects that
tries to dynamically determine the max number of varyings. Make it
easier to port such code.
Change-Id: I846cab2c2fe7b4cd473b5ced0146ca36f1c8169b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhigles2.cpp')
-rw-r--r-- | src/gui/rhi/qrhigles2.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index b698ee369b..3cbda98e04 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -430,6 +430,18 @@ QT_BEGIN_NAMESPACE #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #endif +#ifndef GL_MAX_VARYING_COMPONENTS +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#endif + +#ifndef GL_MAX_VARYING_FLOATS +#define GL_MAX_VARYING_FLOATS 0x8B4B +#endif + +#ifndef GL_MAX_VARYING_VECTORS +#define GL_MAX_VARYING_VECTORS 0x8DFC +#endif + /*! Constructs a new QRhiGles2InitParams. @@ -849,6 +861,23 @@ bool QRhiGles2::create(QRhi::Flags flags) caps.maxUniformVectors = qMin(maxVertexUniformComponents, maxFragmentUniformComponents) / 4; } + f->glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &caps.maxVertexInputs); + + if (caps.gles) { + f->glGetIntegerv(GL_MAX_VARYING_VECTORS, &caps.maxVertexOutputs); + } else if (caps.ctxMajor >= 3) { + GLint components = 0; + f->glGetIntegerv(GL_MAX_VARYING_COMPONENTS, &components); + caps.maxVertexOutputs = components / 4; + } else { + // OpenGL before 3.0 only has this, and not the same as + // MAX_VARYING_COMPONENTS strictly speaking, but will do. + GLint components = 0; + f->glGetIntegerv(GL_MAX_VARYING_FLOATS, &components); + if (components > 0) + caps.maxVertexOutputs = components / 4; + } + if (!caps.gles) { f->glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); f->glEnable(GL_POINT_SPRITE); @@ -1239,6 +1268,10 @@ int QRhiGles2::resourceLimit(QRhi::ResourceLimit limit) const return 2048; case QRhi::MaxUniformBufferRange: return int(qMin<qint64>(INT_MAX, caps.maxUniformVectors * qint64(16))); + case QRhi::MaxVertexInputs: + return caps.maxVertexInputs; + case QRhi::MaxVertexOutputs: + return caps.maxVertexOutputs; default: Q_UNREACHABLE(); return 0; |