Part 2 of enabling Atom to use TaskGraph

Enable Atom CullingScene to use TaskGraph
Enable Atom PNG save to use TaskGraph for red/blue color channel swap on save out.

Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com>
This commit is contained in:
rgba16f [Amazon]
2021-11-02 15:02:08 -05:00
committed by GitHub
parent cf1d13fa43
commit 5c072a5d51
10 changed files with 508 additions and 286 deletions
@@ -38,6 +38,8 @@
namespace AZ
{
class Job;
class TaskGraphActiveInterface;
class TaskGraph;
namespace RHI
{
@@ -256,7 +258,13 @@ namespace AZ
//! Must be called between BeginCulling() and EndCulling(), once for each active scene/view pair.
//! Will create child jobs under the parentJob to do the processing in parallel.
//! Can be called in parallel (i.e. to perform culling on multiple views at the same time).
void ProcessCullables(const Scene& scene, View& view, AZ::Job& parentJob);
void ProcessCullablesJobs(const Scene& scene, View& view, AZ::Job& parentJob);
//! Performs render culling and lod selection for a View, then adds the visible renderpackets to that View.
//! Must be called between BeginCulling() and EndCulling(), once for each active scene/view pair.
//! Will create child task graphs that signal the TaskGraphEvent to do the processing in parallel.
//! Can be called in parallel (i.e. to perform culling on multiple views at the same time).
void ProcessCullablesTG(const Scene& scene, View& view, AZ::TaskGraph& taskGraph);
//! Adds a Cullable to the underlying visibility system(s).
//! Must be called at least once on initialization and whenever a Cullable's position or bounds is changed.
@@ -276,17 +284,20 @@ namespace AZ
return m_debugCtx;
}
static const size_t WorkListCapacity = 5;
using WorkListType = AZStd::fixed_vector<AzFramework::IVisibilityScene::NodeData, WorkListCapacity>;
protected:
size_t CountObjectsInScene();
private:
void BeginCullingTaskGraph(const AZStd::vector<ViewPtr>& views);
void BeginCullingJobs(const AZStd::vector<ViewPtr>& views);
void ProcessCullablesCommon(const Scene& scene, View& view, AZ::Frustum& frustum, void*& maskedOcclusionCulling);
const Scene* m_parentScene = nullptr;
AzFramework::IVisibilityScene* m_visScene = nullptr;
CullingDebugContext m_debugCtx;
AZStd::concurrency_checker m_cullDataConcurrencyCheck;
OcclusionPlaneVector m_occlusionPlanes;
AZ::TaskGraphActiveInterface* m_taskGraphActive = nullptr;
};
@@ -200,8 +200,8 @@ namespace AZ
// This function is called every time scene's render pipelines change.
void RebuildPipelineStatesLookup();
// Helper function to wait for end of TaskGraph
void WaitTGEvent(AZ::TaskGraphEvent& completionTGEvent, AZStd::atomic_bool* workToWaitOn = nullptr);
// Helper function to wait for end of TaskGraph and then delete the TaskGraphEvent
void WaitAndCleanTGEvent(AZStd::unique_ptr<AZ::TaskGraphEvent>&& completionTGEvent);
// Helper function for wait and clean up a completion job
void WaitAndCleanCompletionJob(AZ::JobCompletion*& completionJob);
@@ -230,8 +230,7 @@ namespace AZ
AZStd::vector<RenderPipelinePtr> m_pipelines;
// CPU simulation TaskGraphEvent to wait for completion of all the simulation tasks
AZ::TaskGraphEvent m_simulationFinishedTGEvent;
AZStd::atomic_bool m_simulationFinishedWorkActive = false;
AZStd::unique_ptr<AZ::TaskGraphEvent> m_simulationFinishedTGEvent;
// CPU simulation job completion for track all feature processors' simulation jobs
AZ::JobCompletion* m_simulationCompletion = nullptr;