QRhiGles2: replace two QSet<int> with QDuplicateTracker
Apart from a more fitting, minimal, API, QDuplicateTracker also transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or at least reduce, memory allocations. Pick-to: 6.3 Change-Id: Ied2574734949b2dadc1bcbaa9d1e3c0ed98ba50a Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
208cfad9ad
commit
9ab44777d6
@ -4354,7 +4354,7 @@ void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable
|
||||
int binding,
|
||||
int baseOffset,
|
||||
GLuint program,
|
||||
QSet<int> *activeUniformLocations,
|
||||
QDuplicateTracker<int, 256> *activeUniformLocations,
|
||||
QGles2UniformDescriptionVector *dst)
|
||||
{
|
||||
if (var.type == QShaderDescription::Struct) {
|
||||
@ -4371,8 +4371,7 @@ void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable
|
||||
// that is not the case, it won't break anything, but we'll generate
|
||||
// unnecessary glUniform* calls then.
|
||||
uniform.glslLocation = f->glGetUniformLocation(program, name.constData());
|
||||
if (uniform.glslLocation >= 0 && !activeUniformLocations->contains(uniform.glslLocation)) {
|
||||
activeUniformLocations->insert(uniform.glslLocation);
|
||||
if (uniform.glslLocation >= 0 && !activeUniformLocations->hasSeen(uniform.glslLocation)) {
|
||||
if (var.arrayDims.count() > 1) {
|
||||
qWarning("Array '%s' has more than one dimension. This is not supported.",
|
||||
var.name.constData());
|
||||
@ -4388,7 +4387,7 @@ void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable
|
||||
|
||||
void QRhiGles2::gatherUniforms(GLuint program,
|
||||
const QShaderDescription::UniformBlock &ub,
|
||||
QSet<int> *activeUniformLocations,
|
||||
QDuplicateTracker<int, 256> *activeUniformLocations,
|
||||
QGles2UniformDescriptionVector *dst)
|
||||
{
|
||||
QByteArray prefix = ub.structName + '.';
|
||||
@ -5517,7 +5516,7 @@ bool QGles2GraphicsPipeline::create()
|
||||
// Use the same work area for the vertex & fragment stages, thus ensuring
|
||||
// that we will not do superfluous glUniform calls for uniforms that are
|
||||
// present in both shaders.
|
||||
QSet<int> activeUniformLocations;
|
||||
QDuplicateTracker<int, 256> activeUniformLocations;
|
||||
|
||||
for (const QRhiShaderStage &shaderStage : qAsConst(m_shaderStages)) {
|
||||
if (isGraphicsStage(shaderStage)) {
|
||||
@ -5628,7 +5627,7 @@ bool QGles2ComputePipeline::create()
|
||||
}
|
||||
}
|
||||
|
||||
QSet<int> activeUniformLocations;
|
||||
QDuplicateTracker<int, 256> activeUniformLocations;
|
||||
for (const QShaderDescription::UniformBlock &ub : csDesc.uniformBlocks())
|
||||
rhiD->gatherUniforms(program, ub, &activeUniformLocations, &uniforms);
|
||||
for (const QShaderDescription::InOutVariable &v : csDesc.combinedImageSamplers())
|
||||
|
@ -58,6 +58,8 @@
|
||||
#include <QByteArray>
|
||||
#include <QSurface>
|
||||
|
||||
#include <QtCore/private/qduplicatetracker_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QOpenGLExtensions;
|
||||
@ -882,10 +884,10 @@ public:
|
||||
void registerUniformIfActive(const QShaderDescription::BlockVariable &var,
|
||||
const QByteArray &namePrefix, int binding, int baseOffset,
|
||||
GLuint program,
|
||||
QSet<int> *activeUniformLocations,
|
||||
QDuplicateTracker<int, 256> *activeUniformLocations,
|
||||
QGles2UniformDescriptionVector *dst);
|
||||
void gatherUniforms(GLuint program, const QShaderDescription::UniformBlock &ub,
|
||||
QSet<int> *activeUniformLocations, QGles2UniformDescriptionVector *dst);
|
||||
QDuplicateTracker<int, 256> *activeUniformLocations, QGles2UniformDescriptionVector *dst);
|
||||
void gatherSamplers(GLuint program, const QShaderDescription::InOutVariable &v,
|
||||
QGles2SamplerDescriptionVector *dst);
|
||||
void gatherGeneratedSamplers(GLuint program,
|
||||
|
Loading…
x
Reference in New Issue
Block a user