/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
#include <dali/integration-api/debug.h>
#include <dali/integration-api/events/event.h>
#include <dali/integration-api/gl-context-helper-abstraction.h>
-#include <dali/integration-api/gl-sync-abstraction.h>
#include <dali/integration-api/platform-abstraction.h>
#include <dali/integration-api/processor-interface.h>
#include <dali/integration-api/render-controller.h>
+#include <dali/integration-api/trace.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/animation/animation-playlist.h>
#include <dali/internal/render/common/performance-monitor.h>
#include <dali/internal/render/common/render-manager.h>
-#include <dali/internal/render/gl-resources/context.h>
-using Dali::Internal::SceneGraph::DiscardQueue;
using Dali::Internal::SceneGraph::RenderManager;
using Dali::Internal::SceneGraph::RenderQueue;
using Dali::Internal::SceneGraph::UpdateManager;
// The Update for frame N+1 may be processed whilst frame N is being rendered.
const uint32_t MAXIMUM_UPDATE_COUNT = 2u;
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
+
#if defined(DEBUG_ENABLED)
Debug::Filter* gCoreFilter = Debug::Filter::New(Debug::Concise, false, "LOG_CORE");
#endif
using Integration::Event;
using Integration::GlAbstraction;
using Integration::GlContextHelperAbstraction;
-using Integration::GlSyncAbstraction;
using Integration::PlatformAbstraction;
using Integration::RenderController;
using Integration::RenderStatus;
mPlatform(platform),
mGraphicsController(graphicsController),
mProcessingEvent(false),
- mForceNextUpdate(false)
+ mForceNextUpdate(false),
+ mProcessorUnregistered(false),
+ mPostProcessorUnregistered(false)
{
// Create the thread local storage
CreateThreadLocalStorage();
RenderQueue& renderQueue = mRenderManager->GetRenderQueue();
- mDiscardQueue = new DiscardQueue(renderQueue);
-
mUpdateManager = new UpdateManager(*mNotificationManager,
*mAnimationPlaylist,
*mPropertyNotificationManager,
- *mDiscardQueue,
renderController,
*mRenderManager,
renderQueue,
mUpdateManager->SetShaderSaver(*mShaderFactory);
GetImplementation(Dali::TypeRegistry::Get()).CallInitFunctions();
+
+ DALI_LOG_RELEASE_INFO("Node size: %lu\n", sizeof(Dali::Internal::SceneGraph::Node));
+ DALI_LOG_RELEASE_INFO("Renderer size: %lu\n", sizeof(Dali::Internal::SceneGraph::Renderer));
+ DALI_LOG_RELEASE_INFO("RenderItem size: %lu\n", sizeof(Dali::Internal::SceneGraph::RenderItem));
}
Core::~Core()
void Core::ContextCreated()
{
- mRenderManager->ContextCreated();
}
void Core::ContextDestroyed()
{
- mRenderManager->ContextDestroyed();
}
-void Core::Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo)
+void Core::Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo, bool uploadOnly)
{
// set the time delta so adaptor can easily print FPS with a release build with 0 as
// it is cached by frametime
lastVSyncTimeMilliseconds,
nextVSyncTimeMilliseconds,
renderToFboEnabled,
- isRenderingToFbo);
+ isRenderingToFbo,
+ uploadOnly);
// Check the Notification Manager message queue to set needsNotification
status.needsNotification = mNotificationManager->MessagesToProcess();
// Any message to update will wake it up anyways
}
-void Core::PreRender(RenderStatus& status, bool forceClear, bool uploadOnly)
+void Core::PreRender(RenderStatus& status, bool forceClear)
{
- mRenderManager->PreRender(status, forceClear, uploadOnly);
+ mRenderManager->PreRender(status, forceClear);
}
void Core::PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects)
mRenderManager->RenderScene(status, scene, renderToFbo, clippingRect);
}
-void Core::PostRender(bool uploadOnly)
+void Core::PostRender()
{
- mRenderManager->PostRender(uploadOnly);
+ mUpdateManager->PostRender();
+ mRenderManager->PostRender();
}
void Core::SceneCreated()
// Run the size negotiation after event processing finished signal
mRelayoutController->Relayout();
+ // Run any registered post processors
+ RunPostProcessors();
+
// Rebuild depth tree after event processing has finished
for(auto scene : scenes)
{
return MAXIMUM_UPDATE_COUNT;
}
-void Core::RegisterProcessor(Integration::Processor& processor)
+void Core::RegisterProcessor(Integration::Processor& processor, bool postProcessor)
{
- mProcessors.PushBack(&processor);
+ if(postProcessor)
+ {
+ mPostProcessors.PushBack(&processor);
+ }
+ else
+ {
+ mProcessors.PushBack(&processor);
+ }
}
-void Core::UnregisterProcessor(Integration::Processor& processor)
+void Core::UnregisterProcessor(Integration::Processor& processor, bool postProcessor)
{
- auto iter = std::find(mProcessors.Begin(), mProcessors.End(), &processor);
- if(iter != mProcessors.End())
+ if(postProcessor)
{
- mProcessors.Erase(iter);
+ auto iter = std::find(mPostProcessors.Begin(), mPostProcessors.End(), &processor);
+ if(iter != mPostProcessors.End())
+ {
+ mPostProcessors.Erase(iter);
+ mPostProcessorUnregistered = true;
+ }
+ }
+ else
+ {
+ auto iter = std::find(mProcessors.Begin(), mProcessors.End(), &processor);
+ if(iter != mProcessors.End())
+ {
+ mProcessors.Erase(iter);
+ mProcessorUnregistered = true;
+ }
}
}
void Core::RunProcessors()
{
- // Copy processor pointers to prevent changes to vector affecting loop iterator.
- Dali::Vector<Integration::Processor*> processors(mProcessors);
+ if(mProcessors.Count() != 0)
+ {
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_CORE_RUN_PROCESSORS");
+
+ // Copy processor pointers to prevent changes to vector affecting loop iterator.
+ Dali::Vector<Integration::Processor*> processors(mProcessors);
+
+ // To prevent accessing processor unregistered during the loop
+ mProcessorUnregistered = false;
+
+ for(auto processor : processors)
+ {
+ if(processor)
+ {
+ if(!mProcessorUnregistered)
+ {
+ processor->Process(false);
+ }
+ else
+ {
+ // Run processor if the processor is still in the list.
+ // It may be removed during the loop.
+ auto iter = std::find(mProcessors.Begin(), mProcessors.End(), processor);
+ if(iter != mProcessors.End())
+ {
+ processor->Process(false);
+ }
+ }
+ }
+ }
+ }
+}
- for(auto processor : processors)
+void Core::RunPostProcessors()
+{
+ if(mPostProcessors.Count() != 0)
{
- if(processor)
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_CORE_RUN_POST_PROCESSORS");
+
+ // Copy processor pointers to prevent changes to vector affecting loop iterator.
+ Dali::Vector<Integration::Processor*> processors(mPostProcessors);
+
+ // To prevent accessing processor unregistered during the loop
+ mPostProcessorUnregistered = false;
+
+ for(auto processor : processors)
{
- processor->Process();
+ if(processor)
+ {
+ if(!mPostProcessorUnregistered)
+ {
+ processor->Process(true);
+ }
+ else
+ {
+ // Run processor if the processor is still in the list.
+ // It may be removed during the loop.
+ auto iter = std::find(mPostProcessors.Begin(), mPostProcessors.End(), processor);
+ if(iter != mPostProcessors.End())
+ {
+ processor->Process(true);
+ }
+ }
+ }
}
}
}
return *(mObjectRegistry.Get());
}
+void Core::LogMemoryPools() const
+{
+ uint32_t animationPoolCapacity = SceneGraph::Animation::GetMemoryPoolCapacity();
+ uint32_t renderItemPoolCapacity = SceneGraph::RenderItem::GetMemoryPoolCapacity();
+ uint32_t relayoutItemPoolCapacity = mRelayoutController->GetMemoryPoolCapacity();
+ uint32_t rendererPoolCapacity = SceneGraph::Renderer::GetMemoryPoolCapacity();
+ uint32_t textureSetPoolCapacity = SceneGraph::TextureSet::GetMemoryPoolCapacity();
+ uint32_t renderTaskPoolCapacity = SceneGraph::RenderTaskList::GetMemoryPoolCapacity();
+ uint32_t nodePoolCapacity = SceneGraph::Node::GetMemoryPoolCapacity();
+
+ DALI_LOG_RELEASE_INFO(
+ "\nMemory Pool capacities:\n"
+ " Animations: %lu\n"
+ " RenderItems: %lu\n"
+ " RelayoutItems: %lu\n"
+ " Renderers: %lu\n"
+ " TextureSets: %lu\n"
+ " RenderTasks: %lu\n"
+ " Nodes: %lu\n",
+ animationPoolCapacity,
+ renderItemPoolCapacity,
+ relayoutItemPoolCapacity,
+ rendererPoolCapacity,
+ textureSetPoolCapacity,
+ renderTaskPoolCapacity,
+ nodePoolCapacity);
+
+ uint32_t updateQCapacity = mUpdateManager->GetUpdateMessageQueueCapacity();
+ uint32_t renderQCapacity = mUpdateManager->GetRenderMessageQueueCapacity();
+
+ DALI_LOG_RELEASE_INFO(
+ "\nMessage Queue capacities:\n"
+ " UpdateQueue: %lu\n"
+ " RenderQueue: %lu\n",
+ updateQCapacity,
+ renderQCapacity);
+
+ size_t renderInstructionCapacity = mUpdateManager->GetRenderInstructionCapacity();
+ DALI_LOG_RELEASE_INFO("\nRenderInstruction capacity: %lu\n", renderInstructionCapacity);
+}
+
EventThreadServices& Core::GetEventThreadServices()
{
return *this;