Blend Equation Advanced Supporting 99/224499/30
authorSeungho, Baek <sbsh.baek@samsung.com>
Tue, 11 Feb 2020 05:50:42 +0000 (14:50 +0900)
committerseungho <seungho@seungho.tn.corp.samsungelectronics.net>
Fri, 30 Oct 2020 02:13:37 +0000 (11:13 +0900)
Change-Id: Ie82734305328537e8fceee6bdfb7d644bd1ae2ef
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
14 files changed:
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.h
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/combined-update-render-controller.cpp
dali/internal/graphics/gles/egl-implementation.cpp
dali/internal/graphics/gles/egl-implementation.h
dali/internal/graphics/gles/gl-extensions.cpp
dali/internal/graphics/gles/gl-extensions.h
dali/internal/graphics/gles/gl-implementation.h
dali/internal/graphics/gles/gles-abstraction.h
dali/internal/graphics/gles/gles2-implementation.h
dali/internal/graphics/gles/gles3-implementation.h
dali/internal/system/common/configuration-manager.cpp
dali/internal/system/common/configuration-manager.h

index a694eeb..9e8c7a8 100644 (file)
@@ -112,6 +112,31 @@ bool TestGlAbstraction::IsSurfacelessContextSupported() const
   return true;
 }
 
+bool TestGlAbstraction::IsAdvancedBlendEquationSupported()
+{
+  return true;
+}
+
+bool TestGlAbstraction::IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
+{
+  return true;
+}
+
+std::string TestGlAbstraction::GetShaderVersionPrefix()
+{
+  return std::string("");
+}
+
+std::string TestGlAbstraction::GetVertexShaderPrefix()
+{
+  return std::string("");
+}
+
+std::string TestGlAbstraction::GetFragmentShaderPrefix()
+{
+  return std::string("");
+}
+
 bool TestGlAbstraction::TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const
 {
   return ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
index 99dca10..861f4ae 100644 (file)
@@ -61,6 +61,16 @@ public:
 
   bool IsSurfacelessContextSupported() const override;
 
+  bool IsAdvancedBlendEquationSupported() override;
+
+  bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) override;
+
+  std::string GetShaderVersionPrefix();
+
+  std::string GetVertexShaderPrefix();
+
+  std::string GetFragmentShaderPrefix();
+
   bool TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const override;
 
   /* OpenGL ES 2.0 */
@@ -1889,6 +1899,10 @@ public:
   {
   }
 
+  inline void BlendBarrier(void)
+  {
+  }
+
 private:
   inline void AddUniformCallToTraceStack(GLint location, std::string& value)
   {
index e75d156..189503b 100755 (executable)
@@ -400,6 +400,13 @@ void Adaptor::Start()
     Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( maxTextureSize );
   }
 
+  // Set cached isAdvancedBlendEquationSupported
+  GraphicsInterface* graphics = mGraphics.get(); // This interface is temporary until Core has been updated to match
+  auto eglGraphics = static_cast<EglGraphics *>( graphics );
+  GlImplementation& mGLES = eglGraphics->GetGlesInterface();
+  mGLES.SetIsAdvancedBlendEquationSupported( mConfigurationManager->IsAdvancedBlendEquationSupported() );
+  mGLES.SetShadingLanguageVersion( mConfigurationManager->GetShadingLanguageVersion() );
+
   ProcessCoreEvents(); // Ensure any startup messages are processed.
 
   // Initialize the image loader plugin
index eb28975..a0f690e 100644 (file)
@@ -561,7 +561,9 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     }
   }
 
-  eglGraphics->GetGlesInterface().ContextCreated();
+  GlImplementation& gles = eglGraphics->GetGlesInterface();
+  gles.ContextCreated();
+  eglGraphics->SetGlesVersion( gles.GetGlesVersion() );
 
   // Tell core it has a context
   mCore.ContextCreated();
index 984b4e1..ee4e08e 100755 (executable)
@@ -37,6 +37,7 @@ namespace
 {
   const uint32_t THRESHOLD_SWAPBUFFER_COUNT = 5;
   const uint32_t CHECK_EXTENSION_NUMBER = 4;
+  const uint32_t EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT = 15;
   const std::string EGL_KHR_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
   const std::string EGL_KHR_CREATE_CONTEXT = "EGL_KHR_create_context";
   const std::string EGL_KHR_PARTIAL_UPDATE = "EGL_KHR_partial_update";
@@ -131,38 +132,51 @@ bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwn
     mIsOwnSurface = isOwnSurface;
   }
 
-  // Query EGL extensions to check whether surfaceless context is supported
+  const char* const versionStr = eglQueryString( mEglDisplay, EGL_VERSION );
   const char* const extensionStr = eglQueryString( mEglDisplay, EGL_EXTENSIONS );
-  std::istringstream stream( extensionStr );
-  std::string currentExtension;
+
+  // Query EGL extensions to check whether required extensions are supported
+  std::istringstream versionStream( versionStr );
+  std::string majorVersion, minorVersion;
+  std::getline( versionStream, majorVersion, '.' );
+  std::getline( versionStream, minorVersion );
   uint32_t extensionCheckCount = 0;
+  if( stoul( majorVersion ) * 10 + stoul( minorVersion ) >= EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT )
+  {
+    mIsSurfacelessContextSupported = true;
+    mIsKhrCreateContextSupported = true;
+    extensionCheckCount += 2;
+  }
+
+  std::istringstream stream(extensionStr);
+  std::string currentExtension;
   bool isKhrPartialUpdateSupported = false;
   bool isKhrSwapBuffersWithDamageSupported = false;
-  while( std::getline( stream, currentExtension, ' ' ) && extensionCheckCount < CHECK_EXTENSION_NUMBER )
+  while(std::getline(stream, currentExtension, ' ') && extensionCheckCount < CHECK_EXTENSION_NUMBER)
   {
-    if( currentExtension == EGL_KHR_SURFACELESS_CONTEXT )
+    if(currentExtension == EGL_KHR_SURFACELESS_CONTEXT && !mIsSurfacelessContextSupported)
     {
       mIsSurfacelessContextSupported = true;
       extensionCheckCount++;
     }
-    if( currentExtension == EGL_KHR_CREATE_CONTEXT )
+    if(currentExtension == EGL_KHR_CREATE_CONTEXT && !mIsKhrCreateContextSupported)
     {
       mIsKhrCreateContextSupported = true;
       extensionCheckCount++;
     }
-    if( currentExtension == EGL_KHR_PARTIAL_UPDATE )
+    if(currentExtension == EGL_KHR_PARTIAL_UPDATE)
     {
       isKhrPartialUpdateSupported = true;
       extensionCheckCount++;
     }
-    if( currentExtension == EGL_KHR_SWAP_BUFFERS_WITH_DAMAGE )
+    if(currentExtension == EGL_KHR_SWAP_BUFFERS_WITH_DAMAGE)
     {
       isKhrSwapBuffersWithDamageSupported = true;
       extensionCheckCount++;
     }
   }
 
-  if( !isKhrPartialUpdateSupported || !isKhrSwapBuffersWithDamageSupported  )
+  if(!isKhrPartialUpdateSupported || !isKhrSwapBuffersWithDamageSupported)
   {
     mPartialUpdateRequired = false;
   }
@@ -178,7 +192,7 @@ bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwn
       "            Extensions:    %s\n",
       mPartialUpdateRequired,
       eglQueryString( mEglDisplay, EGL_VENDOR ),
-      eglQueryString( mEglDisplay, EGL_VERSION ),
+      versionStr,
       eglQueryString( mEglDisplay, EGL_CLIENT_APIS ),
       extensionStr);
 
index 6d9e3c9..8a23ef1 100644 (file)
@@ -65,7 +65,7 @@ public:
 public:
 
   /**
-   * (Called from  ECoreX::RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
+   * (Called from RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
    * Initialize GL
    * @param display The display
    * @param isOwnSurface whether the surface is own or not
index 429cbd5..54c781a 100644 (file)
@@ -33,9 +33,6 @@ namespace Internal
 namespace Adaptor
 {
 
-namespace ECoreX
-{
-
 GlExtensions::GlExtensions()
 :
 #ifdef GL_EXT_discard_framebuffer
@@ -118,6 +115,27 @@ void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const G
 #endif
 }
 
+bool GlExtensions::BlendBarrierKHR()
+{
+  // initialize extension on first use as on some hw platforms a context
+  // has to be bound for the extensions to return correct pointer
+  if( !mInitialized )
+  {
+    Initialize();
+  }
+
+#ifdef GL_KHR_blend_equation_advanced
+  if (mBlendBarrierKHR)
+  {
+    mBlendBarrierKHR();
+    return true;
+  }
+  return false;
+#endif
+
+  return false;
+}
+
 void GlExtensions::Initialize()
 {
   mInitialized = true;
@@ -130,9 +148,11 @@ void GlExtensions::Initialize()
   mGlGetProgramBinaryOES = reinterpret_cast< PFNGLGETPROGRAMBINARYOESPROC >( eglGetProcAddress("glGetProgramBinaryOES") );
   mGlProgramBinaryOES = reinterpret_cast< PFNGLPROGRAMBINARYOESPROC >( eglGetProcAddress("glProgramBinaryOES") );
 #endif
-}
 
-} // namespace ECoreX
+#ifdef GL_KHR_blend_equation_advanced
+  mBlendBarrierKHR = reinterpret_cast< PFNGLBLENDBARRIERKHRPROC >( eglGetProcAddress("glBlendBarrierKHR") );
+#endif
+}
 
 } // namespace Adaptor
 
index b3a8085..887c714 100644 (file)
@@ -34,9 +34,6 @@ namespace Internal
 namespace Adaptor
 {
 
-namespace ECoreX
-{
-
 /**
  * GlExtensions class provides GL extensions support
  */
@@ -91,6 +88,12 @@ public:
    */
   void ProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
 
+  /**
+   * KHR extension
+   * Specify a boundary between passes when using advanced blend equations.
+   */
+  bool BlendBarrierKHR ();
+
 private:
 
   /**
@@ -107,12 +110,14 @@ private:
   PFNGLPROGRAMBINARYOESPROC mGlProgramBinaryOES;
 #endif
 
+#ifdef GL_KHR_blend_equation_advanced
+  PFNGLBLENDBARRIERKHRPROC mBlendBarrierKHR;
+#endif
+
   bool mInitialized;
 
 };
 
-} // namespace ECoreX
-
 } // namespace Adaptor
 
 } // namespace Internal
index 1cd7ed9..5f1078e 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_GL_IMPLEMENTATION_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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 <memory>
 #include <cstdlib>
 #include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
 #include <dali/integration-api/gl-abstraction.h>
 #include <dali/devel-api/threading/conditional-wait.h>
+#include <dali/internal/graphics/common/egl-include.h>
 
 // INTERNAL INCLUDES
 #include <dali/internal/graphics/gles/gles-abstraction.h>
@@ -39,6 +41,24 @@ namespace Internal
 namespace Adaptor
 {
 
+namespace
+{
+
+const int32_t INITIAL_GLES_VERSION = 30;
+const int32_t GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED = 32;
+const char* KHR_BLEND_EQUATION_ADVANCED = "GL_KHR_blend_equation_advanced";
+
+const char* FRAGMENT_SHADER_ADVANCED_BLEND_EQUATION_PREFIX =
+  "#extension GL_KHR_blend_equation_advanced : enable\n"
+
+  "#if GL_KHR_blend_equation_advanced==1 || __VERSION__>=320\n"
+  "  layout(blend_support_all_equations) out;\n"
+  "#endif\n";
+
+const char* FRAGMENT_SHADER_OUTPUT_COLOR_STRING =
+  "out mediump vec4 fragColor;\n";
+}
+
 /**
  * GlImplementation is a concrete implementation for GlAbstraction.
  * The class provides an OpenGL-ES 2.0 or 3.0 implementation.
@@ -49,11 +69,16 @@ class GlImplementation : public Dali::Integration::GlAbstraction
 
 public:
   GlImplementation()
-    : mGlesVersion( 30 ),
+    : mContextCreatedWaitCondition(),
+      mMaxTextureSize( 0 ),
+      mVertexShaderPrefix(""),
+      mGlesVersion( INITIAL_GLES_VERSION ),
+      mShadingLanguageVersion( 100 ),
+      mShadingLanguageVersionCached( false ),
       mIsSurfacelessContextSupported( false ),
-      mIsContextCreated( false ),
-      mContextCreatedWaitCondition(),
-      mMaxTextureSize( 0 )
+      mIsAdvancedBlendEquationSupportedCached( false ),
+      mIsAdvancedBlendEquationSupported( false ),
+      mIsContextCreated( false )
   {
     mImpl.reset( new Gles3Implementation() );
   }
@@ -74,16 +99,64 @@ public:
   {
     glGetIntegerv( GL_MAX_TEXTURE_SIZE, &mMaxTextureSize );
 
-    if( !mIsContextCreated )
+    GLint majorVersion, minorVersion;
+    glGetIntegerv( GL_MAJOR_VERSION, &majorVersion );
+    glGetIntegerv( GL_MINOR_VERSION, &minorVersion );
+    mGlesVersion = majorVersion * 10 + minorVersion;
+
+    if( mGlesVersion >= GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED )
+    {
+      mIsAdvancedBlendEquationSupported = true;
+    }
+    else
     {
-      mContextCreatedWaitCondition.Notify();
+      // when mIsAdvancedBlendEquationSupported is cached, we don't need to check all the extensions.
+      if( !mIsAdvancedBlendEquationSupportedCached )
+      {
+        const char* const  extensionStr = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
+        std::istringstream stream(extensionStr);
+        std::string currentExtension;
+        while(std::getline(stream, currentExtension, ' '))
+        {
+          if(currentExtension == KHR_BLEND_EQUATION_ADVANCED)
+          {
+            mIsAdvancedBlendEquationSupported = true;
+            break;
+          }
+        }
+      }
+    }
+
+    if(!mShadingLanguageVersionCached)
+    {
+      std::istringstream shadingLanguageVersionStream(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
+      std::string token;
+      uint32_t tokenCount = 0;
+      while(std::getline(shadingLanguageVersionStream, token, ' '))
+      {
+        if(tokenCount == 3 && token == "ES")
+        {
+          std::getline(shadingLanguageVersionStream, token, '.');
+          mShadingLanguageVersion = std::atoi(token.c_str());
+          mShadingLanguageVersion *= 100;
+          std::getline(shadingLanguageVersionStream, token, '.');
+          mShadingLanguageVersion += std::atoi(token.c_str());
+          break;
+        }
+        tokenCount++;
+      }
+    }
+
+    {
+      ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
+      mIsContextCreated = true;
+      mContextCreatedWaitCondition.Notify( lock );
     }
-    mIsContextCreated = true;
   }
 
   void SetGlesVersion( const int32_t glesVersion )
   {
-    if( mGlesVersion != glesVersion )
+    if( mGlesVersion / 10 != glesVersion / 10 )
     {
       mGlesVersion = glesVersion;
       if( mGlesVersion >= 30 )
@@ -107,6 +180,131 @@ public:
     return mIsSurfacelessContextSupported;
   }
 
+  void SetIsAdvancedBlendEquationSupported(const bool isSupported)
+  {
+    mIsAdvancedBlendEquationSupported       = isSupported;
+    mIsAdvancedBlendEquationSupportedCached = true;
+  }
+
+  bool IsAdvancedBlendEquationSupported()
+  {
+    ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
+    if(!mIsContextCreated && !mIsAdvancedBlendEquationSupportedCached)
+    {
+      mContextCreatedWaitCondition.Wait( lock );
+    }
+    return mIsAdvancedBlendEquationSupported;
+  }
+
+  bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
+  {
+    switch(blendEquation)
+    {
+      case DevelBlendEquation::ADD:
+      case DevelBlendEquation::SUBTRACT:
+      case DevelBlendEquation::REVERSE_SUBTRACT:
+      {
+        return true;
+      }
+      case DevelBlendEquation::MIN:
+      case DevelBlendEquation::MAX:
+      {
+        return (GetGlesVersion() >= 30);
+      }
+      case DevelBlendEquation::MULTIPLY:
+      case DevelBlendEquation::SCREEN:
+      case DevelBlendEquation::OVERLAY:
+      case DevelBlendEquation::DARKEN:
+      case DevelBlendEquation::LIGHTEN:
+      case DevelBlendEquation::COLOR_DODGE:
+      case DevelBlendEquation::COLOR_BURN:
+      case DevelBlendEquation::HARD_LIGHT:
+      case DevelBlendEquation::SOFT_LIGHT:
+      case DevelBlendEquation::DIFFERENCE:
+      case DevelBlendEquation::EXCLUSION:
+      case DevelBlendEquation::HUE:
+      case DevelBlendEquation::SATURATION:
+      case DevelBlendEquation::COLOR:
+      case DevelBlendEquation::LUMINOSITY:
+      {
+        return IsAdvancedBlendEquationSupported();
+      }
+
+      default:
+      {
+        return false;
+      }
+    }
+
+    return false;
+  }
+
+  std::string GetShaderVersionPrefix()
+  {
+    if(mShaderVersionPrefix == "")
+    {
+      mShaderVersionPrefix = "#version " + std::to_string( GetShadingLanguageVersion() );
+      if(GetShadingLanguageVersion() < 300)
+      {
+        mShaderVersionPrefix += "\n";
+      }
+      else
+      {
+        mShaderVersionPrefix += " es\n";
+      }
+    }
+    return mShaderVersionPrefix;
+  }
+
+  std::string GetVertexShaderPrefix()
+  {
+    if(mVertexShaderPrefix == "")
+    {
+      mVertexShaderPrefix = GetShaderVersionPrefix();
+
+      if(GetShadingLanguageVersion() < 300)
+      {
+        mVertexShaderPrefix += "#define INPUT attribute\n";
+        mVertexShaderPrefix += "#define OUTPUT varying\n";
+      }
+      else
+      {
+        mVertexShaderPrefix += "#define INPUT in\n";
+        mVertexShaderPrefix += "#define OUTPUT out\n";
+      }
+    }
+    return mVertexShaderPrefix;
+  }
+
+  std::string GetFragmentShaderPrefix()
+  {
+    if(mFragmentShaderPrefix == "")
+    {
+      mFragmentShaderPrefix = GetShaderVersionPrefix();
+
+      if(GetShadingLanguageVersion() < 300)
+      {
+        mFragmentShaderPrefix += "#define INPUT varying\n";
+        mFragmentShaderPrefix += "#define OUT_COLOR gl_FragColor\n";
+        mFragmentShaderPrefix += "#define TEXTURE texture2D\n";
+      }
+      else
+      {
+        mFragmentShaderPrefix += "#define INPUT in\n";
+        mFragmentShaderPrefix += "#define OUT_COLOR fragColor\n";
+        mFragmentShaderPrefix += "#define TEXTURE texture\n";
+
+        if(IsAdvancedBlendEquationSupported())
+        {
+          mFragmentShaderPrefix += FRAGMENT_SHADER_ADVANCED_BLEND_EQUATION_PREFIX;
+        }
+
+        mFragmentShaderPrefix += FRAGMENT_SHADER_OUTPUT_COLOR_STRING;
+      }
+    }
+    return mFragmentShaderPrefix;
+  }
+
   bool TextureRequiresConverting( const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage ) const override
   {
     bool convert = ( ( imageGlFormat == GL_RGB ) && ( textureGlFormat == GL_RGBA ) );
@@ -120,13 +318,40 @@ public:
 
   int GetMaxTextureSize()
   {
+    ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
     if( !mIsContextCreated )
     {
-      mContextCreatedWaitCondition.Wait();
+      mContextCreatedWaitCondition.Wait( lock );
     }
     return mMaxTextureSize;
   }
 
+  int GetGlesVersion()
+  {
+    ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
+    if( !mIsContextCreated )
+    {
+      mContextCreatedWaitCondition.Wait( lock );
+    }
+    return mGlesVersion;
+  }
+
+  void SetShadingLanguageVersion( int shadingLanguageVersion )
+  {
+    mShadingLanguageVersion = shadingLanguageVersion;
+    mShadingLanguageVersionCached = true;
+  }
+
+  int GetShadingLanguageVersion()
+  {
+    ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
+    if( !mIsContextCreated && !mShadingLanguageVersionCached )
+    {
+      mContextCreatedWaitCondition.Wait( lock );
+    }
+    return mShadingLanguageVersion;
+  }
+
   /* OpenGL ES 2.0 */
 
   void ActiveTexture( GLenum texture ) override
@@ -1361,13 +1586,29 @@ public:
     mImpl->GetInternalformativ( target, internalformat, pname, bufSize, params );
   }
 
+  void BlendBarrier(void)
+  {
+    if(mIsAdvancedBlendEquationSupported)
+    {
+      mImpl->BlendBarrier();
+    }
+  }
+
 private:
-  int32_t mGlesVersion;
-  bool mIsSurfacelessContextSupported;
-  bool mIsContextCreated;
-  ConditionalWait mContextCreatedWaitCondition;
-  GLint mMaxTextureSize;
   std::unique_ptr<GlesAbstraction> mImpl;
+
+  ConditionalWait                  mContextCreatedWaitCondition;
+  GLint                            mMaxTextureSize;
+  std::string                      mShaderVersionPrefix;
+  std::string                      mVertexShaderPrefix;
+  std::string                      mFragmentShaderPrefix;
+  int32_t                          mGlesVersion;
+  int32_t                          mShadingLanguageVersion;
+  bool                             mShadingLanguageVersionCached;
+  bool                             mIsSurfacelessContextSupported;
+  bool                             mIsAdvancedBlendEquationSupportedCached;
+  bool                             mIsAdvancedBlendEquationSupported;
+  bool                             mIsContextCreated;
 };
 
 } // namespace Adaptor
index 8dc63e6..6334b27 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_GLES_ABSTRACTION_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -244,6 +244,8 @@ public:
   virtual void TexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth ) = 0;
 
   virtual void GetInternalformativ( GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params ) = 0;
+
+  virtual void BlendBarrier( void ) = 0;
 };
 
 } // namespace Adaptor
index 5bab59b..cee1c77 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_GLES2_IMPLEMENTATION_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -574,8 +574,13 @@ public:
     DALI_LOG_ERROR( "glGetInternalformativ is not supported in OpenGL es 2.0\n" );
   }
 
+  void BlendBarrier( void ) override
+  {
+    DALI_LOG_ERROR( "BlendBarrier is not supported in OpenGL es 2.0\n" );
+  }
+
 private:
-  ECoreX::GlExtensions mGlExtensions;
+  GlExtensions mGlExtensions;
 };
 
 } // namespace Adaptor
index ace3849..173cd6a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_GLES3_IMPLEMENTATION_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -20,6 +20,7 @@
 
  // EXTERNAL INCLUDES
 #include <GLES3/gl3.h>
+#include <GLES3/gl32.h>
 
 // INTERNAL INCLUDES
 #include <dali/internal/graphics/gles/gles-abstraction.h>
@@ -560,6 +561,17 @@ public:
   {
     glGetInternalformativ( target, internalformat, pname, bufSize, params );
   }
+
+  void BlendBarrier( void ) override
+  {
+    if(!mGlExtensions.BlendBarrierKHR())
+    {
+      glBlendBarrier();
+    }
+  }
+
+private:
+  GlExtensions mGlExtensions;
 };
 
 } // namespace Adaptor
index 63b62dc..e37ae78 100644 (file)
@@ -43,6 +43,8 @@ namespace
 
 const std::string SYSTEM_CACHE_FILE = "gpu-environment.conf";
 const std::string DALI_ENV_MULTIPLE_WINDOW_SUPPORT = "DALI_ENV_MULTIPLE_WINDOW_SUPPORT";
+const std::string DALI_BLEND_EQUATION_ADVANCED_SUPPORT = "DALI_BLEND_EQUATION_ADVANCED_SUPPORT";
+const std::string DALI_GLSL_VERSION = "DALI_GLSL_VERSION";
 
 bool RetrieveKeyFromConfigFile( std::iostream& stream, const std::string& key, std::string& value )
 {
@@ -81,8 +83,11 @@ ConfigurationManager::ConfigurationManager( std::string systemCachePath, EglGrap
   mThreadController( threadController ),
   mMaxTextureSize( 0u ),
   mIsMultipleWindowSupported( true ),
-  mMaxTextureSizeCached( false ) ,
-  mIsMultipleWindowSupportedCached( false )
+  mIsAdvancedBlendEquationSupported( true ),
+  mMaxTextureSizeCached( false ),
+  mIsMultipleWindowSupportedCached( false ),
+  mIsAdvancedBlendEquationSupportedCached( false ),
+  mGlslVersionCached( false )
 {
 }
 
@@ -104,16 +109,30 @@ void ConfigurationManager::RetrieveKeysFromConfigFile( const std::string& config
       mMaxTextureSizeCached = true;
     }
 
+    if( !mGlslVersionCached &&
+        RetrieveKeyFromConfigFile( stream, DALI_GLSL_VERSION, value ) )
+    {
+      mGlslVersion = std::atoi( value.c_str() );
+      mGlslVersionCached = true;
+    }
+
     if( !mIsMultipleWindowSupportedCached &&
         RetrieveKeyFromConfigFile( stream, DALI_ENV_MULTIPLE_WINDOW_SUPPORT, value ) )
     {
       mIsMultipleWindowSupported = std::atoi( value.c_str() );
       mIsMultipleWindowSupportedCached = true;
     }
+
+    if( !mIsAdvancedBlendEquationSupportedCached &&
+        RetrieveKeyFromConfigFile( stream, DALI_BLEND_EQUATION_ADVANCED_SUPPORT, value ) )
+    {
+      mIsAdvancedBlendEquationSupported = std::atoi( value.c_str() );
+      mIsAdvancedBlendEquationSupportedCached = true;
+    }
   }
 }
 
-unsigned int ConfigurationManager::GetMaxTextureSize()
+uint32_t ConfigurationManager::GetMaxTextureSize()
 {
   if( !mMaxTextureSizeCached )
   {
@@ -141,6 +160,43 @@ unsigned int ConfigurationManager::GetMaxTextureSize()
   return mMaxTextureSize;
 }
 
+uint32_t ConfigurationManager::GetShadingLanguageVersion()
+{
+  if ( !mGlslVersionCached )
+  {
+    RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+
+    if ( !mGlslVersionCached )
+    {
+      EglImplementation& eglImpl = mEglGraphics->GetEglImplementation();
+      if ( !eglImpl.IsGlesInitialized() )
+      {
+        // Wait until GLES is initialised, but this will happen once.
+        // This method blocks until the render thread has initialised the graphics.
+        mThreadController->WaitForGraphicsInitialization();
+      }
+
+      // Query from GLES and save the cache
+      mGlslVersion = mEglGraphics->GetGlesInterface().GetShadingLanguageVersion();
+      DALI_LOG_ERROR("mGlslVersion : %d\n", mGlslVersion);
+      mGlslVersionCached = true;
+
+      Dali::FileStream configFile( mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT );
+      std::fstream& stream = dynamic_cast<std::fstream&>( configFile.GetStream() );
+      if ( stream.is_open() )
+      {
+        stream << DALI_GLSL_VERSION << " " << mGlslVersion << std::endl;
+      }
+      else
+      {
+        DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+      }
+    }
+  }
+
+  return mGlslVersion;
+}
+
 bool ConfigurationManager::IsMultipleWindowSupported()
 {
   if ( !mIsMultipleWindowSupportedCached )
@@ -177,6 +233,42 @@ bool ConfigurationManager::IsMultipleWindowSupported()
   return mIsMultipleWindowSupported;
 }
 
+bool ConfigurationManager::IsAdvancedBlendEquationSupported()
+{
+  if ( !mIsAdvancedBlendEquationSupportedCached )
+  {
+    RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+
+    if ( !mIsAdvancedBlendEquationSupportedCached )
+    {
+      EglImplementation& eglImpl = mEglGraphics->GetEglImplementation();
+      if ( !eglImpl.IsGlesInitialized() )
+      {
+        // Wait until GLES is initialised, but this will happen once.
+        // This method blocks until the render thread has initialised the graphics.
+        mThreadController->WaitForGraphicsInitialization();
+      }
+
+      // Query from GLES and save the cache
+      mIsAdvancedBlendEquationSupported = mEglGraphics->GetGlesInterface().IsAdvancedBlendEquationSupported();
+      mIsAdvancedBlendEquationSupportedCached = true;
+
+      Dali::FileStream configFile( mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT );
+      std::fstream& stream = dynamic_cast<std::fstream&>( configFile.GetStream() );
+      if ( stream.is_open() )
+      {
+        stream << DALI_BLEND_EQUATION_ADVANCED_SUPPORT << " " << mIsAdvancedBlendEquationSupported << std::endl;
+      }
+      else
+      {
+        DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+      }
+    }
+  }
+
+  return mIsAdvancedBlendEquationSupported;
+}
+
 } // Adaptor
 
 } // Internal
index a6721ee..a3375ac 100644 (file)
@@ -37,7 +37,8 @@ class ThreadController;
 
 /**
  * This class retrieves and caches the system configuration.
- *
+ * Some of the methods in this class can block system until GL has been initialized,
+ * only at the first time the DALi application is launched in the system.
  */
 class ConfigurationManager
 {
@@ -62,7 +63,13 @@ public:
    * @brief Get the maximum texture size.
    * @return The maximum texture size
    */
-  unsigned int GetMaxTextureSize();
+  uint32_t GetMaxTextureSize();
+
+  /**
+   * @brief Get the GLSL version that the system supports
+   * @return the GLSL version.
+   */
+  uint32_t GetShadingLanguageVersion();
 
   /**
    * @brief Check whether multiple window is supported
@@ -70,6 +77,12 @@ public:
    */
   bool IsMultipleWindowSupported();
 
+  /**
+   * @brief Check whether blend equation advanced (extension) is supported
+   * @return Whether blend equation advanced (extension is supported
+   */
+  bool IsAdvancedBlendEquationSupported();
+
   // Deleted copy constructor.
   ConfigurationManager( const ConfigurationManager& ) = delete;
 
@@ -88,9 +101,13 @@ private: // Data
   EglGraphics* mEglGraphics;                     ///< EGL graphics
   ThreadController* mThreadController;           ///< The thread controller
   unsigned int mMaxTextureSize;                  ///< The largest texture that the GL can handle
+  unsigned int mGlslVersion;                     ///< The GLSL version that the system supports.
   bool mIsMultipleWindowSupported:1;             ///< Whether multiple window is supported by the GLES
+  bool mIsAdvancedBlendEquationSupported:1;      ///< Whether blend equation advanced (extension) is supported by the GLES
   bool mMaxTextureSizeCached:1;                  ///< Whether we have checked the maximum texture size
   bool mIsMultipleWindowSupportedCached:1;       ///< Whether we have checked the support of multiple window
+  bool mIsAdvancedBlendEquationSupportedCached:1;///< Whether we have checked the support of blend equation advanced (extension)
+  bool mGlslVersionCached:1;                     ///< Whether we have checked the GLSL version
 };
 
 } // Adaptor