summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-05-27 14:54:13 +0200
committerPaul Lemire <paul.lemire@kdab.com>2020-12-01 16:08:58 +0000
commitb70c952ffd44f91c6cafca5a86e21f18fc403d19 (patch)
tree85bb8f1791074c10235eedbd26f15f7248e4c3ef
parentd4e6ee2d994651ce17f7014ba1077ae4bd228cfb (diff)
SyncRenderViewPreCommandUpdate: fix a few odd cases
- We need to perform frustum culling even if camera hasn't moved as entities in the scene could still be moving - We shouldn't return early if there's nothing to draw/or filter. Given we keep 2 sets of render command buffers we flip between every frame, we still need to update the command indices on bufferA, so that bufferB get initialized with values from bufferA at the end of the frame ... Otherwise in the case where at frame N (bufA) we have a visible object and at frame N+1 (bufB), that object is culled object. If we return early, bufB would never gets updated to contain 0 command indices. We would then end up flickering between visible and non visible object. Change-Id: I248c54b89a3795fa69c23ea952424c68696313e1 Reviewed-by: Mike Krus <mike.krus@kdab.com> (cherry picked from commit b76e9b0eccdd49a539e213a91bcaecbd98efbd74)
-rw-r--r--src/plugins/renderers/opengl/renderer/renderviewbuilder.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/plugins/renderers/opengl/renderer/renderviewbuilder.cpp b/src/plugins/renderers/opengl/renderer/renderviewbuilder.cpp
index 32667dceb..41aef69a0 100644
--- a/src/plugins/renderers/opengl/renderer/renderviewbuilder.cpp
+++ b/src/plugins/renderers/opengl/renderer/renderviewbuilder.cpp
@@ -370,13 +370,15 @@ public:
// Record the updated viewProjectionMatrix in the cache to allow check to be performed
// next frame
cacheForLeaf.viewProjectionMatrix = rv->viewProjectionMatrix();
+ }
- // Filter out frustum culled entity for drawable entities and store in cache
- if (isDraw && rv->frustumCulling()) {
- cacheForLeaf.filteredAndCulledRenderables = RenderViewBuilder::entitiesInSubset(
- cacheForLeaf.layeredFilteredRenderables,
- m_frustumCullingJob->visibleEntities());
- }
+ // Filter out frustum culled entity for drawable entities and store in cache
+ // We need to check this regardless of whether the camera has moved since
+ // entities in the scene themselves could have moved
+ if (isDraw && rv->frustumCulling()) {
+ cacheForLeaf.filteredAndCulledRenderables = RenderViewBuilder::entitiesInSubset(
+ cacheForLeaf.layeredFilteredRenderables,
+ m_frustumCullingJob->visibleEntities());
}
rv->setMaterialParameterTable(cacheForLeaf.materialParameterGatherer);
@@ -400,10 +402,6 @@ public:
// Set RenderCommandDataView on RV (will be used later on to sort commands ...)
rv->setRenderCommandDataView(filteredCommandData);
- // Early return in case we have nothing to filter
- if (renderableEntities.size() == 0)
- return;
-
// Filter out Render commands for which the Entity wasn't selected because
// of frustum, proximity or layer filtering
if (commandFilteringRequired) {