/*
- * 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.
#include <sstream>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
#include <dali/internal/graphics/gles/egl-debug.h>
#include <dali/internal/graphics/gles/gl-implementation.h>
+#include <dali/internal/system/common/time-service.h>
#include <dali/public-api/dali-adaptor-common.h>
// EGL constants use C style casts
const std::string EGL_KHR_PARTIAL_UPDATE = "EGL_KHR_partial_update";
const std::string EGL_KHR_SWAP_BUFFERS_WITH_DAMAGE = "EGL_KHR_swap_buffers_with_damage";
+// Threshold time in miliseconds
+constexpr auto PERFORMANCE_LOG_THRESHOLD_TIME_ENV = "DALI_EGL_PERFORMANCE_LOG_THRESHOLD_TIME";
+
DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_EGL, true);
+
+static 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
namespace Dali
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
- Integration::Log::LogMessage(Integration::Log::DebugInfo,
+ Integration::Log::LogMessage(Integration::Log::INFO,
"EGL Information\n"
" PartialUpdate %d\n"
" Vendor: %s\n"
{
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)
{
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
{
+ uint32_t startTime = 0, endTime = 0;
+ if(mLogEnabled)
+ {
+ startTime = TimeService::GetMilliSeconds();
+ }
+
EGLint age = 0;
eglQuerySurface(mEglDisplay, eglSurface, EGL_BUFFER_AGE_EXT, &age);
if(age < 0)
age = 0;
}
- // 0 - invalid buffer
- // 1, 2, 3
- if(age > 3)
+ if(mLogEnabled)
{
- DALI_LOG_ERROR("EglImplementation::GetBufferAge() buffer age %d > 3\n", age);
- age = 0; // shoudn't be more than 3 back buffers, if there is just reset, I don't want to add extra history level
+ endTime = TimeService::GetMilliSeconds();
+ if(endTime - startTime > mLogThreshold)
+ {
+ DALI_LOG_DEBUG_INFO("eglQuerySurface takes long time! [%u ms]\n", endTime - startTime);
+ }
}
-
return age;
}
EGLBoolean result = mEglSetDamageRegionKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(damagedRects.data()), 1);
if(result == EGL_FALSE)
{
- DALI_LOG_ERROR("eglSetDamageRegionKHR(%d)\n", eglGetError());
+ DALI_LOG_ERROR("eglSetDamageRegionKHR(0x%x)\n", eglGetError());
}
}
}
return;
}
+ uint32_t startTime = 0, endTime = 0;
+ if(mLogEnabled)
+ {
+ startTime = TimeService::GetMilliSeconds();
+ }
+
#ifndef DALI_PROFILE_UBUNTU
if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
{
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);
+ }
+ }
}
}
DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
return false;
}
- Integration::Log::LogMessage(Integration::Log::DebugInfo, "Using OpenGL es %d.%d.\n", mGlesVersion / 10, mGlesVersion % 10);
+ Integration::Log::LogMessage(Integration::Log::INFO, "Using OpenGL es %d.%d.\n", mGlesVersion / 10, mGlesVersion % 10);
mContextAttribs.Clear();
if(mIsKhrCreateContextSupported)