Profiling: Add more instrumentation

Adds new instrumentation macros throughout the codebase, using the
visualizer to find where current instrumentation is lacking using the
shadowed sponza sample + editor. Some notes from exploring:

- We spend ~5ms in CullingScene: BeginCulling
- PipelineStateCache: Compact usually 1ms
- CompileImageBarriers takes most of the time in CompileResourceBarriers

Signed-off-by: Jacob Hilliard <jhlliar@amazon.com>
monroegm-disable-blank-issue-2
Jacob Hilliard 4 years ago
parent db8f78890f
commit 4d618ea619

@ -126,6 +126,7 @@ namespace AZ
ResultCode FrameGraph::End() ResultCode FrameGraph::End()
{ {
AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameGraph: End");
ResultCode resultCode = ValidateEnd(); ResultCode resultCode = ValidateEnd();
if (resultCode != ResultCode::Success) if (resultCode != ResultCode::Success)
{ {

@ -72,6 +72,7 @@ namespace AZ
void FrameGraphExecuter::Begin(const FrameGraph& frameGraph) void FrameGraphExecuter::Begin(const FrameGraph& frameGraph)
{ {
AZ_TRACE_METHOD(); AZ_TRACE_METHOD();
AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameGraphExecuter: Begin");
BeginInternal(frameGraph); BeginInternal(frameGraph);
} }

@ -6,6 +6,7 @@
* *
*/ */
#include <Atom/RHI/CpuProfiler.h>
#include <Atom/RHI/PipelineStateCache.h> #include <Atom/RHI/PipelineStateCache.h>
#include <Atom/RHI/Factory.h> #include <Atom/RHI/Factory.h>
#include <AzCore/std/sort.h> #include <AzCore/std/sort.h>
@ -205,6 +206,7 @@ namespace AZ
void PipelineStateCache::Compact() void PipelineStateCache::Compact()
{ {
AZ_ATOM_PROFILE_FUNCTION("RHI", "PipelineStateCache: Compact");
AZStd::unique_lock<AZStd::shared_mutex> lock(m_mutex); AZStd::unique_lock<AZStd::shared_mutex> lock(m_mutex);
// Merge the pending cache into the read-only cache. // Merge the pending cache into the read-only cache.

@ -223,7 +223,7 @@ namespace AZ
* own RHI scopes to the frame scheduler. This happens prior to the RPI pass graph registration. * own RHI scopes to the frame scheduler. This happens prior to the RPI pass graph registration.
*/ */
{ {
AZ_ATOM_PROFILE_TIME_GROUP_REGION("RHI", "RHISystem :FrameUpdate: OnFramePrepare"); AZ_ATOM_PROFILE_TIME_GROUP_REGION("RHI", "RHISystem: FrameUpdate: OnFramePrepare");
RHISystemNotificationBus::Broadcast(&RHISystemNotificationBus::Events::OnFramePrepare, m_frameScheduler); RHISystemNotificationBus::Broadcast(&RHISystemNotificationBus::Events::OnFramePrepare, m_frameScheduler);
} }

@ -469,6 +469,8 @@ namespace AZ
ResourceTransitionLoggerNull logger(imageFrameAttachment.GetId()); ResourceTransitionLoggerNull logger(imageFrameAttachment.GetId());
#endif #endif
AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameGraphCompiler: CompileImageBarriers (DX12)");
Image& image = static_cast<Image&>(*imageFrameAttachment.GetImage()); Image& image = static_cast<Image&>(*imageFrameAttachment.GetImage());
RHI::ImageScopeAttachment* scopeAttachment = imageFrameAttachment.GetFirstScopeAttachment(); RHI::ImageScopeAttachment* scopeAttachment = imageFrameAttachment.GetFirstScopeAttachment();

@ -720,6 +720,7 @@ namespace AZ
void CullingScene::BeginCulling(const AZStd::vector<ViewPtr>& views) void CullingScene::BeginCulling(const AZStd::vector<ViewPtr>& views)
{ {
AZ_ATOM_PROFILE_FUNCTION("RPI", "CullingScene: BeginCulling");
m_cullDataConcurrencyCheck.soft_lock(); m_cullDataConcurrencyCheck.soft_lock();
m_debugCtx.ResetCullStats(); m_debugCtx.ResetCullStats();

@ -298,6 +298,7 @@ namespace AZ
void PassSystem::ProcessQueuedChanges() void PassSystem::ProcessQueuedChanges()
{ {
AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: ProcessQueuedChanges");
RemovePasses(); RemovePasses();
BuildPasses(); BuildPasses();
InitializePasses(); InitializePasses();
@ -313,7 +314,11 @@ namespace AZ
m_state = PassSystemState::Rendering; m_state = PassSystemState::Rendering;
Pass::FramePrepareParams params{ &frameGraphBuilder }; Pass::FramePrepareParams params{ &frameGraphBuilder };
m_rootPass->FrameBegin(params);
{
AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "Pass: FrameBegin");
m_rootPass->FrameBegin(params);
}
} }
void PassSystem::FrameEnd() void PassSystem::FrameEnd()

@ -408,6 +408,7 @@ namespace AZ
{ {
AZ_PROFILE_SCOPE(Debug::ProfileCategory::AzRender, "m_srgCallback"); AZ_PROFILE_SCOPE(Debug::ProfileCategory::AzRender, "m_srgCallback");
AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "ShaderResourceGroupCallback: SrgCallback");
// Set values for scene srg // Set values for scene srg
if (m_srg && m_srgCallback) if (m_srg && m_srgCallback)
{ {
@ -418,7 +419,7 @@ namespace AZ
// Get active pipelines which need to be rendered and notify them frame started // Get active pipelines which need to be rendered and notify them frame started
AZStd::vector<RenderPipelinePtr> activePipelines; AZStd::vector<RenderPipelinePtr> activePipelines;
{ {
AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "OnStartFrame"); AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "Scene: OnStartFrame");
for (auto& pipeline : m_pipelines) for (auto& pipeline : m_pipelines)
{ {
if (pipeline->NeedsRender()) if (pipeline->NeedsRender())
@ -483,6 +484,7 @@ namespace AZ
{ {
AZ_PROFILE_SCOPE(Debug::ProfileCategory::AzRender, "CollectDrawPackets"); AZ_PROFILE_SCOPE(Debug::ProfileCategory::AzRender, "CollectDrawPackets");
AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "CollectDrawPackets");
AZ::JobCompletion* collectDrawPacketsCompletion = aznew AZ::JobCompletion(); AZ::JobCompletion* collectDrawPacketsCompletion = aznew AZ::JobCompletion();
// Launch FeatureProcessor::Render() jobs // Launch FeatureProcessor::Render() jobs

Loading…
Cancel
Save