summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Persano <mauro.persano@kdab.com>2021-05-03 10:20:47 -0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-04 17:10:57 +0000
commit4d73bf1cb5a95b9a79c2fcc2e624ce9899ff2c71 (patch)
tree0f515fa272e534a1e3c0ab7107c83297333e97f6
parentb21d0f4b543a9f2e3dab7f60e058a53042ddc8f6 (diff)
QShaderNode: use rule with highest version number
Pick the supported rule with highest version number. For instance, if we're looking for a rule for OpenGL ES 3.2, and there's a rule for ES 2.0 and another one for ES 3.0, make sure the rule for ES 3 is selected. Change-Id: Ie517206948bc0422f6254472de43cda4dd2ce982 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> (cherry picked from commit e5276cd4cdc6b7b2e37c14e6983eaf4ce31b5a1c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/render/shadergraph/qshadernode.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/render/shadergraph/qshadernode.cpp b/src/render/shadergraph/qshadernode.cpp
index aa4a101c2..b95a77b04 100644
--- a/src/render/shadergraph/qshadernode.cpp
+++ b/src/render/shadergraph/qshadernode.cpp
@@ -152,11 +152,14 @@ QList<QShaderFormat> QShaderNode::availableFormats() const
QShaderNode::Rule QShaderNode::rule(const QShaderFormat &format) const
{
- const auto it = std::find_if(m_rules.crbegin(), m_rules.crend(),
- [format](const QPair<QShaderFormat, Rule> &entry) {
- return format.supports(entry.first);
- });
- return it != m_rules.crend() ? it->second : Rule();
+ const QPair<QShaderFormat, Rule> *selected = nullptr;
+ for (const auto &entry : qAsConst(m_rules)) {
+ if (format.supports(entry.first)) {
+ if (!selected || entry.first.version() > selected->first.version())
+ selected = &entry;
+ }
+ }
+ return selected ? selected->second : Rule();
}
QShaderNode::Rule::Rule(const QByteArray &subs, const QByteArrayList &snippets) noexcept