[Tizen] Support to get shader language version + Support gles2.0 device 08/306408/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 5 Feb 2024 14:50:10 +0000 (23:50 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 21 Feb 2024 05:50:38 +0000 (14:50 +0900)
This is a combination of 2 commits.

Support to get shader language version

Let we make shader language version getter as virtual function,
so some graphics config can use it.

Change-Id: I6752c21b105046b1872ba0e97df7a7ed2d453e8e
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
Support gles2.0 device also use BuildUniformBlockReflection() API

Since glGetActiveUniformsiv only implements on gles3.1 or over,
BuildUniformBLockReflection API doesn't work well on gles2.0 devices.

To support it, let we implement naive way of glGetActiveUniform, so
let we make it didn't break down at least.

Change-Id: I3f50f2e74763968d19712d5dc37377f283000383
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
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/graphics/gles/gl-implementation.h
dali/internal/graphics/gles/gles2-implementation.h

index b861c666dc69320e4e931e22270dedd5566a92ad..fc1eb656f4d043193df8a22c755e10cd6071a29c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -209,6 +209,11 @@ bool TestGlAbstraction::IsBlendEquationSupported(DevelBlendEquation::Type blendE
   return true;
 }
 
+uint32_t TestGlAbstraction::GetShaderLanguageVersion()
+{
+  return mShaderLanguageVersion;
+}
+
 std::string TestGlAbstraction::GetShaderVersionPrefix()
 {
   return std::string("");
index 3f04a6bd8027011c3a50061c22040514dc1c1b3f..a70c21f40c50941975feeb75cb4aa03dbf9252fc 100644 (file)
@@ -2,7 +2,7 @@
 #define TEST_GL_ABSTRACTION_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -77,6 +77,8 @@ public:
 
   bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) override;
 
+  uint32_t GetShaderLanguageVersion();
+
   std::string GetShaderVersionPrefix();
 
   std::string GetVertexShaderPrefix();
@@ -2712,6 +2714,8 @@ public:
   TraceCallStack mViewportTrace;
 
   // Shaders & Uniforms
+  uint32_t mShaderLanguageVersion{320u};
+
   GLuint                                 mLastShaderIdUsed;
   GLuint                                 mLastProgramIdUsed{0u};
   GLuint                                 mLastUniformIdUsed;
index 733743bdd69936f178a0a220a69bcd0bae88a5f1..1cc2c183de487e72e7e1ed9ff1baa74a545b5349 100644 (file)
@@ -208,6 +208,11 @@ public:
     return false;
   }
 
+  uint32_t GetShaderLanguageVersion() override
+  {
+    return static_cast<uint32_t>(GetShadingLanguageVersion());
+  }
+
   std::string GetShaderVersionPrefix() override
   {
     if(mShaderVersionPrefix == "")
index 527cebfff5976cf2f80d68316aa5fee0d740adda..57cb40f8558c552a7af76d27dcac926e27a858be 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_GLES2_IMPLEMENTATION_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -371,6 +371,40 @@ public:
   void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override
   {
     DALI_LOG_ERROR("glGetActiveUniformsiv is not supported in OpenGL es 2.0\n");
+
+    int maxUniformNameLength = 0;
+    glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformNameLength);
+    char* name = new char[maxUniformNameLength + 1];
+
+    for(auto i = 0; i < uniformCount; ++i)
+    {
+      GLint  elementCount;
+      GLint  written;
+      GLenum type;
+      glGetActiveUniform(program, uniformIndices[i], maxUniformNameLength, &written, &elementCount, &type, name);
+
+      if(pname == GL_UNIFORM_TYPE)
+      {
+        params[i] = type;
+      }
+      else if(pname == GL_UNIFORM_SIZE)
+      {
+        params[i] = elementCount;
+      }
+      else if(pname == GL_UNIFORM_NAME_LENGTH)
+      {
+        params[i] = written;
+      }
+      else if(pname == GL_UNIFORM_BLOCK_INDEX)
+      {
+        params[i] = -1; // Not support
+      }
+      else if(pname == GL_UNIFORM_OFFSET)
+      {
+        params[i] = 0; // Not support
+      }
+    }
+    delete[] name;
   }
 
   GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override