From 257c9bc8b53fb62fcad6bb8977b048d3a7563469 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Wed, 16 Oct 2019 10:52:17 +0200 Subject: [PATCH] Renderer: build cache data for new RenderViews Change-Id: I95690444badaf573b9e2775b50c61113de8d1c77 Reviewed-by: Michael Brasser --- .../renderers/opengl/renderer/renderer.cpp | 19 +++++++----- tests/auto/render/renderer/tst_renderer.cpp | 29 ++++++++++++++++++- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp index 474519398..9220a719a 100644 --- a/src/render/renderers/opengl/renderer/renderer.cpp +++ b/src/render/renderers/opengl/renderer/renderer.cpp @@ -1887,14 +1887,17 @@ QVector 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()); diff --git a/tests/auto/render/renderer/tst_renderer.cpp b/tests/auto/render/renderer/tst_renderer.cpp index 91cb7906c..0940348bd 100644 --- a/tests/auto/render/renderer/tst_renderer.cpp +++ b/tests/auto/render/renderer/tst_renderer.cpp @@ -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