/*
- * 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/public-api/common/dali-common.h"
// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/thread-settings.h>
#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
#include <dali/internal/adaptor/common/adaptor-internal-services.h>
#include <dali/internal/adaptor/common/combined-update-render-controller-debug.h>
#include <dali/internal/graphics/common/graphics-interface.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/graphics/gles/egl-implementation.h>
#include <dali/internal/system/common/environment-options.h>
#include <dali/internal/system/common/time-service.h>
+#include <dali/internal/thread/common/thread-settings-impl.h>
#include <dali/internal/window-system/common/window-impl.h>
namespace Dali
mDefaultHalfFrameNanoseconds(0u),
mUpdateRequestCount(0u),
mRunning(FALSE),
+ mThreadId(0),
mThreadMode(threadMode),
mUpdateRenderRunCount(0),
mDestroyUpdateRenderThread(FALSE),
}
}
+int32_t CombinedUpdateRenderController::GetThreadId() const
+{
+ return mThreadId;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
// EVENT THREAD
///////////////////////////////////////////////////////////////////////////////////////////////////
void CombinedUpdateRenderController::UpdateRenderThread()
{
- SetThreadName("RenderThread\0");
+ ThreadSettings::SetThreadName("RenderThread\0");
+ mThreadId = ThreadSettings::GetThreadId();
// Install a function for logging
mEnvironmentOptions.InstallLogFunction();
// Update time
uint64_t lastFrameTime;
TimeService::GetNanoseconds(lastFrameTime);
+ uint64_t lastMemPoolLogTime = lastFrameTime;
LOG_UPDATE_RENDER("THREAD INITIALISED");
uint64_t timeToSleepUntil = 0;
int extraFramesDropped = 0;
+ const uint64_t memPoolInterval = 1e9 * float(mEnvironmentOptions.GetMemoryPoolInterval());
+
const unsigned int renderToFboInterval = mEnvironmentOptions.GetRenderToFboInterval();
const bool renderToFboEnabled = 0u != renderToFboInterval;
unsigned int frameCount = 0u;
{
LOG_UPDATE_RENDER_TRACE;
+ // For thread safe
+ bool uploadOnly = mUploadWithoutRendering;
+ unsigned int surfaceResized = mSurfaceResized;
+
// Performance statistics are logged upon a VSYNC tick so use this point for a VSync marker
AddPerformanceMarker(PerformanceInterface::VSYNC);
// UPDATE
//////////////////////////////
- const unsigned int currentTime = currentFrameStartTime / NANOSECONDS_PER_MILLISECOND;
- const unsigned int nextFrameTime = currentTime + mDefaultFrameDurationMilliseconds;
+ const uint32_t currentTime = static_cast<uint32_t>(currentFrameStartTime / NANOSECONDS_PER_MILLISECOND);
+ const uint32_t nextFrameTime = currentTime + static_cast<uint32_t>(mDefaultFrameDurationMilliseconds);
uint64_t noOfFramesSinceLastUpdate = 1;
float frameDelta = 0.0f;
Integration::UpdateStatus updateStatus;
AddPerformanceMarker(PerformanceInterface::UPDATE_START);
+ TRACE_UPDATE_RENDER_BEGIN("DALI_UPDATE");
mCore.Update(frameDelta,
currentTime,
nextFrameTime,
updateStatus,
renderToFboEnabled,
- isRenderingToFbo);
+ isRenderingToFbo,
+ uploadOnly);
+ TRACE_UPDATE_RENDER_END("DALI_UPDATE");
AddPerformanceMarker(PerformanceInterface::UPDATE_END);
unsigned int keepUpdatingStatus = updateStatus.KeepUpdating();
// RENDER
//////////////////////////////
+ graphics.FrameStart();
mAdaptorInterfaces.GetDisplayConnectionInterface().ConsumeEvents();
if(mPreRenderCallback != NULL)
Integration::RenderStatus renderStatus;
AddPerformanceMarker(PerformanceInterface::RENDER_START);
+ TRACE_UPDATE_RENDER_BEGIN("DALI_RENDER");
// Upload shared resources
- mCore.PreRender(renderStatus, mForceClear, mUploadWithoutRendering);
+ mCore.PreRender(renderStatus, mForceClear);
- if(!mUploadWithoutRendering)
+ if(!uploadOnly || surfaceResized)
{
// Go through each window
WindowContainer windows;
mAdaptorInterfaces.GetWindowContainerInterface(windows);
- bool sceneSurfaceResized;
-
for(auto&& window : windows)
{
Dali::Integration::Scene scene = window->GetScene();
{
Integration::RenderStatus windowRenderStatus;
- // Get Surface Resized flag
- sceneSurfaceResized = scene.IsSurfaceRectChanged();
- windowSurface->SetIsResizing(sceneSurfaceResized);
-
- windowSurface->InitializeGraphics();
+ const bool sceneSurfaceResized = scene.IsSurfaceRectChanged();
// clear previous frame damaged render items rects, buffer history is tracked on surface level
mDamagedRects.clear();
}
}
- if(!mUploadWithoutRendering)
+ if(!uploadOnly)
{
- graphics.ActivateResourceContext();
+ graphics.PostRender();
}
- mCore.PostRender(mUploadWithoutRendering);
+ mCore.PostRender();
//////////////////////////////
// DELETE SURFACE
SurfaceDeleted();
}
+ TRACE_UPDATE_RENDER_END("DALI_RENDER");
AddPerformanceMarker(PerformanceInterface::RENDER_END);
+ // if the memory pool interval is set and has elapsed, log the graphics memory pools
+ if(0 < memPoolInterval && memPoolInterval < lastFrameTime - lastMemPoolLogTime)
+ {
+ lastMemPoolLogTime = lastFrameTime;
+ graphics.LogMemoryPools();
+ }
+
mForceClear = false;
// Trigger event thread to request Update/Render thread to sleep if update not required