Support to get shader language version for shader static API 37/305637/4
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 5 Feb 2024 14:47:04 +0000 (23:47 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Wed, 14 Feb 2024 06:43:21 +0000 (15:43 +0900)
Let we support to get shader language version

Change-Id: Ic9a1c2223633acb965f945d04179d20a9d7b89b7
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp
automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h
automated-tests/src/dali/utc-Dali-Shader.cpp
dali/integration-api/gl-abstraction.h
dali/integration-api/graphics-config.h
dali/internal/event/common/thread-local-storage.cpp
dali/internal/event/common/thread-local-storage.h
dali/internal/event/rendering/shader-impl.cpp
dali/internal/event/rendering/shader-impl.h
dali/public-api/rendering/shader.cpp
dali/public-api/rendering/shader.h

index b861c66..fc1eb65 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 3f04a6b..a70c21f 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 cc2f064..cf23d79 100644 (file)
@@ -351,6 +351,36 @@ int UtcDaliShaderAnimatedProperty01(void)
   END_TEST;
 }
 
+int UtcDaliShaderGetShaderLanguageVersion(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test get shader language version");
+
+  auto originalShaderVersion = application.GetGlAbstraction().GetShaderLanguageVersion();
+
+  try
+  {
+    uint32_t expectVersion                                = 100;
+    application.GetGlAbstraction().mShaderLanguageVersion = expectVersion;
+
+    DALI_TEST_EQUALS(Dali::Shader::GetShaderLanguageVersion(), expectVersion, TEST_LOCATION);
+
+    expectVersion                                         = 200;
+    application.GetGlAbstraction().mShaderLanguageVersion = expectVersion;
+
+    DALI_TEST_EQUALS(Dali::Shader::GetShaderLanguageVersion(), expectVersion, TEST_LOCATION);
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(false);
+  }
+
+  application.GetGlAbstraction().mShaderLanguageVersion = originalShaderVersion;
+
+  END_TEST;
+}
+
 int UtcDaliShaderAnimatedProperty02(void)
 {
   TestApplication application;
index f085354..366c137 100644 (file)
@@ -144,6 +144,12 @@ public:
   virtual bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) = 0;
 
   /**
+   * Returns shading language version.
+   * @Return shading language version.
+   */
+  virtual uint32_t GetShaderLanguageVersion() = 0;
+
+  /**
    * Returns shader prefix of shading language version.
    * @Return shader prefix of shading language version.
    */
index e0b3ddb..c2b892d 100644 (file)
@@ -48,6 +48,12 @@ public:
   virtual bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) = 0;
 
   /**
+   * Returns shading language version.
+   * @Return shading language version.
+   */
+  virtual uint32_t GetShaderLanguageVersion() = 0;
+
+  /**
    * Returns shader prefix of shading language version.
    * @Return shader prefix of shading language version.
    */
index 2cbab57..3f1ea43 100644 (file)
@@ -164,6 +164,11 @@ bool ThreadLocalStorage::IsBlendEquationSupported(DevelBlendEquation::Type blend
   return mCore->GetGraphicsConfig().IsBlendEquationSupported(blendEquation);
 }
 
+uint32_t ThreadLocalStorage::GetShaderLanguageVersion()
+{
+  return mCore->GetGraphicsConfig().GetShaderLanguageVersion();
+}
+
 std::string ThreadLocalStorage::GetShaderVersionPrefix()
 {
   return mCore->GetGraphicsConfig().GetShaderVersionPrefix();
index 8baef7d..8d4d537 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_THREAD_LOCAL_STORAGE_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.
@@ -176,6 +176,11 @@ public:
   bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation);
 
   /**
+   * @brief Returns shading language version.
+   */
+  uint32_t GetShaderLanguageVersion();
+
+  /**
    * @brief Returns shader prefix of shading language version.
    */
   std::string GetShaderVersionPrefix();
index becd736..de3c95e 100644 (file)
@@ -328,6 +328,12 @@ Shader::~Shader()
   }
 }
 
+uint32_t Shader::GetShaderLanguageVersion()
+{
+  Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();
+  return tls.GetShaderLanguageVersion();
+}
+
 std::string Shader::GetShaderVersionPrefix()
 {
   Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();
index 3b1482e..ccde312 100644 (file)
@@ -123,6 +123,11 @@ private:
 
 public:
   /**
+   * @copydoc Dali::Shader::GetShaderLanguageVersion()
+   */
+  static uint32_t GetShaderLanguageVersion();
+
+  /**
    * @copydoc Dali::Shader::GetShaderVersionPrefix()
    */
   static std::string GetShaderVersionPrefix();
index 04ec2cb..9445b7e 100644 (file)
@@ -60,6 +60,11 @@ Shader::Shader(Internal::Shader* pointer)
 {
 }
 
+uint32_t Shader::GetShaderLanguageVersion()
+{
+  return Dali::Internal::Shader::GetShaderLanguageVersion();
+}
+
 std::string Shader::GetShaderVersionPrefix()
 {
   return Dali::Internal::Shader::GetShaderVersionPrefix();
index 416c8dc..ae9f34f 100644 (file)
@@ -203,6 +203,15 @@ public:
   Shader& operator=(Shader&& rhs) noexcept;
 
   /**
+   * @brief Get the number of shading language version.
+   * @note This can potentially block until GL has been initialized
+   * when the first time any DALi application is launched in the system.
+   * @SINCE_2_3.11
+   * @return shader languange version as integer.
+   */
+  static uint32_t GetShaderLanguageVersion();
+
+  /**
    * @brief Get shader preprocessor of shading language version.
    * @note This can potentially block until GL has been initialized
    * when the first time any DALi application is launched in the system.