summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-05-01 15:07:12 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-05-05 11:34:39 +0200
commita206f52acd175800688b9f4cce8e56df2632dab2 (patch)
tree97dc1a9f690d38a857560c1a3f0ea26f2a152228
parent616000ed7f1b2e60d8766c36eab5b86c9c8e6ee3 (diff)
Hotfix for int->qsizetype fallout in QShader
The proper solution is to use qint32 everywhere, but that is left as a separate exercise. Change-Id: Id0c06b102b56a1b3b48dd67c6c29c28da7d1f22d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
-rw-r--r--src/gui/rhi/qshader.cpp6
-rw-r--r--src/gui/rhi/qshaderdescription.cpp26
-rw-r--r--tests/auto/gui/rhi/qshader/tst_qshader.cpp17
3 files changed, 33 insertions, 16 deletions
diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp
index b5c1aca8be..18d0fdef05 100644
--- a/src/gui/rhi/qshader.cpp
+++ b/src/gui/rhi/qshader.cpp
@@ -368,7 +368,7 @@ QByteArray QShader::serialized() const
ds << QShaderPrivate::QSB_VERSION;
ds << int(d->stage);
d->desc.serialize(&ds);
- ds << d->shaders.count();
+ ds << int(d->shaders.count());
for (auto it = d->shaders.cbegin(), itEnd = d->shaders.cend(); it != itEnd; ++it) {
const QShaderKey &k(it.key());
writeShaderKey(&ds, k);
@@ -376,12 +376,12 @@ QByteArray QShader::serialized() const
ds << shader.shader();
ds << shader.entryPoint();
}
- ds << d->bindings.count();
+ ds << int(d->bindings.count());
for (auto it = d->bindings.cbegin(), itEnd = d->bindings.cend(); it != itEnd; ++it) {
const QShaderKey &k(it.key());
writeShaderKey(&ds, k);
const NativeResourceBindingMap &map(it.value());
- ds << map.count();
+ ds << int(map.count());
for (auto mapIt = map.cbegin(), mapItEnd = map.cend(); mapIt != mapItEnd; ++mapIt) {
ds << mapIt.key();
ds << mapIt.value().first;
diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp
index f3ef5edd12..bd8676c57c 100644
--- a/src/gui/rhi/qshaderdescription.cpp
+++ b/src/gui/rhi/qshaderdescription.cpp
@@ -896,7 +896,7 @@ static void serializeDecorations(QDataStream *stream, const QShaderDescription::
(*stream) << v.descriptorSet;
(*stream) << int(v.imageFormat);
(*stream) << int(v.imageFlags);
- (*stream) << v.arrayDims.count();
+ (*stream) << int(v.arrayDims.count());
for (int dim : v.arrayDims)
(*stream) << dim;
}
@@ -951,13 +951,13 @@ static void serializeBlockMemberVar(QDataStream *stream, const QShaderDescriptio
(*stream) << int(v.type);
(*stream) << v.offset;
(*stream) << v.size;
- (*stream) << v.arrayDims.count();
+ (*stream) << int(v.arrayDims.count());
for (int dim : v.arrayDims)
(*stream) << dim;
(*stream) << v.arrayStride;
(*stream) << v.matrixStride;
(*stream) << v.matrixIsRowMajor;
- (*stream) << v.structMembers.count();
+ (*stream) << int(v.structMembers.count());
for (const QShaderDescription::BlockVariable &sv : v.structMembers)
serializeBlockMemberVar(stream, sv);
}
@@ -1062,55 +1062,55 @@ QJsonDocument QShaderDescriptionPrivate::makeDoc()
void QShaderDescriptionPrivate::writeToStream(QDataStream *stream)
{
- (*stream) << inVars.count();
+ (*stream) << int(inVars.count());
for (const QShaderDescription::InOutVariable &v : qAsConst(inVars))
serializeInOutVar(stream, v);
- (*stream) << outVars.count();
+ (*stream) << int(outVars.count());
for (const QShaderDescription::InOutVariable &v : qAsConst(outVars))
serializeInOutVar(stream, v);
- (*stream) << uniformBlocks.count();
+ (*stream) << int(uniformBlocks.count());
for (const QShaderDescription::UniformBlock &b : uniformBlocks) {
(*stream) << b.blockName;
(*stream) << b.structName;
(*stream) << b.size;
(*stream) << b.binding;
(*stream) << b.descriptorSet;
- (*stream) << b.members.count();
+ (*stream) << int(b.members.count());
for (const QShaderDescription::BlockVariable &v : b.members)
serializeBlockMemberVar(stream, v);
}
- (*stream) << pushConstantBlocks.count();
+ (*stream) << int(pushConstantBlocks.count());
for (const QShaderDescription::PushConstantBlock &b : pushConstantBlocks) {
(*stream) << b.name;
(*stream) << b.size;
- (*stream) << b.members.count();
+ (*stream) << int(b.members.count());
for (const QShaderDescription::BlockVariable &v : b.members)
serializeBlockMemberVar(stream, v);
}
- (*stream) << storageBlocks.count();
+ (*stream) << int(storageBlocks.count());
for (const QShaderDescription::StorageBlock &b : storageBlocks) {
(*stream) << b.blockName;
(*stream) << b.instanceName;
(*stream) << b.knownSize;
(*stream) << b.binding;
(*stream) << b.descriptorSet;
- (*stream) << b.members.count();
+ (*stream) << int(b.members.count());
for (const QShaderDescription::BlockVariable &v : b.members)
serializeBlockMemberVar(stream, v);
}
- (*stream) << combinedImageSamplers.count();
+ (*stream) << int(combinedImageSamplers.count());
for (const QShaderDescription::InOutVariable &v : qAsConst(combinedImageSamplers)) {
(*stream) << v.name;
(*stream) << int(v.type);
serializeDecorations(stream, v);
}
- (*stream) << storageImages.count();
+ (*stream) << int(storageImages.count());
for (const QShaderDescription::InOutVariable &v : qAsConst(storageImages)) {
(*stream) << v.name;
(*stream) << int(v.type);
diff --git a/tests/auto/gui/rhi/qshader/tst_qshader.cpp b/tests/auto/gui/rhi/qshader/tst_qshader.cpp
index 378d1e85e7..22173d6d1a 100644
--- a/tests/auto/gui/rhi/qshader/tst_qshader.cpp
+++ b/tests/auto/gui/rhi/qshader/tst_qshader.cpp
@@ -36,6 +36,7 @@ class tst_QShader : public QObject
Q_OBJECT
private slots:
+ void serializeDeserialize();
void simpleCompileCheckResults();
void genVariants();
void shaderDescImplicitSharing();
@@ -56,6 +57,22 @@ static QShader getShader(const QString &name)
return QShader();
}
+void tst_QShader::serializeDeserialize()
+{
+ QShader s = getShader(QLatin1String(":/data/texture_all_v4.frag.qsb"));
+ QVERIFY(s.isValid());
+
+ QByteArray data = s.serialized();
+ QVERIFY(!data.isEmpty());
+
+ QShader s2;
+ QVERIFY(!s2.isValid());
+ QVERIFY(s != s2);
+ s2 = QShader::fromSerialized(data);
+ QVERIFY(s2.isValid());
+ QCOMPARE(s, s2);
+}
+
void tst_QShader::simpleCompileCheckResults()
{
QShader s = getShader(QLatin1String(":/data/color_spirv_v1.vert.qsb"));