Merge branch 'development' into redcode/driller_removal
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> # Conflicts: # Code/Framework/AzCore/AzCore/azcore_files.cmake # Gems/Atom/Feature/Common/Assets/Materials/Presets/MacBeth/15_red_sRGB.tif
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
|
||||
//Enables more detailed profiling descriptions within the culling system, but adds some performance overhead.
|
||||
//Enable this to more easily see which jobs are associated with which view.
|
||||
//#define AZ_CULL_PROFILE_VERBOSE
|
||||
//#define AZ_CULL_PROFILE_VERBOSE
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -43,6 +43,7 @@ namespace AZ
|
||||
AZ_CVAR(bool, r_CullInParallel, true, nullptr, ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(uint32_t, r_CullWorkPerBatch, 500, nullptr, ConsoleFunctorFlags::Null, "");
|
||||
|
||||
#ifdef AZ_CULL_DEBUG_ENABLED
|
||||
void DebugDrawWorldCoordinateAxes(AuxGeomDraw* auxGeom)
|
||||
{
|
||||
auxGeom->DrawCylinder(Vector3(.5, .0, .0), Vector3(1, 0, 0), 0.02f, 1.0f, Colors::Red, AuxGeomDraw::DrawStyle::Solid, AuxGeomDraw::DepthTest::Off);
|
||||
@@ -198,6 +199,7 @@ namespace AZ
|
||||
AZ_Assert(false, "invalid frustum, cannot draw");
|
||||
}
|
||||
}
|
||||
#endif //AZ_CULL_DEBUG_ENABLED
|
||||
|
||||
CullingDebugContext::~CullingDebugContext()
|
||||
{
|
||||
@@ -282,7 +284,7 @@ namespace AZ
|
||||
const Scene& scene,
|
||||
View& view,
|
||||
Frustum& frustum,
|
||||
[[maybe_unused]]void* maskedOcclusionCulling)
|
||||
[[maybe_unused]] void* maskedOcclusionCulling)
|
||||
{
|
||||
AZStd::shared_ptr<WorklistData> worklistData = AZStd::make_shared<WorklistData>();
|
||||
worklistData->m_debugCtx = &debugCtx;
|
||||
@@ -318,14 +320,16 @@ namespace AZ
|
||||
for (const AzFramework::IVisibilityScene::NodeData& nodeData : worklist)
|
||||
{
|
||||
//If a node is entirely contained within the frustum, then we can skip the fine grained culling.
|
||||
bool nodeIsContainedInFrustum = ShapeIntersection::Contains(worklistData->m_frustum, nodeData.m_bounds);
|
||||
bool nodeIsContainedInFrustum =
|
||||
!worklistData->m_debugCtx->m_enableFrustumCulling ||
|
||||
ShapeIntersection::Contains(worklistData->m_frustum, nodeData.m_bounds);
|
||||
|
||||
#ifdef AZ_CULL_PROFILE_VERBOSE
|
||||
AZ_PROFILE_SCOPE(RPI, "process node (view: %s, skip fine cull: %d",
|
||||
m_view->GetName().GetCStr(), nodeIsContainedInFrustum ? 1 : 0);
|
||||
AZ_PROFILE_SCOPE(RPI, "process node (view: %s, skip fine cull: %ds",
|
||||
worklistData->m_view->GetName().GetCStr(), nodeIsContainedInFrustum ? "true" : "false");
|
||||
#endif
|
||||
|
||||
if (nodeIsContainedInFrustum || !worklistData->m_debugCtx->m_enableFrustumCulling)
|
||||
if (nodeIsContainedInFrustum)
|
||||
{
|
||||
//Add all objects within this node to the view, without any extra culling
|
||||
for (AzFramework::VisibilityEntry* visibleEntry : nodeData.m_entries)
|
||||
@@ -391,7 +395,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef AZ_CULL_DEBUG_ENABLED
|
||||
if (worklistData->m_debugCtx->m_debugDraw && (worklistData->m_view->GetName() == worklistData->m_debugCtx->m_currentViewSelectionName))
|
||||
{
|
||||
AZ_PROFILE_SCOPE(RPI, "debug draw culling");
|
||||
@@ -443,8 +447,10 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef AZ_CULL_DEBUG_ENABLED
|
||||
if (worklistData->m_debugCtx->m_enableStats)
|
||||
{
|
||||
CullingDebugContext::CullStats& cullStats = worklistData->m_debugCtx->GetCullStatsForView(worklistData->m_view);
|
||||
@@ -454,6 +460,7 @@ namespace AZ
|
||||
cullStats.m_numVisibleCullables += numVisibleCullables;
|
||||
++cullStats.m_numJobs;
|
||||
}
|
||||
#endif //AZ_CULL_DEBUG_ENABLED
|
||||
}
|
||||
|
||||
#if AZ_TRAIT_MASKED_OCCLUSION_CULLING_SUPPORTED
|
||||
@@ -466,6 +473,10 @@ namespace AZ
|
||||
return MaskedOcclusionCulling::CullingResult::VISIBLE;
|
||||
}
|
||||
|
||||
#ifdef AZ_CULL_PROFILE_VERBOSE
|
||||
AZ_PROFILE_SCOPE(RPI, "TestOcclusionCulling");
|
||||
#endif
|
||||
|
||||
if (visibleEntry->m_boundingVolume.Contains(worklistData->m_view->GetCameraTransform().GetTranslation()))
|
||||
{
|
||||
// camera is inside bounding volume
|
||||
@@ -515,10 +526,15 @@ namespace AZ
|
||||
}
|
||||
#endif
|
||||
|
||||
void CullingScene::ProcessCullablesCommon(const Scene& scene, View& view, AZ::Frustum& frustum, [[maybe_unused]]void*& maskedOcclusionCulling)
|
||||
void CullingScene::ProcessCullablesCommon(
|
||||
const Scene& scene [[maybe_unused]],
|
||||
View& view,
|
||||
AZ::Frustum& frustum [[maybe_unused]],
|
||||
void*& maskedOcclusionCulling [[maybe_unused]])
|
||||
{
|
||||
AZ_PROFILE_SCOPE(RPI, "CullingScene::ProcessCullablesCommon() - %s", view.GetName().GetCStr());
|
||||
|
||||
#ifdef AZ_CULL_DEBUG_ENABLED
|
||||
if (m_debugCtx.m_freezeFrustums)
|
||||
{
|
||||
AZStd::lock_guard<AZStd::mutex> lock(m_debugCtx.m_frozenFrustumsMutex);
|
||||
@@ -543,7 +559,7 @@ namespace AZ
|
||||
CullingDebugContext::CullStats& cullStats = m_debugCtx.GetCullStatsForView(&view);
|
||||
cullStats.m_cameraViewToWorld = view.GetViewToWorldMatrix();
|
||||
}
|
||||
|
||||
#endif //AZ_CULL_DEBUG_ENABLED
|
||||
#if AZ_TRAIT_MASKED_OCCLUSION_CULLING_SUPPORTED
|
||||
// setup occlusion culling, if necessary
|
||||
maskedOcclusionCulling = m_occlusionPlanes.empty() ? nullptr : view.GetMaskedOcclusionCulling();
|
||||
@@ -805,6 +821,7 @@ namespace AZ
|
||||
beginCullingDescriptor,
|
||||
[&view]()
|
||||
{
|
||||
AZ_PROFILE_SCOPE(RPI, "CullingScene: BeginCullingTaskGraph");
|
||||
view->BeginCulling();
|
||||
});
|
||||
}
|
||||
@@ -822,6 +839,7 @@ namespace AZ
|
||||
{
|
||||
const auto cullingLambda = [&view]()
|
||||
{
|
||||
AZ_PROFILE_SCOPE(RPI, "CullingScene: BeginCullingJob");
|
||||
view->BeginCulling();
|
||||
};
|
||||
|
||||
@@ -843,7 +861,11 @@ namespace AZ
|
||||
|
||||
m_taskGraphActive = AZ::Interface<AZ::TaskGraphActiveInterface>::Get();
|
||||
|
||||
if (m_taskGraphActive && m_taskGraphActive->IsTaskGraphActive())
|
||||
if(views.size() == 1) // avoid job overhead when only 1 job
|
||||
{
|
||||
views[0]->BeginCulling();
|
||||
}
|
||||
else if (m_taskGraphActive && m_taskGraphActive->IsTaskGraphActive())
|
||||
{
|
||||
BeginCullingTaskGraph(views);
|
||||
}
|
||||
@@ -852,6 +874,7 @@ namespace AZ
|
||||
BeginCullingJobs(views);
|
||||
}
|
||||
|
||||
#if AZ_CULL_DEBUG_ENABLED
|
||||
AuxGeomDrawPtr auxGeom;
|
||||
if (m_debugCtx.m_debugDraw)
|
||||
{
|
||||
@@ -884,6 +907,7 @@ namespace AZ
|
||||
m_debugCtx.m_frozenFrustums.clear();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CullingScene::EndCulling()
|
||||
|
||||
@@ -311,7 +311,6 @@ namespace AZ
|
||||
Pass::FramePrepareParams params{ &frameGraphBuilder };
|
||||
|
||||
{
|
||||
AZ_PROFILE_SCOPE(RPI, "Pass: FrameBegin");
|
||||
m_rootPass->FrameBegin(params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,10 +399,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
|
||||
@@ -515,7 +516,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;
|
||||
@@ -575,6 +576,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)
|
||||
{
|
||||
@@ -583,7 +585,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();
|
||||
@@ -730,20 +732,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
|
||||
{
|
||||
@@ -755,7 +756,6 @@ namespace AZ
|
||||
{
|
||||
FinalizeDrawListsJobs();
|
||||
}
|
||||
AZ_PROFILE_END(RPI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user