Support gles2.0 device also use BuildUniformBlockReflection() API 26/305626/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 5 Feb 2024 11:49:06 +0000 (20:49 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 5 Feb 2024 12:09:43 +0000 (21:09 +0900)
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>
dali/internal/graphics/gles/gles2-implementation.h

index 527cebf..57cb40f 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