Revert "[Tizen] Reducing uniform memory usage"
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Wed, 15 Nov 2023 05:59:00 +0000 (14:59 +0900)
committerJaehyun Cho <jae_hyun.cho@samsung.com>
Wed, 15 Nov 2023 05:59:00 +0000 (14:59 +0900)
This reverts commit 2d542f4fd964ea262371313366475c8f4eaafb85.

dali/internal/event/common/property-input-impl.h
dali/internal/render/renderers/render-renderer.cpp
dali/internal/render/renderers/render-renderer.h
dali/internal/update/common/animatable-property.h
dali/internal/update/common/inherited-property.h
dali/internal/update/gestures/gesture-properties.h
dali/internal/update/manager/transform-manager-property.h

index ab2ee093944068ce9850e27448d6960c0557a2da..2bb3a3b0e227e2e4972fd3a8f4c7780e037b490b 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_PROPERTY_INPUT_IMPL_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -181,18 +181,6 @@ public:
     return reinterpret_cast<const Matrix&>(*this);
   }
 
-  /**
-   * Retrieve the address of the property value. Only for use
-   * when writing uniforms.
-   */
-  virtual const void* GetValueAddress(BufferIndex bufferIndex) const = 0;
-
-  /**
-   * Retrieve the size of the property value for use in copying.
-   * Only for use when writing uniforms.
-   */
-  virtual size_t GetValueSize() const = 0;
-
   // Accessors for Constraint functions
 
   /**
index 27ec4b9efe6b96203309e27663bc7c963f5de358..8eb8120ca167ee7d52dfe1b0aeb0696241fe823c 100644 (file)
@@ -47,6 +47,98 @@ uint32_t      mvpBufferIndex;
 
 namespace
 {
+// Helper to get the property value getter by type
+typedef const float& (PropertyInputImpl::*FuncGetter)(BufferIndex) const;
+constexpr FuncGetter GetPropertyValueGetter(Property::Type type)
+{
+  switch(type)
+  {
+    case Property::BOOLEAN:
+    {
+      return FuncGetter(&PropertyInputImpl::GetBoolean);
+    }
+    case Property::INTEGER:
+    {
+      return FuncGetter(&PropertyInputImpl::GetInteger);
+    }
+    case Property::FLOAT:
+    {
+      return FuncGetter(&PropertyInputImpl::GetFloat);
+    }
+    case Property::VECTOR2:
+    {
+      return FuncGetter(&PropertyInputImpl::GetVector2);
+    }
+    case Property::VECTOR3:
+    {
+      return FuncGetter(&PropertyInputImpl::GetVector3);
+    }
+    case Property::VECTOR4:
+    {
+      return FuncGetter(&PropertyInputImpl::GetVector4);
+    }
+    case Property::MATRIX3:
+    {
+      return FuncGetter(&PropertyInputImpl::GetMatrix3);
+    }
+    case Property::MATRIX:
+    {
+      return FuncGetter(&PropertyInputImpl::GetMatrix);
+    }
+    default:
+    {
+      return nullptr;
+    }
+  }
+}
+
+/**
+ * Helper function that returns size of uniform datatypes based
+ * on property type.
+ */
+constexpr int GetPropertyValueSizeForUniform(Property::Type type)
+{
+  switch(type)
+  {
+    case Property::Type::BOOLEAN:
+    {
+      return sizeof(bool);
+    }
+    case Property::Type::FLOAT:
+    {
+      return sizeof(float);
+    }
+    case Property::Type::INTEGER:
+    {
+      return sizeof(int);
+    }
+    case Property::Type::VECTOR2:
+    {
+      return sizeof(Vector2);
+    }
+    case Property::Type::VECTOR3:
+    {
+      return sizeof(Vector3);
+    }
+    case Property::Type::VECTOR4:
+    {
+      return sizeof(Vector4);
+    }
+    case Property::Type::MATRIX3:
+    {
+      return sizeof(Matrix3);
+    }
+    case Property::Type::MATRIX:
+    {
+      return sizeof(Matrix);
+    }
+    default:
+    {
+      return 0;
+    }
+  };
+}
+
 /**
  * Helper function to calculate the correct alignment of data for uniform buffers
  * @param dataSize size of uniform buffer
@@ -830,7 +922,7 @@ void Renderer::FillUniformBuffer(Program&
   {
     auto& uniform    = iter;
     int   arrayIndex = uniform.arrayIndex;
-    if(!uniform.initialized)
+    if(!uniform.uniformFunc)
     {
       auto uniformInfo  = Graphics::UniformInfo{};
       auto uniformFound = program.GetUniform(uniform.uniformName.GetStringView(),
@@ -851,13 +943,15 @@ void Renderer::FillUniformBuffer(Program&
       uniform.uniformOffset     = uniformInfo.offset;
       uniform.uniformLocation   = uniformInfo.location;
       uniform.uniformBlockIndex = uniformInfo.bufferIndex;
-      uniform.initialized       = true;
 
       auto       dst      = ubo->GetOffset() + uniformInfo.offset;
-      const auto typeSize = iter.propertyValue->GetValueSize();
+      const auto typeSize = GetPropertyValueSizeForUniform(iter.propertyValue->GetType());
       const auto dest     = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
+      const auto func     = GetPropertyValueGetter(iter.propertyValue->GetType());
+      uniform.uniformSize = typeSize;
+      uniform.uniformFunc = func;
 
-      ubo->Write(iter.propertyValue->GetValueAddress(updateBufferIndex),
+      ubo->Write(&(iter.propertyValue->*func)(updateBufferIndex),
                  typeSize,
                  dest);
     }
@@ -866,10 +960,11 @@ void Renderer::FillUniformBuffer(Program&
       UniformBufferView* ubo = uboViews[uniform.uniformBlockIndex].get();
 
       auto       dst      = ubo->GetOffset() + uniform.uniformOffset;
-      const auto typeSize = iter.propertyValue->GetValueSize();
+      const auto typeSize = uniform.uniformSize;
       const auto dest     = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
+      const auto func     = uniform.uniformFunc;
 
-      ubo->Write(iter.propertyValue->GetValueAddress(updateBufferIndex),
+      ubo->Write(&(iter.propertyValue->*func)(updateBufferIndex),
                  typeSize,
                  dest);
     }
index 9a252861ebc371b4e510770be844e4532208e9f9..c12d253cfdb2fafda4f0f8fcf4eafdcc68dee082 100644 (file)
@@ -631,6 +631,8 @@ private:
 
   using Hash = std::size_t;
 
+  typedef const float& (PropertyInputImpl::*FuncGetter)(BufferIndex) const;
+
   struct UniformIndexMap
   {
     ConstString              uniformName;            ///< The uniform name
@@ -639,10 +641,11 @@ private:
     Hash                     uniformNameHashNoArray{0u};
     int32_t                  arrayIndex{-1}; ///< The array index
 
-    int16_t  uniformLocation{0u};
-    uint16_t uniformOffset{0u};
-    uint16_t uniformBlockIndex{0u};
-    bool     initialized{false};
+    int16_t    uniformLocation{0u};
+    uint16_t   uniformOffset{0u};
+    uint16_t   uniformSize{0u};
+    uint16_t   uniformBlockIndex{0u};
+    FuncGetter uniformFunc{0};
   };
 
   StencilParameters mStencilParameters; ///< Struct containing all stencil related options
index c2bb6fe63c115982c101396d832e1fdaa53bedeb..612af3f2e7f115914ff142da852cfb2c75a40225 100644 (file)
@@ -173,22 +173,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(bool);
-  }
-
   /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
@@ -355,22 +339,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(int);
-  }
-
   /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
@@ -546,22 +514,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(float);
-  }
-
   /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
@@ -739,22 +691,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector2);
-  }
-
   /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
@@ -1021,22 +957,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector3);
-  }
-
   /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
@@ -1357,22 +1277,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector4);
-  }
-
   /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
@@ -1765,22 +1669,6 @@ public:
     OnSet();
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector4);
-  }
-
   /**
    * Change the property value by a relative amount.
    * @param[in] bufferIndex The buffer to write.
@@ -1921,22 +1809,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Matrix);
-  }
-
   /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
@@ -2093,22 +1965,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Matrix3);
-  }
-
   /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
index 08d62b46d2745a7419300252a738252ef76a4c08..e4a844690365074f9a6a9d90f959ca184496a531 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -122,22 +122,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector3);
-  }
-
   /**
    * @copydoc Dali::PropertyInput::GetConstraintInputVector3()
    */
@@ -284,22 +268,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector4);
-  }
-
   /**
    * @copydoc Dali::PropertyInput::GetConstraintInputVector4()
    */
@@ -464,22 +432,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector4);
-  }
-
   /**
    * @copydoc Dali::PropertyInput::GetConstraintInputQuaternion()
    */
@@ -625,22 +577,6 @@ public:
     return mValue[bufferIndex];
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue[bufferIndex];
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Matrix);
-  }
-
   /**
    * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
    */
index 92e635ee049dce829ad8a4c2fce66dfe6a22c201..33e28b5858dd33460f6bc7678ab7631a77bd88dc 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_GESTURE_PROPERTIES_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -151,22 +151,6 @@ public:
   {
     return mValue;
   }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue;
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector2);
-  }
 };
 
 /**
@@ -187,22 +171,6 @@ public:
   {
     return mValue;
   }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &mValue;
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(bool);
-  }
 };
 
 } // namespace SceneGraph
index e093e01c0e5b698f1246fcded75b5fb083a61528..fe5fec48507496a1487d8c183f9a71c12bf0477d 100644 (file)
@@ -196,22 +196,6 @@ struct TransformManagerPropertyVector3 final : public TransformManagerPropertyHa
     return Get(bufferIndex);
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &GetVector3(bufferIndex);
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector3);
-  }
-
   const float& GetFloatComponent(uint32_t component) const override
   {
     return GetTxManagerData()->Manager()->GetVector3PropertyComponentValue(GetTxManagerData()->Id(), PropertyT, component);
@@ -328,22 +312,6 @@ public:
   {
     return Get(bufferIndex);
   }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &Get(bufferIndex);
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector4);
-  }
 };
 
 /**
@@ -446,22 +414,6 @@ public:
     return mValue;
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &GetVector3(bufferIndex);
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector3);
-  }
-
   /**
    * @copydoc Dali::PropertyInput::GetConstraintInputVector3()
    */
@@ -602,22 +554,6 @@ public:
     return mValue;
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    return &GetQuaternion(bufferIndex);
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Vector4);
-  }
-
   /**
    * @copydoc Dali::PropertyInput::GetConstraintInputQuaternion()
    */
@@ -746,29 +682,6 @@ public:
     return Matrix::IDENTITY;
   }
 
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
-   */
-  const void* GetValueAddress(BufferIndex bufferIndex) const override
-  {
-    static const Matrix identityMatrix(Matrix::IDENTITY);
-    auto                transformManagerData = GetTxManagerData();
-    auto                id                   = transformManagerData->Id();
-    if(id != INVALID_TRANSFORM_ID)
-    {
-      return &(transformManagerData->Manager()->GetWorldMatrix(id));
-    }
-    return &identityMatrix;
-  }
-
-  /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
-   */
-  size_t GetValueSize() const override
-  {
-    return sizeof(Matrix);
-  }
-
   /**
    * @copydoc Dali::PropertyInput::GetConstraintInputMatrix()
    */