From 40aef3581255ac9a1e9ed342fe1e52ea2ec7cba7 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Thu, 23 May 2024 14:13:06 +0900 Subject: [PATCH] Performance trace for some bottleneck of update/render manager Let we check trace the top 5 area of update : update itself / animation / frame update callback / update renderer / transform and top 2 area of render : render instruction process / flush TODO : Since the name of environment need to be sync with peformance trace tool, we'd better change it after the system prepared. Change-Id: I4a9e38b6b957508138737ee225c0cfa9ad94a8f9 Signed-off-by: Eunki, Hong --- dali/internal/render/common/render-algorithms.cpp | 11 +++++- dali/internal/render/common/render-manager.cpp | 31 ++++++++++++---- .../update/manager/frame-callback-processor.cpp | 4 ++- dali/internal/update/manager/transform-manager.cpp | 13 +++++++ dali/internal/update/manager/update-manager.cpp | 42 ++++++++++++++++++++++ 5 files changed, 92 insertions(+), 9 deletions(-) diff --git a/dali/internal/render/common/render-algorithms.cpp b/dali/internal/render/common/render-algorithms.cpp index 9c00289..8048a6f 100644 --- a/dali/internal/render/common/render-algorithms.cpp +++ b/dali/internal/render/common/render-algorithms.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ #include // INTERNAL INCLUDES +#include #include #include #include @@ -390,6 +391,9 @@ inline void SetupDepthBuffer(const RenderItem& item, Graphics::CommandBuffer& co } } +// TODO : The name of trace marker is from VD specific. +// We might need to change it as DALI_TRACE_RENDER_PROCESS. +DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false); } // Unnamed namespace /** @@ -744,6 +748,10 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction& int orientation, const Uint16Pair& sceneSize) { + DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_RENDER_INSTRUCTION_PROCESS", [&](std::ostringstream& oss) { + oss << "[" << instruction.RenderListCount() << "]"; + }); + DALI_PRINT_RENDER_INSTRUCTION(instruction, bufferIndex); const Matrix* viewMatrix = instruction.GetViewMatrix(bufferIndex); @@ -790,6 +798,7 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction& mGraphicsCommandBuffer->ExecuteCommandBuffers(std::move(buffers)); } } + DALI_TRACE_END(gTraceFilter, "DALI_RENDER_INSTRUCTION_PROCESS"); } } // namespace Render diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index 3997f9e..5beba0c 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -24,6 +24,7 @@ // INTERNAL INCLUDES #include #include +#include #include @@ -145,6 +146,10 @@ inline void AlignDamagedRect(Rect& rect) rect.width = ((right + 16) / 16) * 16 - rect.x; rect.height = ((bottom + 16) / 16) * 16 - rect.y; } + +// TODO : The name of trace marker is from VD specific. +// We might need to change it as DALI_TRACE_RENDER_PROCESS. +DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false); } // namespace /** @@ -1139,21 +1144,33 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration:: mainCommandBuffer->EndRenderPass(syncObject); } + if(targetstoPresent.size() > 0u) + { + DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_RENDER_FINISHED", [&](std::ostringstream& oss) { + oss << "[" << targetstoPresent.size() << "]"; + }); + } + // Flush UBOs mImpl->uniformBufferManager->Flush(sceneObject, renderToFbo); mImpl->renderAlgorithms.SubmitCommandBuffer(); mImpl->commandBufferSubmitted = true; - std::sort(targetstoPresent.begin(), targetstoPresent.end()); - - Graphics::RenderTarget* rt = nullptr; - for(auto& target : targetstoPresent) + if(targetstoPresent.size() > 0u) { - if(target != rt) + std::sort(targetstoPresent.begin(), targetstoPresent.end()); + + Graphics::RenderTarget* rt = nullptr; + for(auto& target : targetstoPresent) { - mImpl->graphicsController.PresentRenderTarget(target); - rt = target; + if(target != rt) + { + mImpl->graphicsController.PresentRenderTarget(target); + rt = target; + } } + + DALI_TRACE_END(gTraceFilter, "DALI_RENDER_FINISHED"); } } diff --git a/dali/internal/update/manager/frame-callback-processor.cpp b/dali/internal/update/manager/frame-callback-processor.cpp index fc05171..6c40c72 100644 --- a/dali/internal/update/manager/frame-callback-processor.cpp +++ b/dali/internal/update/manager/frame-callback-processor.cpp @@ -37,7 +37,9 @@ namespace { -DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false); +// TODO : The name of trace marker is from VD specific. +// We might need to change it as DALI_TRACE_UPDATE_PROCESS. +DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false); #ifdef TRACE_ENABLED uint64_t GetNanoseconds() diff --git a/dali/internal/update/manager/transform-manager.cpp b/dali/internal/update/manager/transform-manager.cpp index 5608192..f5e3bac 100644 --- a/dali/internal/update/manager/transform-manager.cpp +++ b/dali/internal/update/manager/transform-manager.cpp @@ -29,6 +29,7 @@ #include #include +#include namespace Dali { @@ -77,6 +78,9 @@ inline void CalculateCenterPosition( } } +// TODO : The name of trace marker is from VD specific. +// We might need to change it as DALI_TRACE_UPDATE_PROCESS. +DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false); } // unnamed namespace TransformManager::TransformManager() @@ -235,8 +239,13 @@ bool TransformManager::Update() { bool componentsChanged = false; + DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_TRANSFORM_UPDATE", [&](std::ostringstream& oss) { + oss << "[" << mComponentCount << "]"; + }); + if(mReorder) { + DALI_TRACE_SCOPE(gTraceFilter, "DALI_TRANSFORM_REORDER"); //If some transform component has change its parent or has been removed since last update //we need to reorder the vectors ReorderComponents(); @@ -357,6 +366,10 @@ bool TransformManager::Update() mComponentDirty[i] = false; } + DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_TRANSFORM_UPDATE", [&](std::ostringstream& oss) { + oss << "[componentsChanged:" << componentsChanged << "]"; + }); + return componentsChanged; } diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index 3790b00..e7cbc2e 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -27,6 +27,7 @@ // INTERNAL INCLUDES #include +#include #include @@ -80,6 +81,12 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_UPDATE_MANAGER"); } // unnamed namespace #endif +namespace +{ +// TODO : The name of trace marker is from VD specific. +// We might need to change it as DALI_TRACE_UPDATE_PROCESS. +DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false); +} // namespace using namespace Dali::Integration; using Dali::Internal::Update::MessageQueue; @@ -883,8 +890,17 @@ bool UpdateManager::Animate(BufferIndex bufferIndex, float elapsedSeconds) { bool animationActive = false; + if(mImpl->animations.Empty()) + { + return animationActive; + } + auto&& iter = mImpl->animations.Begin(); + DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_ANIMATION_ANIMATE", [&](std::ostringstream& oss) { + oss << "[" << mImpl->animations.Count() << "]"; + }); + while(iter != mImpl->animations.End()) { Animation* animation = *iter; @@ -928,6 +944,10 @@ bool UpdateManager::Animate(BufferIndex bufferIndex, float elapsedSeconds) mImpl->notificationManager.QueueNotification(&mImpl->animationPlaylist, std::move(mImpl->notifyRequiredAnimations)); } + DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_ANIMATION_ANIMATE", [&](std::ostringstream& oss) { + oss << "[" << mImpl->animations.Count() << "]"; + }); + return animationActive; } @@ -1016,6 +1036,15 @@ void UpdateManager::ForwardCompiledShadersToEventThread() void UpdateManager::UpdateRenderers(PropertyOwnerContainer& postPropertyOwners, BufferIndex bufferIndex) { + if(mImpl->renderers.Empty()) + { + return; + } + + DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_UPDATE_RENDERERS", [&](std::ostringstream& oss) { + oss << "[" << mImpl->renderers.Count() << "]"; + }); + for(const auto& rendererKey : mImpl->renderers) { // Apply constraints @@ -1028,6 +1057,8 @@ void UpdateManager::UpdateRenderers(PropertyOwnerContainer& postPropertyOwners, mImpl->renderingRequired = renderer->PrepareRender(bufferIndex) || mImpl->renderingRequired; } + + DALI_TRACE_END(gTraceFilter, "DALI_UPDATE_RENDERERS"); } void UpdateManager::UpdateNodes(PropertyOwnerContainer& postPropertyOwners, BufferIndex bufferIndex) @@ -1111,6 +1142,15 @@ uint32_t UpdateManager::Update(float elapsedSeconds, // We should not start skipping update steps or reusing lists until there has been two frames where nothing changes if(updateScene || mImpl->previousUpdateScene) { + DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_UPDATE_INTERNAL", [&](std::ostringstream& oss) { + oss << "[n:" << mImpl->nodes.Size() << ","; + oss << "c:" << mImpl->customObjects.Size() << ","; + oss << "a:" << mImpl->animations.Size() << ","; + oss << "r:" << mImpl->renderers.Size() << ","; + oss << "t:" << mImpl->textureSets.Size() << ","; + oss << "s:" << mImpl->shaders.Size() << "]"; + }); + // Animate bool animationActive = Animate(bufferIndex, elapsedSeconds); @@ -1237,6 +1277,8 @@ uint32_t UpdateManager::Update(float elapsedSeconds, DALI_LOG_INFO(gLogFilter, Debug::General, "Update: numberOfRenderTasks(%d), Render Instructions(%d)\n", numberOfRenderTasks, numberOfRenderInstructions); } + + DALI_TRACE_END(gTraceFilter, "DALI_UPDATE_INTERNAL"); } if(!uploadOnly) -- 2.7.4