diff options
author | Michael Brasser <mbrasser@ford.com> | 2019-03-25 13:26:04 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2019-04-01 13:04:36 +0000 |
commit | f0e70c845e2095ff23ecd28f44ca84f6b5349e92 (patch) | |
tree | d2c5c8c2906192108c175081b3366627b79ab04a /tests | |
parent | e84d8d2a81eb81f9b1ea9f40d4da36d09a97b246 (diff) |
Unify shader include handling
Share the code for this between QShaderBuilder and QShaderProgram. As a
side effect QShaderProgram gains support for absolute paths.
Change-Id: I71dbe0bff702806f0655992008c54bbaa9c4f2c9
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/render/qshaderprogram/included.frag | 1 | ||||
-rw-r--r-- | tests/auto/render/qshaderprogram/main.frag | 1 | ||||
-rw-r--r-- | tests/auto/render/qshaderprogram/mainabsolute.frag | 1 | ||||
-rw-r--r-- | tests/auto/render/qshaderprogram/qshaderprogram.pro | 3 | ||||
-rw-r--r-- | tests/auto/render/qshaderprogram/shaders.qrc | 7 | ||||
-rw-r--r-- | tests/auto/render/qshaderprogram/tst_qshaderprogram.cpp | 18 |
6 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/render/qshaderprogram/included.frag b/tests/auto/render/qshaderprogram/included.frag new file mode 100644 index 000000000..0c954ed15 --- /dev/null +++ b/tests/auto/render/qshaderprogram/included.frag @@ -0,0 +1 @@ +out vec4 fragColor; diff --git a/tests/auto/render/qshaderprogram/main.frag b/tests/auto/render/qshaderprogram/main.frag new file mode 100644 index 000000000..f30bd8c45 --- /dev/null +++ b/tests/auto/render/qshaderprogram/main.frag @@ -0,0 +1 @@ +#pragma include included.frag diff --git a/tests/auto/render/qshaderprogram/mainabsolute.frag b/tests/auto/render/qshaderprogram/mainabsolute.frag new file mode 100644 index 000000000..85a013111 --- /dev/null +++ b/tests/auto/render/qshaderprogram/mainabsolute.frag @@ -0,0 +1 @@ +#pragma include :/included.frag diff --git a/tests/auto/render/qshaderprogram/qshaderprogram.pro b/tests/auto/render/qshaderprogram/qshaderprogram.pro index 6f40caee9..4ab65c455 100644 --- a/tests/auto/render/qshaderprogram/qshaderprogram.pro +++ b/tests/auto/render/qshaderprogram/qshaderprogram.pro @@ -8,5 +8,8 @@ CONFIG += testcase SOURCES += tst_qshaderprogram.cpp +RESOURCES += \ + shaders.qrc + include(../../core/common/common.pri) include(../commons/commons.pri) diff --git a/tests/auto/render/qshaderprogram/shaders.qrc b/tests/auto/render/qshaderprogram/shaders.qrc new file mode 100644 index 000000000..34a5cd22c --- /dev/null +++ b/tests/auto/render/qshaderprogram/shaders.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>included.frag</file> + <file>main.frag</file> + <file>mainabsolute.frag</file> + </qresource> +</RCC> diff --git a/tests/auto/render/qshaderprogram/tst_qshaderprogram.cpp b/tests/auto/render/qshaderprogram/tst_qshaderprogram.cpp index 901ee7349..3fcc49067 100644 --- a/tests/auto/render/qshaderprogram/tst_qshaderprogram.cpp +++ b/tests/auto/render/qshaderprogram/tst_qshaderprogram.cpp @@ -511,6 +511,24 @@ private Q_SLOTS: QCOMPARE(status(), newStatus); } + void checkIncludes() + { + // GIVEN + Qt3DRender::QShaderProgram shaderProgram; + QByteArray includedContent = shaderProgram.loadSource(QUrl(QStringLiteral("qrc:/included.frag"))); + + // WHEN (test relative include) + QByteArray mainContent = shaderProgram.loadSource(QUrl(QStringLiteral("qrc:/main.frag"))); + + // THEN + QVERIFY(mainContent.indexOf(includedContent) == 0); + + // WHEN (test absolute include) + mainContent = shaderProgram.loadSource(QUrl(QStringLiteral("qrc:/mainabsolute.frag"))); + + // THEN + QVERIFY(mainContent.indexOf(includedContent) == 0); + } }; QTEST_MAIN(tst_QShaderProgram) |