Check EGL_KHR_Create_Context extension, Prevent glFinish without makeCurrent, Remove... 10/209310/1
authorSeungho, Baek <sbsh.baek@samsung.com>
Thu, 4 Jul 2019 23:42:34 +0000 (08:42 +0900)
committerSeungho, Baek <sbsh.baek@samsung.com>
Thu, 4 Jul 2019 23:43:09 +0000 (08:43 +0900)
 - If EGL_KHR_Create_Context extension is not supported, Do not use EGL_CONTEXT_MINOR_VERSION_KHR
 - Without any Current Context, do not call glFinish
 - Remove ARM condition in the ChooseConfig

Change-Id: I3d0ac92b4ac2cb1404716a4581d654fa7c6d41ac
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
dali/internal/graphics/gles/egl-implementation.cpp
dali/internal/graphics/gles/egl-implementation.h

index 76fa78a..68d7925 100755 (executable)
@@ -35,7 +35,9 @@
 
 namespace
 {
+  const uint32_t CHECK_EXTENSION_NUMBER = 2;
   const std::string EGL_KHR_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
+  const std::string EGL_KHR_CREATE_CONTEXT = "EGL_KHR_create_context";
 }
 
 namespace Dali
@@ -78,7 +80,8 @@ EglImplementation::EglImplementation( int multiSamplingLevel,
   mIsWindow( true ),
   mDepthBufferRequired( depthBufferRequired == Integration::DepthBufferAvailable::TRUE ),
   mStencilBufferRequired( stencilBufferRequired == Integration::StencilBufferAvailable::TRUE ),
-  mIsSurfacelessContextSupported( false )
+  mIsSurfacelessContextSupported( false ),
+  mIsKhrCreateContextSupported( false )
 {
 }
 
@@ -116,14 +119,20 @@ bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwn
 
   // Query EGL extensions to check whether surfaceless context is supported
   const char* const extensionStr = eglQueryString( mEglDisplay, EGL_EXTENSIONS );
-  std::istringstream stream(extensionStr);
+  std::istringstream stream( extensionStr );
   std::string currentExtension;
-  while ( std::getline( stream, currentExtension, ' ' ) )
+  uint32_t extensionCheckCount = 0;
+  while( std::getline( stream, currentExtension, ' ' ) && extensionCheckCount < CHECK_EXTENSION_NUMBER )
   {
-    if ( currentExtension == EGL_KHR_SURFACELESS_CONTEXT )
+    if( currentExtension == EGL_KHR_SURFACELESS_CONTEXT )
     {
       mIsSurfacelessContextSupported = true;
-      break;
+      extensionCheckCount++;
+    }
+    if( currentExtension == EGL_KHR_CREATE_CONTEXT )
+    {
+      mIsKhrCreateContextSupported = true;
+      extensionCheckCount++;
     }
   }
 
@@ -211,7 +220,10 @@ void EglImplementation::MakeContextCurrent( EGLSurface eglSurface, EGLContext eg
 
   if(mIsOwnSurface)
   {
-    glFinish();
+    if( mCurrentEglContext != EGL_NO_CONTEXT )
+    {
+      glFinish();
+    }
 
     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, eglContext );
 
@@ -240,7 +252,10 @@ void EglImplementation::MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglS
 
   if(mIsOwnSurface)
   {
-    glFinish();
+    if( mCurrentEglContext != EGL_NO_CONTEXT )
+    {
+      glFinish();
+    }
 
     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, mEglContext );
 
@@ -350,11 +365,7 @@ bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
 
   if( mGlesVersion >= 30 )
   {
-#ifdef _ARCH_ARM_
     configAttribs.PushBack( EGL_OPENGL_ES3_BIT_KHR );
-#else
-    configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
-#endif // _ARCH_ARM_
   }
   else
   {
@@ -409,7 +420,7 @@ bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
     if( mGlesVersion >= 30 )
     {
       mEglConfig = NULL;
-      DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retring to use OpenGL es 2.0.");
+      DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retrying to use OpenGL es 2.0.");
       return false;
     }
 
@@ -454,7 +465,7 @@ bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
   Integration::Log::LogMessage(Integration::Log::DebugInfo, "Using OpenGL es %d.%d.\n", mGlesVersion / 10, mGlesVersion % 10 );
 
   mContextAttribs.Clear();
-  if( mGlesVersion >= 30 )
+  if( mIsKhrCreateContextSupported )
   {
     mContextAttribs.Reserve(5);
     mContextAttribs.PushBack( EGL_CONTEXT_MAJOR_VERSION_KHR );
@@ -466,7 +477,7 @@ bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
   {
     mContextAttribs.Reserve(3);
     mContextAttribs.PushBack( EGL_CONTEXT_CLIENT_VERSION );
-    mContextAttribs.PushBack( 2 );
+    mContextAttribs.PushBack( mGlesVersion / 10 );
   }
   mContextAttribs.PushBack( EGL_NONE );
 
index 03c35f4..2901b9e 100644 (file)
@@ -239,6 +239,7 @@ private:
   bool                 mDepthBufferRequired;
   bool                 mStencilBufferRequired;
   bool                 mIsSurfacelessContextSupported;
+  bool                 mIsKhrCreateContextSupported;
 };
 
 } // namespace Adaptor