diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-06-03 11:57:20 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-07-04 06:09:25 +0000 |
commit | 70dfe10ef9c4745bbf7253c0917a7b5b4120f240 (patch) | |
tree | c52c55163e5e0ccfd753574510bfbd1d4bf7464b /src/render/framegraph/framegraphvisitor.cpp | |
parent | 496797fea24e86388eb8ceb9ad257c94c79c72ae (diff) |
Further job improvements
The RenderViewInitialization job used to have to wait for the world transform
job to be completed because it was used to set the viewProjectionMatrix.
This patch adjust dependencies and adds a new job that sets the
viewProjectionMatrix once the transform update job is complete.
This allows to start most of the processing earlier and better use the
available cpu cores.
Change-Id: I77d751e0b20639934cc00be0cd9888f41f684f89
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/framegraph/framegraphvisitor.cpp')
-rw-r--r-- | src/render/framegraph/framegraphvisitor.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/render/framegraph/framegraphvisitor.cpp b/src/render/framegraph/framegraphvisitor.cpp index 577ead8f5..c90a4c1e6 100644 --- a/src/render/framegraph/framegraphvisitor.cpp +++ b/src/render/framegraph/framegraphvisitor.cpp @@ -196,12 +196,23 @@ void FrameGraphVisitor::visit(Render::FrameGraphNode *node) materialGatherer->setTechniqueFilter(const_cast<TechniqueFilter *>(rv->techniqueFilter())); } - // Frustum culling - frustumCulling->setViewProjection(rv->viewProjectionMatrix()); - // Command builders for (const auto renderViewCommandBuilder : qAsConst(renderViewCommandBuilders)) renderViewCommandBuilder->setRenderView(rv); + + // Set whether frustum culling is enabled or not + frustumCulling->setActive(rv->frustumCulling()); + }; + + // Copy shared ptr -> this is called once the FrameGraphBranch was used to fill initial data in the RenderView + auto syncFrustumCulling = [=] () { + RenderView *rv = renderViewJob->renderView(); + + // Update matrices now that all transforms have been updated + rv->updateMatrices(); + + // Frustum culling + frustumCulling->setViewProjection(rv->viewProjectionMatrix()); }; // Copy shared ptr -> this is called after filtering / culling / parameter setting has been performed @@ -297,10 +308,15 @@ void FrameGraphVisitor::visit(Render::FrameGraphNode *node) auto syncRenderViewCommandBuildingJob = GenericLambdaJobPtr<decltype(syncForRenderCommandBuilding)>::create(syncForRenderCommandBuilding); auto syncRenderViewInitializationJob = GenericLambdaJobPtr<decltype(syncRenderViewInitialization)>::create(syncRenderViewInitialization); auto syncRenderViewCommandBuildersJob = GenericLambdaJobPtr<decltype(syncRenderViewCommandBuilders)>::create(syncRenderViewCommandBuilders); + auto syncFrustumCullingJob = GenericLambdaJobPtr<decltype(syncFrustumCulling)>::create(syncFrustumCulling); // Set dependencies - renderViewJob->addDependency(renderer->updateWorldTransformJob()); + syncFrustumCullingJob->addDependency(renderer->updateWorldTransformJob()); + syncFrustumCullingJob->addDependency(syncRenderViewInitializationJob); + frustumCulling->addDependency(renderer->expandBoundingVolumeJob()); + frustumCulling->addDependency(syncFrustumCullingJob); + syncRenderViewInitializationJob->addDependency(renderViewJob); filterEntityByLayer->addDependency(syncRenderViewInitializationJob); @@ -332,6 +348,7 @@ void FrameGraphVisitor::visit(Render::FrameGraphNode *node) m_jobs->push_back(frustumCulling); m_jobs->push_back(lightGatherer); m_jobs->push_back(syncRenderViewCommandBuildersJob); + m_jobs->push_back(syncFrustumCullingJob); for (const auto materialGatherer : qAsConst(materialGatherers)) m_jobs->push_back(materialGatherer); |