Renderer: build cache data for new RenderViews

Change-Id: I95690444badaf573b9e2775b50c61113de8d1c77
Reviewed-by: Michael Brasser <michael.brasser@live.com>
This commit is contained in:
Paul Lemire 2019-10-16 10:52:17 +02:00
parent c795ccb968
commit 257c9bc8b5
2 changed files with 39 additions and 9 deletions

View File

@ -1887,14 +1887,17 @@ QVector<Qt3DCore::QAspectJobPtr> Renderer::renderBinJobs()
const int fgBranchCount = m_frameGraphLeaves.size();
for (int i = 0; i < fgBranchCount; ++i) {
RenderViewBuilder builder(m_frameGraphLeaves.at(i), i, this);
builder.setLayerCacheNeedsToBeRebuilt(layersCacheNeedsToBeRebuilt);
builder.setRenderableCacheNeedsToBeRebuilt(renderableDirty);
builder.setComputableCacheNeedsToBeRebuilt(computeableDirty);
builder.setLightGathererCacheNeedsToBeRebuilt(lightsDirty);
builder.setMaterialGathererCacheNeedsToBeRebuilt(materialCacheNeedsToBeRebuilt);
builder.setLightGathererCacheNeedsToBeRebuilt(lightsDirty);
builder.setRenderCommandCacheNeedsToBeRebuilt(renderCommandsDirty);
FrameGraphNode *leaf = m_frameGraphLeaves.at(i);
RenderViewBuilder builder(leaf, i, this);
// If we have a new RV (wasn't in the cache before, then it contains no cached data)
const bool isNewRV = !m_cache.leafNodeCache.contains(leaf);
builder.setLayerCacheNeedsToBeRebuilt(layersCacheNeedsToBeRebuilt || isNewRV);
builder.setRenderableCacheNeedsToBeRebuilt(renderableDirty || isNewRV);
builder.setComputableCacheNeedsToBeRebuilt(computeableDirty || isNewRV);
builder.setLightGathererCacheNeedsToBeRebuilt(lightsDirty || isNewRV);
builder.setMaterialGathererCacheNeedsToBeRebuilt(materialCacheNeedsToBeRebuilt || isNewRV);
builder.setLightGathererCacheNeedsToBeRebuilt(lightsDirty || isNewRV);
builder.setRenderCommandCacheNeedsToBeRebuilt(renderCommandsDirty || isNewRV);
builder.prepareJobs();
renderBinJobs.append(builder.buildJobHierachy());

View File

@ -211,10 +211,37 @@ private Q_SLOTS:
renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty);
renderQueue->reset();
// WHEN (nothing dirty, no buffers, no layers to be rebuilt, no materials to be rebuilt)
// WHEN (nothing dirty, no buffers, no layers to be rebuilt, no materials to be rebuilt) (Nothing in cache)
renderer.markDirty(Qt3DRender::Render::AbstractRenderer::FrameGraphDirty, nullptr);
jobs = renderer.renderBinJobs();
// THEN (level
QCOMPARE(jobs.size(),
1 + // updateLevelOfDetailJob
1 + // cleanupJob
1 + // VAOGatherer
1 + // updateSkinningPaletteJob
1 + // SyncLoadingJobs
1 + // sendDisablesToFrontend
1 + // LightGathererJob
1 + // CacheLightJob
1 + // RenderableEntityFilterJob
1 + // CacheRenderableEntitiesJob
1 + // ComputableEntityFilterJob
1 + // CacheComputableEntitiesJob
singleRenderViewJobCount +
singleRenderViewCommandRebuildJobCount +
renderViewBuilderMaterialCacheJobCount +
layerCacheJobCount);
renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty);
renderQueue->reset();
// WHEN (nothing dirty, no buffers, no layers to be rebuilt, no materials to be rebuilt) (RV leaf in cache)
renderer.markDirty(Qt3DRender::Render::AbstractRenderer::FrameGraphDirty, nullptr);
renderer.cache()->leafNodeCache[renderer.m_frameGraphLeaves.first()] = {};
jobs = renderer.renderBinJobs();
// THEN (level
QCOMPARE(jobs.size(),
1 + // updateLevelOfDetailJob