diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-11-07 08:26:57 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-12-20 11:58:14 +0100 |
commit | b7873ef58825993f7b820ec78842d0e5bbd7a8a5 (patch) | |
tree | 4d1553961c83e2fc54d4835274dd879b44731f5e /src | |
parent | 390982e5d62b76528ce345dfcac7325abc839935 (diff) |
QSortPolicy: add Uniform sorting mode
We used to perform uniform minization between adjacent render commands all the time.
Since this can yield to a higher CPU usages (but more efficient rendering submission),
we now make this step optional.
[ChangeLog] QSortPolicy add Uniform mode (to control whether uniform minization
should be performed)
Change-Id: I5c0e0dba22400a9884ee1d75426fd76b073fdcb5
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/render/framegraph/qsortpolicy.cpp | 7 | ||||
-rw-r--r-- | src/render/framegraph/qsortpolicy.h | 1 | ||||
-rw-r--r-- | src/render/renderers/opengl/renderer/renderview.cpp | 8 |
3 files changed, 14 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(); |