diff options
author | Nicolas Guichard <nicolas.guichard@kdab.com> | 2020-04-24 14:11:17 +0200 |
---|---|---|
committer | Nicolas Guichard <nicolas.guichard@kdab.com> | 2020-04-27 09:36:50 +0200 |
commit | 5e16aa067ac6a8b5f031ffcefc356777a0da34ad (patch) | |
tree | cdde252171520a8f11452cf05d78b8f45b9c8e5a /tests | |
parent | 36ef85341aacd225839d58880d3f388f31e3100c (diff) |
QShaderGraph: disable edges connected to disabled nodesv5.15.0-rc2v5.15.0-rc1v5.15.0
This graph failed to generate statements with enabledLayers = {"0"}:
_edge0i__ function0 __edge0o__
/ \
input output
\_edge1i__ function1 __edge1o__/
with function0 and edge0o on layer "0" only
and function1 and edge1o on layer "1" only
and all other nodes and edges on all layers.
The issue was that when only layer "0" is enabled, edge1i didn't get
properly discarded and Kahn's algorithm didn't ever schedule input.
Task-number: QTBUG-83766
Change-Id: Idb8705d487c3748153e0c4b3330b9589e827139e
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/render/shadergraph/qshadergraph/tst_qshadergraph.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/render/shadergraph/qshadergraph/tst_qshadergraph.cpp b/tests/auto/render/shadergraph/qshadergraph/tst_qshadergraph.cpp index 6336763f5..e21b57577 100644 --- a/tests/auto/render/shadergraph/qshadergraph/tst_qshadergraph.cpp +++ b/tests/auto/render/shadergraph/qshadergraph/tst_qshadergraph.cpp @@ -116,6 +116,7 @@ private slots: void shouldDealWithEdgesJumpingOverLayers(); void shouldGenerateDifferentStatementsDependingOnActiveLayers(); void shouldDealWithBranchesWithoutOutput(); + void shouldDiscardEdgesConnectedToDiscardedNodes(); }; void tst_QShaderGraph::shouldHaveEdgeDefaultState() @@ -816,6 +817,49 @@ void tst_QShaderGraph::shouldDealWithBranchesWithoutOutput() QCOMPARE(statements, expected); } +void tst_QShaderGraph::shouldDiscardEdgesConnectedToDiscardedNodes() +{ + // GIVEN + const auto input = createNode({ + createPort(QShaderNodePort::Output, "input") + }); + const auto output = createNode({ + createPort(QShaderNodePort::Input, "output") + }); + const auto function0 = createNode({ + createPort(QShaderNodePort::Input, "function0Input"), + createPort(QShaderNodePort::Output, "function0Output") + }, {"0"}); + const auto function1 = createNode({ + createPort(QShaderNodePort::Input, "function1Input"), + createPort(QShaderNodePort::Output, "function1Output") + }, {"1"}); + + const auto graph = [=] { + auto res = QShaderGraph(); + res.addNode(input); + res.addNode(function0); + res.addNode(function1); + res.addNode(output); + res.addEdge(createEdge(input.uuid(), "input", function0.uuid(), "function0Input", {"0"})); + res.addEdge(createEdge(input.uuid(), "input", function1.uuid(), "function1Input")); + res.addEdge(createEdge(function0.uuid(), "function0Output", output.uuid(), "output")); + res.addEdge(createEdge(function1.uuid(), "function1Output", output.uuid(), "output")); + return res; + }(); + + // WHEN + const auto statements = graph.createStatements({"0"}); + + // THEN + const auto expected = QVector<QShaderGraph::Statement>() + << createStatement(input, {}, {0}) + << createStatement(function0, {0}, {1}) + << createStatement(output, {1}, {}); + dumpStatementsIfNeeded(statements, expected); + QCOMPARE(statements, expected); +} + QTEST_MAIN(tst_QShaderGraph) #include "tst_qshadergraph.moc" |