summaryrefslogtreecommitdiffstats
path: root/src/render/renderers/opengl/renderer/renderviewbuilder.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-10-17 10:03:01 +0200
committerPaul Lemire <paul.lemire@kdab.com>2019-10-29 09:13:35 +0100
commitfee0f43522483415b4af1475caaca21658f3e24a (patch)
tree7e226f37ec3685b7caed96330f98f6aa82b74e27 /src/render/renderers/opengl/renderer/renderviewbuilder.cpp
parent3c5848a923b9b9393753c654e837fc8c99bd8b23 (diff)
Convert EntityRenderCommandData to struct of vectors
Change-Id: Ib290491476b083e6aa4cff5c112a802c4e198987 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/renderers/opengl/renderer/renderviewbuilder.cpp')
-rw-r--r--src/render/renderers/opengl/renderer/renderviewbuilder.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/render/renderers/opengl/renderer/renderviewbuilder.cpp b/src/render/renderers/opengl/renderer/renderviewbuilder.cpp
index ead29ec03..40179fbd6 100644
--- a/src/render/renderers/opengl/renderer/renderviewbuilder.cpp
+++ b/src/render/renderers/opengl/renderer/renderviewbuilder.cpp
@@ -268,11 +268,7 @@ public:
// This should happen fairly infrequently (FrameGraph Change, Geometry/Material change)
// and allow to skip that step most of the time
if (m_fullRebuild) {
- // Clear previous cache
- RendererCache::LeafNodeData &writableCacheForLeaf = cache->leafNodeCache[m_leafNode];
- writableCacheForLeaf.renderCommandData.clear();
-
- QVector<EntityRenderCommandData> commandData;
+ EntityRenderCommandData commandData;
// Reduction
{
int totalCommandCount = 0;
@@ -282,10 +278,12 @@ public:
for (const RenderViewCommandBuilderJobPtr &renderViewCommandBuilder : qAsConst(m_renderViewCommandBuilderJobs))
commandData += std::move(renderViewCommandBuilder->commandData());
}
- // Store in cache
+
+ // Store new cache
+ RendererCache::LeafNodeData &writableCacheForLeaf = cache->leafNodeCache[m_leafNode];
writableCacheForLeaf.renderCommandData = std::move(commandData);
}
- const QVector<EntityRenderCommandData> commandData = dataCacheForLeaf.renderCommandData;
+ const EntityRenderCommandData commandData = dataCacheForLeaf.renderCommandData;
const QVector<Entity *> filteredEntities = dataCacheForLeaf.filterEntitiesByLayer;
QVector<Entity *> renderableEntities = isDraw ? cache->renderableEntities : cache->computeEntities;
@@ -317,26 +315,28 @@ public:
// Filter out Render commands for which the Entity wasn't selected because
// of frustum, proximity or layer filtering
- QVector<EntityRenderCommandData *> filteredCommandData;
+ EntityRenderCommandData filteredCommandData;
filteredCommandData.reserve(renderableEntities.size());
// Because dataCacheForLeaf.renderableEntities or computeEntities are sorted
// What we get out of EntityRenderCommandData is also sorted by Entity
auto eIt = std::cbegin(renderableEntities);
- auto cIt = std::cbegin(commandData);
const auto eEnd = std::cend(renderableEntities);
- const auto cEnd = std::cend(commandData);
+ int cIt = 0;
+ const int cEnd = commandData.size();
while (eIt != eEnd) {
const Entity *targetEntity = *eIt;
// Advance until we have commands whose Entity has a lower address
// than the selected filtered entity
- while (cIt->entity < targetEntity && cIt != cEnd)
+ while (cIt != cEnd && commandData.entities.at(cIt) < targetEntity)
++cIt;
// Push pointers to command data for all commands that match the
// entity
- while (cIt->entity == targetEntity && cIt != cEnd) {
- filteredCommandData.push_back(const_cast<EntityRenderCommandData *>(&(*cIt)));
+ while (cIt != cEnd && commandData.entities.at(cIt) == targetEntity) {
+ filteredCommandData.push_back(commandData.entities.at(cIt),
+ commandData.commands.at(cIt),
+ commandData.passesData.at(cIt));
++cIt;
}
++eIt;