Jobify the draw item list sort in View::FinalizeDrawLists (#6176)
Jobification of the sort saves 0.7ms/frame on the HighInstanceTest on my pc. Make MeshFeatureProcessor update of the mesh cull bounds part of the job work rather than part of the simulate work. This saves 0.1ms/frame on the HighInstanceTest Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com>
This commit is contained in:
@@ -400,10 +400,11 @@ namespace AZ
|
||||
for (FeatureProcessorPtr& fp : m_featureProcessors)
|
||||
{
|
||||
FeatureProcessor* featureProcessor = fp.get();
|
||||
const auto jobLambda = [this, featureProcessor]()
|
||||
const auto jobLambda = [this, featureProcessor](AZ::Job& owner)
|
||||
{
|
||||
|
||||
featureProcessor->Simulate(m_simulatePacket);
|
||||
FeatureProcessor::SimulatePacket jobPacket = m_simulatePacket;
|
||||
jobPacket.m_parentJob = &owner;
|
||||
featureProcessor->Simulate(jobPacket);
|
||||
};
|
||||
|
||||
AZ::Job* simulationJob = AZ::CreateJobFunction(AZStd::move(jobLambda), true, nullptr); //auto-deletes
|
||||
@@ -516,7 +517,7 @@ namespace AZ
|
||||
collectDrawPacketsTG.Submit(&collectDrawPacketsTGEvent);
|
||||
|
||||
// Launch CullingSystem::ProcessCullables() jobs (will run concurrently with FeatureProcessor::Render() jobs if m_parallelOctreeTraversal)
|
||||
bool parallelOctreeTraversal = m_cullingScene->GetDebugContext().m_parallelOctreeTraversal;
|
||||
const bool parallelOctreeTraversal = m_cullingScene->GetDebugContext().m_parallelOctreeTraversal;
|
||||
m_cullingScene->BeginCulling(m_renderPacket.m_views);
|
||||
static const AZ::TaskDescriptor processCullablesDescriptor{"AZ::RPI::Scene::ProcessCullables", "Graphics"};
|
||||
AZ::TaskGraphEvent processCullablesTGEvent;
|
||||
@@ -576,6 +577,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
// Launch CullingSystem::ProcessCullables() jobs (will run concurrently with FeatureProcessor::Render() jobs)
|
||||
const bool parallelOctreeTraversal = m_cullingScene->GetDebugContext().m_parallelOctreeTraversal;
|
||||
m_cullingScene->BeginCulling(m_renderPacket.m_views);
|
||||
for (ViewPtr& viewPtr : m_renderPacket.m_views)
|
||||
{
|
||||
@@ -584,7 +586,7 @@ namespace AZ
|
||||
m_cullingScene->ProcessCullablesJobs(*this, *viewPtr, thisJob); // can't call directly because ProcessCullables needs a parent job
|
||||
},
|
||||
true, nullptr); //auto-deletes
|
||||
if (m_cullingScene->GetDebugContext().m_parallelOctreeTraversal)
|
||||
if (parallelOctreeTraversal)
|
||||
{
|
||||
processCullablesJob->SetDependent(collectDrawPacketsCompletion);
|
||||
processCullablesJob->Start();
|
||||
@@ -731,20 +733,19 @@ namespace AZ
|
||||
// Add dynamic draw data for all the views
|
||||
if (m_dynamicDrawSystem)
|
||||
{
|
||||
AZ_PROFILE_SCOPE(RPI, "DynamicDraw SubmitDrawData");
|
||||
m_dynamicDrawSystem->SubmitDrawData(this, m_renderPacket.m_views);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
AZ_PROFILE_BEGIN(RPI, "FinalizeDrawLists");
|
||||
if (jobPolicy == RHI::JobPolicy::Serial)
|
||||
AZ_PROFILE_SCOPE(RPI, "FinalizeDrawLists");
|
||||
if (jobPolicy == RHI::JobPolicy::Serial ||
|
||||
m_renderPacket.m_views.size() <= 1) // FinalizeDrawListsX both immediately wait for the job to complete, skip job if only 1 job would be generated
|
||||
{
|
||||
for (auto& view : m_renderPacket.m_views)
|
||||
{
|
||||
view->FinalizeDrawLists();
|
||||
}
|
||||
AZ_PROFILE_END(RPI);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -756,7 +757,6 @@ namespace AZ
|
||||
{
|
||||
FinalizeDrawListsJobs();
|
||||
}
|
||||
AZ_PROFILE_END(RPI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user