[Tizen] CleanUp gles version setter + Get exact FBO MSAA sample level 13/288913/2 accepted/tizen/7.0/unified/20230302.015543
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 21 Feb 2023 19:53:33 +0000 (04:53 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Sun, 26 Feb 2023 13:34:52 +0000 (22:34 +0900)
Avoid some useless duplicated GLES version setter.
It will reduce complexity of gles version relative logics.

Change-Id: Ibffe2894d9fab34188861d77aad28593aea6ac54
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/graphics/gles-impl/gles-graphics-types.h
dali/internal/graphics/gles/egl-graphics.cpp
dali/internal/graphics/gles/egl-graphics.h
dali/internal/graphics/gles/gl-implementation.h

index 836439d..5e0025e 100644 (file)
@@ -1283,6 +1283,11 @@ struct GLIndexFormat
         format = GL_UNSIGNED_SHORT;
         break;
       }
+      case Format::R32_UINT:
+      {
+        format = GL_UNSIGNED_INT;
+        break;
+      }
       default:
       {
         format = 0;
index 15e17f1..d1f79e9 100644 (file)
@@ -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.
@@ -54,18 +54,6 @@ EglGraphics::~EglGraphics()
 {
 }
 
-void EglGraphics::SetGlesVersion(const int32_t glesVersion)
-{
-  if(mEglImplementation)
-  {
-    mEglImplementation->SetGlesVersion(glesVersion);
-  }
-
-  mGLES->SetGlesVersion(glesVersion);
-
-  mGraphicsController.SetGLESVersion(static_cast<Graphics::GLES::GLESVersion>(glesVersion));
-}
-
 void EglGraphics::SetIsSurfacelessContextSupported(const bool isSupported)
 {
   mGLES->SetIsSurfacelessContextSupported(isSupported);
@@ -152,7 +140,12 @@ void EglGraphics::ConfigureSurface(Dali::RenderSurfaceInterface* surface)
   if(!mEglImplementation->ChooseConfig(true, COLOR_DEPTH_32))
   {
     // Retry to use OpenGL es 2.0
-    SetGlesVersion(20);
+    mEglImplementation->SetGlesVersion(20);
+
+    // Mark gles that we will use gles 2.0 version.
+    // After this call, we will not change mGLES version anymore.
+    mGLES->SetGlesVersion(20);
+
     mEglImplementation->ChooseConfig(true, COLOR_DEPTH_32);
   }
 
@@ -176,8 +169,13 @@ void EglGraphics::ConfigureSurface(Dali::RenderSurfaceInterface* surface)
     }
   }
 
-  mGLES->ContextCreated();
-  SetGlesVersion(mGLES->GetGlesVersion());
+  mGLES->ContextCreated(); // After this call, we can know exact gles version.
+  auto glesVersion = mGLES->GetGlesVersion();
+
+  // Set more detail GLES version to egl and graphics controller.
+  // Note. usually we don't need EGL client's minor version. So don't need to choose config one more time.
+  mEglImplementation->SetGlesVersion(glesVersion);
+  mGraphicsController.SetGLESVersion(static_cast<Graphics::GLES::GLESVersion>(glesVersion));
 }
 
 void EglGraphics::Shutdown()
index 48dd0b7..88558ba 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
 
 /*
- * 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.
@@ -67,12 +67,6 @@ public:
   void ConfigureSurface(Dali::RenderSurfaceInterface* surface) override;
 
   /**
-   * Set gles version
-   * Default version is gles 3.0
-   */
-  void SetGlesVersion(const int32_t glesVersion);
-
-  /**
    * Set whether the surfaceless context is supported
    * @param[in] isSupported Whether the surfaceless context is supported
    */
index 2ba344a..b252942 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_GL_IMPLEMENTATION_H
 
 /*
- * 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.
@@ -43,9 +43,12 @@ namespace Adaptor
 {
 namespace
 {
-static constexpr int32_t     INITIAL_GLES_VERSION                         = 30;
-static constexpr int32_t     GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED = 32;
-static constexpr const char* LEGACY_SHADING_LANGUAGE_VERSION              = "100";
+static constexpr int32_t INITIAL_GLES_VERSION                         = 30;
+static constexpr int32_t GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED = 32;
+
+static constexpr int32_t MINIMUM_GLES_VERSION_GET_MAXIMUM_MULTISAMPLES_TO_TEXTURE = 30;
+
+static constexpr const char* LEGACY_SHADING_LANGUAGE_VERSION = "100";
 
 static constexpr const char* DEFAULT_SAMPLER_TYPE = "sampler2D";
 
@@ -108,6 +111,7 @@ public:
   {
     glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
 
+    // Since gles 2.0 didn't return well for GL_MAJOR_VERSION and GL_MINOR_VERSION,
     // Only change gles version for the device that support above gles 3.0.
     if(mGlesVersion >= INITIAL_GLES_VERSION)
     {
@@ -130,7 +134,18 @@ public:
 
     if(IsMultisampledRenderToTextureSupported())
     {
-      glGetIntegerv(GL_MAX_SAMPLES_EXT, &mMaxTextureSamples);
+      mMaxTextureSamples = 0;
+
+      if(mGlesVersion >= MINIMUM_GLES_VERSION_GET_MAXIMUM_MULTISAMPLES_TO_TEXTURE)
+      {
+        // Try to get maximum FBO MSAA sampling level from GL_RENDERBUFFER first.
+        // If false, than ask again to GL_MAX_SAMPLES_EXT.
+        GetInternalformativ(GL_RENDERBUFFER, GL_RGBA8, GL_SAMPLES, 1, &mMaxTextureSamples);
+      }
+      if(mMaxTextureSamples == 0)
+      {
+        glGetIntegerv(GL_MAX_SAMPLES_EXT, &mMaxTextureSamples);
+      }
     }
 
     if(!mShadingLanguageVersionCached)
@@ -360,7 +375,7 @@ public:
     return mMaxTextureSamples;
   }
 
-  int GetGlesVersion()
+  int32_t GetGlesVersion()
   {
     ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
     if(!mIsContextCreated)