Add performance check logs 07/292007/1
authorHeeyong Song <heeyong.song@samsung.com>
Wed, 26 Apr 2023 06:52:47 +0000 (15:52 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 26 Apr 2023 06:52:52 +0000 (15:52 +0900)
Change-Id: Ib4c0cb4addb4356645ace5297d5b1217d4884cc5

dali/internal/graphics/gles/egl-implementation.cpp
dali/internal/graphics/gles/egl-implementation.h
dali/internal/graphics/gles/gl-implementation.h

index e389671..feea271 100644 (file)
@@ -191,6 +191,9 @@ bool EglImplementation::InitializeGles(EGLNativeDisplayType display, bool isOwnS
     mPartialUpdateRequired = false;
   }
 
+  mLogThreshold = GetPerformanceLogThresholdTime();
+  mLogEnabled   = mLogThreshold > 0 ? true : false;
+
   mGlesInitialized = true;
 
   // We want to display this information all the time, so use the LogMessage directly
@@ -395,6 +398,12 @@ void EglImplementation::SwapBuffers(EGLSurface& eglSurface)
 {
   if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
   {
+    uint32_t startTime = 0, endTime = 0;
+    if(mLogEnabled)
+    {
+      startTime = TimeService::GetMilliSeconds();
+    }
+
 #ifndef DALI_PROFILE_UBUNTU
     if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
     {
@@ -414,16 +423,22 @@ void EglImplementation::SwapBuffers(EGLSurface& eglSurface)
       mSwapBufferCountAfterResume++;
     }
 #endif //DALI_PROFILE_UBUNTU
+
+    if(mLogEnabled)
+    {
+      endTime = TimeService::GetMilliSeconds();
+      if(endTime - startTime > mLogThreshold)
+      {
+        DALI_LOG_DEBUG_INFO("eglSwapBuffers takes long time! [%u ms]\n", endTime - startTime);
+      }
+    }
   }
 }
 
 EGLint EglImplementation::GetBufferAge(EGLSurface& eglSurface) const
 {
-  static uint32_t logThreshold = GetPerformanceLogThresholdTime();
-  static bool     logEnabled   = logThreshold > 0 ? true : false;
-
-  uint32_t startTime, endTime;
-  if(logEnabled)
+  uint32_t startTime = 0, endTime = 0;
+  if(mLogEnabled)
   {
     startTime = TimeService::GetMilliSeconds();
   }
@@ -436,10 +451,10 @@ EGLint EglImplementation::GetBufferAge(EGLSurface& eglSurface) const
     age = 0;
   }
 
-  if(logEnabled)
+  if(mLogEnabled)
   {
     endTime = TimeService::GetMilliSeconds();
-    if(endTime - startTime > logThreshold)
+    if(endTime - startTime > mLogThreshold)
     {
       DALI_LOG_DEBUG_INFO("eglQuerySurface takes long time! [%u ms]\n", endTime - startTime);
     }
@@ -474,6 +489,12 @@ void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector<Re
       return;
     }
 
+    uint32_t startTime = 0, endTime = 0;
+    if(mLogEnabled)
+    {
+      startTime = TimeService::GetMilliSeconds();
+    }
+
 #ifndef DALI_PROFILE_UBUNTU
     if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
     {
@@ -496,6 +517,15 @@ void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector<Re
       mSwapBufferCountAfterResume++;
     }
 #endif //DALI_PROFILE_UBUNTU
+
+    if(mLogEnabled)
+    {
+      endTime = TimeService::GetMilliSeconds();
+      if(endTime - startTime > mLogThreshold)
+      {
+        DALI_LOG_DEBUG_INFO("eglSwapBuffersWithDamageKHR takes long time! [%u ms]\n", endTime - startTime);
+      }
+    }
   }
 }
 
index 7712658..bee38dc 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_EGL_IMPLEMENTATION_H
 
 /*
- * Copyright (c) 2021 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.
@@ -259,8 +259,9 @@ private:
   typedef std::vector<EGLSurface> EglWindowSurfaceContainer;
   EglWindowSurfaceContainer       mEglWindowSurfaces; ///< The EGL surface for the window
 
-  int32_t mMultiSamplingLevel;
-  int32_t mGlesVersion;
+  int32_t  mMultiSamplingLevel;
+  int32_t  mGlesVersion;
+  uint32_t mLogThreshold{0};
 
   ColorDepth mColorDepth;
 
@@ -272,6 +273,7 @@ private:
   bool mPartialUpdateRequired;
   bool mIsSurfacelessContextSupported;
   bool mIsKhrCreateContextSupported;
+  bool mLogEnabled{false};
 
   uint32_t                           mSwapBufferCountAfterResume;
   PFNEGLSETDAMAGEREGIONKHRPROC       mEglSetDamageRegionKHR;
index 5dac669..2d41b7d 100644 (file)
 #include <memory>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/internal/graphics/gles/gl-extensions-support.h>
 #include <dali/internal/graphics/gles/gles-abstraction.h>
 #include <dali/internal/graphics/gles/gles2-implementation.h>
 #include <dali/internal/graphics/gles/gles3-implementation.h>
+#include <dali/internal/system/common/time-service.h>
 
 namespace Dali
 {
@@ -68,6 +70,16 @@ static constexpr const char* OES_EGL_IMAGE_EXTERNAL_STRING = "#extension GL_OES_
 
 static constexpr const char* OES_EGL_IMAGE_EXTERNAL_STRING_ESSL3 = "#extension GL_OES_EGL_image_external_essl3:require\n";
 
+// Threshold time in miliseconds
+constexpr auto PERFORMANCE_LOG_THRESHOLD_TIME_ENV = "DALI_EGL_PERFORMANCE_LOG_THRESHOLD_TIME";
+
+uint32_t GetPerformanceLogThresholdTime()
+{
+  auto     timeString = Dali::EnvironmentVariable::GetEnvironmentVariable(PERFORMANCE_LOG_THRESHOLD_TIME_ENV);
+  uint32_t time       = timeString ? static_cast<uint32_t>(std::atoi(timeString)) : 0u;
+  return time;
+}
+
 } // namespace
 
 /**
@@ -170,6 +182,9 @@ public:
       }
     }
 
+    mLogThreshold = GetPerformanceLogThresholdTime();
+    mLogEnabled   = mLogThreshold > 0 ? true : false;
+
     {
       ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
       mIsContextCreated = true;
@@ -540,7 +555,22 @@ public:
 
   void Clear(GLbitfield mask) override
   {
+    uint32_t startTime = 0, endTime = 0;
+    if(mLogEnabled)
+    {
+      startTime = TimeService::GetMilliSeconds();
+    }
+
     glClear(mask);
+
+    if(mLogEnabled)
+    {
+      endTime = TimeService::GetMilliSeconds();
+      if(endTime - startTime > mLogThreshold)
+      {
+        DALI_LOG_DEBUG_INFO("glClear takes long time! [%u ms]\n", endTime - startTime);
+      }
+    }
   }
 
   void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override
@@ -1722,9 +1752,11 @@ private:
   std::string     mFragmentShaderPrefix;
   int32_t         mGlesVersion;
   int32_t         mShadingLanguageVersion;
+  uint32_t        mLogThreshold{0};
   bool            mShadingLanguageVersionCached;
   bool            mIsSurfacelessContextSupported;
   bool            mIsContextCreated;
+  bool            mLogEnabled{false};
 };
 
 } // namespace Adaptor