summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/render/framegraph/qsortpolicy.cpp7
-rw-r--r--src/render/framegraph/qsortpolicy.h1
-rw-r--r--src/render/renderers/opengl/renderer/renderview.cpp8
-rw-r--r--tests/auto/render/renderviews/tst_renderviews.cpp1
4 files changed, 15 insertions, 2 deletions
diff --git a/src/render/framegraph/qsortpolicy.cpp b/src/render/framegraph/qsortpolicy.cpp
index a24dd5eae..5c04025b0 100644
--- a/src/render/framegraph/qsortpolicy.cpp
+++ b/src/render/framegraph/qsortpolicy.cpp
@@ -98,12 +98,14 @@ QSortPolicyPrivate::QSortPolicyPrivate()
projection of the camera-to-object-center vector onto the camera's view
vector.
- \value Material sort the objects based on their material value
+ \value Material sort the objects based on their material (shader) value.
\value FrontToBack sort the objects from front to back. The opposite of
BackToFront.
\value [since 5.14] Texture sort the objects to minimize texture changes.
+
+ \value [since 5.15] Uniform sort the objects to minimize uniform changes.
*/
/*!
@@ -123,10 +125,11 @@ QSortPolicyPrivate::QSortPolicyPrivate()
order. More accurately, the sorting key is the z component of the
projection of the camera-to-object-center vector onto the camera's view
vector.
- \li Material - sort the objects based on their material value
+ \li Material - sort the objects based on their material (shader) value.
\li FrontToBack - sort the objects from front to back. The opposite of
BackToFront.
\li [since 5.14] Texture - sort the objects to minimize texture changes.
+ \li [since 5.15] Uniform - sort the objects to minimize uniform changes.
\endlist
*/
diff --git a/src/render/framegraph/qsortpolicy.h b/src/render/framegraph/qsortpolicy.h
index a302caa8b..f5ea988e8 100644
--- a/src/render/framegraph/qsortpolicy.h
+++ b/src/render/framegraph/qsortpolicy.h
@@ -62,6 +62,7 @@ public:
Material = (1 << 2),
FrontToBack = (1 << 3),
Texture = (1 << 4),
+ Uniform = (1 << 5)
};
Q_ENUM(SortType) // LCOV_EXCL_LINE
diff --git a/src/render/renderers/opengl/renderer/renderview.cpp b/src/render/renderers/opengl/renderer/renderview.cpp
index c00a92629..60ebc2193 100644
--- a/src/render/renderers/opengl/renderer/renderview.cpp
+++ b/src/render/renderers/opengl/renderer/renderview.cpp
@@ -467,6 +467,8 @@ int findSubRange(const QVector<RenderCommand> &commands,
return advanceUntilNonAdjacent(commands, begin, end, AdjacentSubRangeFinder<QSortPolicy::FrontToBack>::adjacentSubRange);
case QSortPolicy::Texture:
return advanceUntilNonAdjacent(commands, begin, end, AdjacentSubRangeFinder<QSortPolicy::Texture>::adjacentSubRange);
+ case QSortPolicy::Uniform:
+ return end;
default:
Q_UNREACHABLE();
return end;
@@ -513,6 +515,8 @@ void sortCommandRange(QVector<RenderCommand> &commands, int begin, const int end
case QSortPolicy::Texture:
SubRangeSorter<QSortPolicy::Texture>::sortSubRange(commands.begin() + begin, commands.begin() + end);
break;
+ case QSortPolicy::Uniform:
+ break;
default:
Q_UNREACHABLE();
}
@@ -536,6 +540,10 @@ void RenderView::sort()
// For RenderCommand with the same shader
// We compute the adjacent change cost
+ // Only perform uniform minimization if we explicitly asked for it
+ if (!m_data.m_sortingTypes.contains(QSortPolicy::Uniform))
+ return;
+
// Minimize uniform changes
int i = 0;
const int commandSize = m_commands.size();
diff --git a/tests/auto/render/renderviews/tst_renderviews.cpp b/tests/auto/render/renderviews/tst_renderviews.cpp
index 1558b68c9..086ff0220 100644
--- a/tests/auto/render/renderviews/tst_renderviews.cpp
+++ b/tests/auto/render/renderviews/tst_renderviews.cpp
@@ -253,6 +253,7 @@ private Q_SLOTS:
// WHEN
renderView.setCommands(rawCommands);
+ renderView.addSortType((QVector<QSortPolicy::SortType>() << QSortPolicy::Uniform));
renderView.sort();
// THEN