Added element_count for sampler uniform arrays. 39/291639/2
authorDavid Steele <david.steele@samsung.com>
Wed, 19 Apr 2023 16:22:19 +0000 (17:22 +0100)
committerDavid Steele <david.steele@samsung.com>
Wed, 19 Apr 2023 16:33:38 +0000 (16:33 +0000)
Graphics interface didn't differentiate between non-array uniforms
and uniform array elements. Added element_count to show that.

(Used mainly in graphics backend implementation).

Change-Id: I7f3d9eead85dc029e93337c88bb38de1ce3e2fa5

dali/graphics-api/graphics-reflection.h
dali/graphics-api/graphics-types.h
dali/internal/render/shaders/program.cpp

index b6e187b..5203c65 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_REFLECTION_H
 
 /*
- * Copyright (c) 2021 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.
@@ -166,7 +166,9 @@ public:
   // Sampler
 
   /**
-   * @brief Gets all the sampler uniforms
+   * @brief Gets all the sampler uniforms. In the case of arrays of samplers,
+   * it contains only the name of the sampler array without the [N] size, but,
+   * the element count is set to N.
    *
    * @return A vector of the sampler uniforms
    */
index 6d6eb40..45b8e6f 100644 (file)
@@ -1150,6 +1150,7 @@ struct UniformInfo
   uint32_t     bufferIndex{0u};
   uint32_t     offset{0u};
   uint32_t     location{0u};
+  uint32_t     elementCount{0u};
 
   bool operator==(const UniformInfo& rhs)
   {
@@ -1158,7 +1159,8 @@ struct UniformInfo
            binding == rhs.binding &&
            bufferIndex == rhs.bufferIndex &&
            offset == rhs.offset &&
-           location == rhs.location;
+           location == rhs.location &&
+           elementCount == rhs.elementCount;
   }
 };
 
index 4cfbcb4..f6d9f97 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.
@@ -143,7 +143,7 @@ void Program::BuildReflection(const Graphics::Reflection& graphicsReflection)
   }
 
   // add samplers
-  auto samplers = graphicsReflection.GetSamplers();
+  auto samplers = graphicsReflection.GetSamplers(); // Only holds first element of arrays without [].
   for(const auto& sampler : samplers)
   {
     mReflection.emplace_back(ReflectionUniformInfo{CalculateHash(sampler.name), false, sampler});