X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fadaptor%2Fcommon%2Fcombined-update-render-controller.cpp;h=4cc78b6a66e3ddd7c735ae15bf5abf2eab4cfeb9;hb=d5365301af718ee285f84452464ca030758eeb66;hp=0f1f71bb3f28f5e5e02c9c5b4c097a57a4c3d67d;hpb=b93ece0101184d2a4182eaa54e7957157845b1b1;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 0f1f71b..4cc78b6 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -25,15 +25,14 @@ #include "dali/public-api/common/dali-common.h" // INTERNAL INCLUDES -#include #include #include #include #include #include -#include #include #include +#include #include namespace Dali @@ -92,6 +91,7 @@ CombinedUpdateRenderController::CombinedUpdateRenderController(AdaptorInternalSe mEventThreadSemaphore(0), mSurfaceSemaphore(0), mUpdateRenderThreadWaitCondition(), + mPostRenderWaitCondition(), mAdaptorInterfaces(adaptorInterfaces), mPerformanceInterface(adaptorInterfaces.GetPerformanceInterface()), mCore(adaptorInterfaces.GetCore()), @@ -106,6 +106,7 @@ CombinedUpdateRenderController::CombinedUpdateRenderController(AdaptorInternalSe mDefaultHalfFrameNanoseconds(0u), mUpdateRequestCount(0u), mRunning(FALSE), + mThreadId(0), mThreadMode(threadMode), mUpdateRenderRunCount(0), mDestroyUpdateRenderThread(FALSE), @@ -307,8 +308,7 @@ void CombinedUpdateRenderController::ReplaceSurface(Dali::RenderSurfaceInterface // Start replacing the surface. { ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition); - mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will replace the surface now - mNewSurface = newSurface; + mNewSurface = newSurface; mUpdateRenderThreadWaitCondition.Notify(lock); } @@ -330,7 +330,6 @@ void CombinedUpdateRenderController::DeleteSurface(Dali::RenderSurfaceInterface* // Start replacing the surface. { ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition); - mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will delete the surface now mDeletedSurface = surface; mUpdateRenderThreadWaitCondition.Notify(lock); } @@ -366,7 +365,6 @@ void CombinedUpdateRenderController::ResizeSurface() { ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition); - mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will resize the surface now // Surface is resized and the surface resized count is increased. mSurfaceResized++; mUpdateRenderThreadWaitCondition.Notify(lock); @@ -408,6 +406,11 @@ void CombinedUpdateRenderController::AddSurface(Dali::RenderSurfaceInterface* su } } +int32_t CombinedUpdateRenderController::GetThreadId() const +{ + return mThreadId; +} + /////////////////////////////////////////////////////////////////////////////////////////////////// // EVENT THREAD /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -498,7 +501,8 @@ void CombinedUpdateRenderController::ProcessSleepRequest() void CombinedUpdateRenderController::UpdateRenderThread() { - SetThreadName("RenderThread\0"); + ThreadSettings::SetThreadName("RenderThread\0"); + mThreadId = ThreadSettings::GetThreadId(); // Install a function for logging mEnvironmentOptions.InstallLogFunction(); @@ -528,6 +532,7 @@ void CombinedUpdateRenderController::UpdateRenderThread() // Update time uint64_t lastFrameTime; TimeService::GetNanoseconds(lastFrameTime); + uint64_t lastMemPoolLogTime = lastFrameTime; LOG_UPDATE_RENDER("THREAD INITIALISED"); @@ -536,6 +541,8 @@ void CombinedUpdateRenderController::UpdateRenderThread() 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; @@ -545,7 +552,8 @@ void CombinedUpdateRenderController::UpdateRenderThread() LOG_UPDATE_RENDER_TRACE; // For thread safe - bool uploadOnly = mUploadWithoutRendering; + 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); @@ -592,8 +600,8 @@ void CombinedUpdateRenderController::UpdateRenderThread() // UPDATE ////////////////////////////// - const unsigned int currentTime = currentFrameStartTime / NANOSECONDS_PER_MILLISECOND; - const unsigned int nextFrameTime = currentTime + mDefaultFrameDurationMilliseconds; + const uint32_t currentTime = static_cast(currentFrameStartTime / NANOSECONDS_PER_MILLISECOND); + const uint32_t nextFrameTime = currentTime + static_cast(mDefaultFrameDurationMilliseconds); uint64_t noOfFramesSinceLastUpdate = 1; float frameDelta = 0.0f; @@ -646,6 +654,7 @@ void CombinedUpdateRenderController::UpdateRenderThread() // RENDER ////////////////////////////// + graphics.FrameStart(); mAdaptorInterfaces.GetDisplayConnectionInterface().ConsumeEvents(); if(mPreRenderCallback != NULL) @@ -676,14 +685,12 @@ void CombinedUpdateRenderController::UpdateRenderThread() // Upload shared resources mCore.PreRender(renderStatus, mForceClear); - if(!uploadOnly) + if(!uploadOnly || surfaceResized) { // Go through each window WindowContainer windows; mAdaptorInterfaces.GetWindowContainerInterface(windows); - bool sceneSurfaceResized; - for(auto&& window : windows) { Dali::Integration::Scene scene = window->GetScene(); @@ -693,9 +700,7 @@ void CombinedUpdateRenderController::UpdateRenderThread() { Integration::RenderStatus windowRenderStatus; - // Get Surface Resized flag - sceneSurfaceResized = scene.IsSurfaceRectChanged(); - windowSurface->SetIsResizing(sceneSurfaceResized); + const bool sceneSurfaceResized = scene.IsSurfaceRectChanged(); // clear previous frame damaged render items rects, buffer history is tracked on surface level mDamagedRects.clear(); @@ -749,6 +754,13 @@ void CombinedUpdateRenderController::UpdateRenderThread() 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 @@ -952,9 +964,9 @@ void CombinedUpdateRenderController::AddPerformanceMarker(PerformanceInterface:: void CombinedUpdateRenderController::PostRenderComplete() { - ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition); + ConditionalWait::ScopedLock lock(mPostRenderWaitCondition); mPostRendering = FALSE; - mUpdateRenderThreadWaitCondition.Notify(lock); + mPostRenderWaitCondition.Notify(lock); } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -963,19 +975,19 @@ void CombinedUpdateRenderController::PostRenderComplete() void CombinedUpdateRenderController::PostRenderStarted() { - ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition); + ConditionalWait::ScopedLock lock(mPostRenderWaitCondition); mPostRendering = TRUE; } void CombinedUpdateRenderController::PostRenderWaitForCompletion() { - ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition); + ConditionalWait::ScopedLock lock(mPostRenderWaitCondition); while(mPostRendering && !mNewSurface && // We should NOT wait if we're replacing the surface !mDeletedSurface && // We should NOT wait if we're deleting the surface !mDestroyUpdateRenderThread) { - mUpdateRenderThreadWaitCondition.Wait(lock); + mPostRenderWaitCondition.Wait(lock); } }