summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/rhi/qshader/tst_qshader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/rhi/qshader/tst_qshader.cpp')
-rw-r--r--tests/auto/gui/rhi/qshader/tst_qshader.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/tests/auto/gui/rhi/qshader/tst_qshader.cpp b/tests/auto/gui/rhi/qshader/tst_qshader.cpp
index cd883b34d9..912101a839 100644
--- a/tests/auto/gui/rhi/qshader/tst_qshader.cpp
+++ b/tests/auto/gui/rhi/qshader/tst_qshader.cpp
@@ -18,12 +18,14 @@ private slots:
void genVariants();
void shaderDescImplicitSharing();
void bakedShaderImplicitSharing();
+ void sortedKeys();
void mslResourceMapping();
void serializeShaderDesc();
void comparison();
void loadV4();
void manualShaderPackCreation();
void loadV6WithSeparateImagesAndSamplers();
+ void loadV7();
};
static QShader getShader(const QString &name)
@@ -238,6 +240,16 @@ void tst_QShader::bakedShaderImplicitSharing()
}
}
+void tst_QShader::sortedKeys()
+{
+ QShader s = getShader(QLatin1String(":/data/texture_all_v4.frag.qsb"));
+ QVERIFY(s.isValid());
+ QList<QShaderKey> availableShaders = s.availableShaders();
+ QCOMPARE(availableShaders.count(), 7);
+ std::sort(availableShaders.begin(), availableShaders.end());
+ QCOMPARE(availableShaders, s.availableShaders());
+}
+
void tst_QShader::mslResourceMapping()
{
QShader s = getShader(QLatin1String(":/data/texture_all_v4.frag.qsb"));
@@ -579,5 +591,87 @@ void tst_QShader::loadV6WithSeparateImagesAndSamplers()
}
}
+void tst_QShader::loadV7()
+{
+ QShader vert = getShader(QLatin1String(":/data/metal_enabled_tessellation_v7.vert.qsb"));
+ QVERIFY(vert.isValid());
+ QCOMPARE(QShaderPrivate::get(&vert)->qsbVersion, 7);
+ QCOMPARE(vert.availableShaders().count(), 8);
+
+ QCOMPARE(vert.description().inputVariables().count(), 2);
+ QCOMPARE(vert.description().outputBuiltinVariables().count(), 1);
+ QCOMPARE(vert.description().outputBuiltinVariables()[0].type, QShaderDescription::PositionBuiltin);
+ QCOMPARE(vert.description().outputVariables().count(), 1);
+ QCOMPARE(vert.description().outputVariables()[0].name, QByteArrayLiteral("v_color"));
+
+ QVERIFY(vert.availableShaders().contains(QShaderKey(QShader::MslShader, QShaderVersion(12))));
+ QVERIFY(!vert.shader(QShaderKey(QShader::MslShader, QShaderVersion(12), QShader::NonIndexedVertexAsComputeShader)).shader().isEmpty());
+ QVERIFY(!vert.shader(QShaderKey(QShader::MslShader, QShaderVersion(12), QShader::UInt16IndexedVertexAsComputeShader)).shader().isEmpty());
+ QVERIFY(!vert.shader(QShaderKey(QShader::MslShader, QShaderVersion(12), QShader::UInt32IndexedVertexAsComputeShader)).shader().isEmpty());
+
+ QShader tesc = getShader(QLatin1String(":/data/metal_enabled_tessellation_v7.tesc.qsb"));
+ QVERIFY(tesc.isValid());
+ QCOMPARE(QShaderPrivate::get(&tesc)->qsbVersion, 7);
+ QCOMPARE(tesc.availableShaders().count(), 5);
+ QCOMPARE(tesc.description().tessellationOutputVertexCount(), 3u);
+
+ QCOMPARE(tesc.description().inputBuiltinVariables().count(), 2);
+ QCOMPARE(tesc.description().outputBuiltinVariables().count(), 3);
+ // builtins must be sorted based on the type
+ QCOMPARE(tesc.description().inputBuiltinVariables()[0].type, QShaderDescription::PositionBuiltin);
+ QCOMPARE(tesc.description().inputBuiltinVariables()[1].type, QShaderDescription::InvocationIdBuiltin);
+ QCOMPARE(tesc.description().outputBuiltinVariables()[0].type, QShaderDescription::PositionBuiltin);
+ QCOMPARE(tesc.description().outputBuiltinVariables()[1].type, QShaderDescription::TessLevelOuterBuiltin);
+ QCOMPARE(tesc.description().outputBuiltinVariables()[2].type, QShaderDescription::TessLevelInnerBuiltin);
+
+ QCOMPARE(tesc.description().outputVariables().count(), 3);
+ for (const QShaderDescription::InOutVariable &v : tesc.description().outputVariables()) {
+ switch (v.location) {
+ case 0:
+ QCOMPARE(v.name, QByteArrayLiteral("outColor"));
+ QCOMPARE(v.type, QShaderDescription::Vec3);
+ QCOMPARE(v.perPatch, false);
+ break;
+ case 1:
+ QCOMPARE(v.name, QByteArrayLiteral("stuff"));
+ QCOMPARE(v.type, QShaderDescription::Vec3);
+ QCOMPARE(v.perPatch, true);
+ break;
+ case 2:
+ QCOMPARE(v.name, QByteArrayLiteral("more_stuff"));
+ QCOMPARE(v.type, QShaderDescription::Float);
+ QCOMPARE(v.perPatch, true);
+ break;
+ default:
+ QFAIL(qPrintable(QStringLiteral("Bad location: %1").arg(v.location)));
+ break;
+ }
+ }
+
+ QVERIFY(!tesc.shader(QShaderKey(QShader::MslShader, QShaderVersion(12))).shader().isEmpty());
+ QCOMPARE(tesc.nativeShaderInfo(QShaderKey(QShader::SpirvShader, QShaderVersion(100))).extraBufferBindings.count(), 0);
+ QCOMPARE(tesc.nativeShaderInfo(QShaderKey(QShader::MslShader, QShaderVersion(12))).extraBufferBindings.count(), 5);
+
+ QShader tese = getShader(QLatin1String(":/data/metal_enabled_tessellation_v7.tese.qsb"));
+ QVERIFY(tese.isValid());
+ QCOMPARE(QShaderPrivate::get(&tese)->qsbVersion, 7);
+ QCOMPARE(tese.availableShaders().count(), 5);
+ QCOMPARE(tese.description().tessellationMode(), QShaderDescription::TrianglesTessellationMode);
+ QCOMPARE(tese.description().tessellationWindingOrder(), QShaderDescription::CcwTessellationWindingOrder);
+ QCOMPARE(tese.description().tessellationPartitioning(), QShaderDescription::FractionalOddTessellationPartitioning);
+
+ QCOMPARE(tese.description().inputBuiltinVariables()[0].type, QShaderDescription::PositionBuiltin);
+ QCOMPARE(tese.description().inputBuiltinVariables()[1].type, QShaderDescription::TessLevelOuterBuiltin);
+ QCOMPARE(tese.description().inputBuiltinVariables()[2].type, QShaderDescription::TessLevelInnerBuiltin);
+ QCOMPARE(tese.description().inputBuiltinVariables()[3].type, QShaderDescription::TessCoordBuiltin);
+
+ QCOMPARE(tese.nativeResourceBindingMap(QShaderKey(QShader::MslShader, QShaderVersion(12))).count(), 1);
+ QCOMPARE(tese.nativeResourceBindingMap(QShaderKey(QShader::MslShader, QShaderVersion(12))).value(0), qMakePair(0, -1));
+
+ QShader frag = getShader(QLatin1String(":/data/metal_enabled_tessellation_v7.frag.qsb"));
+ QVERIFY(frag.isValid());
+ QCOMPARE(QShaderPrivate::get(&frag)->qsbVersion, 7);
+}
+
#include <tst_qshader.moc>
QTEST_MAIN(tst_QShader)