summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhigles2.cpp
diff options
context:
space:
mode:
authorJonas Karlsson <jonas.karlsson@qt.io>2020-05-27 12:34:29 +0200
committerJonas Karlsson <jonas.karlsson@qt.io>2020-06-03 18:56:21 +0200
commit1b33ee95e5c6e5e27f732fd273920861fdae486a (patch)
treef8e77cab65d4d32df4f65ee155e01b75e5993598 /src/gui/rhi/qrhigles2.cpp
parent1f88ccc8ad64096209cdf7874af129f4220b00ba (diff)
Use QByteArray instead of QString
Since the variable names in QShaderDescription are later compared to QByteArrays we can gain some performance from not having to convert them to QByteArrays later. Task-Id: QTBUG-83706 Change-Id: Iaf80d0966f45cbb09e7c1000b7854bc488e57bb3 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhigles2.cpp')
-rw-r--r--src/gui/rhi/qrhigles2.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index b59e6d98b1..ebe66f302b 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -3378,17 +3378,17 @@ void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable
{
if (var.type == QShaderDescription::Struct) {
qWarning("Nested structs are not supported at the moment. '%s' ignored.",
- qPrintable(var.name));
+ var.name.constData());
return;
}
QGles2UniformDescription uniform;
uniform.type = var.type;
- const QByteArray name = namePrefix + var.name.toUtf8();
+ const QByteArray name = namePrefix + var.name;
uniform.glslLocation = f->glGetUniformLocation(program, name.constData());
if (uniform.glslLocation >= 0) {
if (var.arrayDims.count() > 1) {
qWarning("Array '%s' has more than one dimension. This is not supported.",
- qPrintable(var.name));
+ var.name.constData());
return;
}
uniform.binding = binding;
@@ -3403,10 +3403,10 @@ void QRhiGles2::gatherUniforms(GLuint program,
const QShaderDescription::UniformBlock &ub,
QVector<QGles2UniformDescription> *dst)
{
- QByteArray prefix = ub.structName.toUtf8() + '.';
+ QByteArray prefix = ub.structName + '.';
for (const QShaderDescription::BlockVariable &blockMember : ub.members) {
if (blockMember.type == QShaderDescription::Struct) {
- QByteArray structPrefix = prefix + blockMember.name.toUtf8();
+ QByteArray structPrefix = prefix + blockMember.name;
const int baseOffset = blockMember.offset;
if (blockMember.arrayDims.isEmpty()) {
@@ -3414,8 +3414,9 @@ void QRhiGles2::gatherUniforms(GLuint program,
registerUniformIfActive(structMember, structPrefix, ub.binding, baseOffset, program, dst);
} else {
if (blockMember.arrayDims.count() > 1) {
- qWarning("Array of struct '%s' has more than one dimension. Only the first dimension is used.",
- qPrintable(blockMember.name));
+ qWarning("Array of struct '%s' has more than one dimension. Only the first "
+ "dimension is used.",
+ blockMember.name.constData());
}
const int dim = blockMember.arrayDims.first();
const int elemSize = blockMember.size / dim;
@@ -3437,8 +3438,7 @@ void QRhiGles2::gatherSamplers(GLuint program, const QShaderDescription::InOutVa
QVector<QGles2SamplerDescription> *dst)
{
QGles2SamplerDescription sampler;
- const QByteArray name = v.name.toUtf8();
- sampler.glslLocation = f->glGetUniformLocation(program, name.constData());
+ sampler.glslLocation = f->glGetUniformLocation(program, v.name.constData());
if (sampler.glslLocation >= 0) {
sampler.binding = v.binding;
dst->append(sampler);
@@ -4202,8 +4202,7 @@ bool QGles2GraphicsPipeline::create()
}
for (auto inVar : vsDesc.inputVariables()) {
- const QByteArray name = inVar.name.toUtf8();
- rhiD->f->glBindAttribLocation(program, GLuint(inVar.location), name.constData());
+ rhiD->f->glBindAttribLocation(program, GLuint(inVar.location), inVar.name);
}
if (needsCompile && !rhiD->linkProgram(program))