Remove uniform hash 37/289537/4
authorHeeyong Song <heeyong.song@samsung.com>
Thu, 9 Mar 2023 08:27:27 +0000 (17:27 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Tue, 14 Mar 2023 08:47:04 +0000 (17:47 +0900)
Use BakerResetter instead of hash

Change-Id: I48cf6b8b4446c3e66e8329bfb1a90d2ab1052fbd

dali/internal/update/animation/scene-graph-constraint-base.h
dali/internal/update/animation/scene-graph-constraint.h
dali/internal/update/common/property-resetter.h
dali/internal/update/manager/update-algorithms.cpp
dali/internal/update/manager/update-manager.cpp
dali/internal/update/nodes/node.cpp
dali/internal/update/nodes/node.h
dali/internal/update/rendering/scene-graph-renderer.cpp
dali/internal/update/rendering/scene-graph-renderer.h

index f3f8f08..5bab505 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_CONSTRAINT_BASE_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.
@@ -232,9 +232,10 @@ protected:
   bool mFirstApply : 1;
   bool mDisconnected : 1;
 
+  PropertyOwnerContainer mObservedOwners; ///< A set of pointers to each observed object. Not owned.
+
 private:
-  PropertyOwnerContainer mObservedOwners;    ///< A set of pointers to each observed object. Not owned.
-  LifecycleObserver*     mLifecycleObserver; ///< Resetter observers this object
+  LifecycleObserver* mLifecycleObserver; ///< Resetter observers this object
 
 #ifdef DEBUG_ENABLED
   static uint32_t mCurrentInstanceCount; ///< The current number of Constraint instances in existence.
index d7ba807..dc6a867 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_CONSTRAINT_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.
@@ -80,8 +80,34 @@ public:
       if(mFunc->InputsInitialized())
       {
         PropertyType current = mTargetProperty.Get(updateBufferIndex);
+        PropertyType old     = mTargetProperty.Get(!updateBufferIndex);
+
         mFunc->Apply(updateBufferIndex, current);
 
+        // Compare with value of the previous frame
+        if constexpr(std::is_same_v<PropertyType, float>)
+        {
+          if(!Equals(old, current))
+          {
+            if(!mObservedOwners.Empty())
+            {
+              // The first observer is the target of the constraint
+              mObservedOwners[0]->SetUpdated(true);
+            }
+          }
+        }
+        else
+        {
+          if(old != current)
+          {
+            if(!mObservedOwners.Empty())
+            {
+              // The first observer is the target of the constraint
+              mObservedOwners[0]->SetUpdated(true);
+            }
+          }
+        }
+
         // Optionally bake the final value
         if(Dali::Constraint::BAKE == mRemoveAction)
         {
index ddbc110..68a3986 100644 (file)
@@ -60,6 +60,7 @@ public:
   void Initialize()
   {
     mPropertyOwner->AddObserver(*this);
+    mPropertyOwner->SetUpdated(true);
   }
 
   /**
@@ -201,7 +202,7 @@ public:
                 Lifetime       lifetime)
   : PropertyResetterBase(propertyOwner, baseProperty)
   {
-    mRunning = lifetime == Lifetime::BAKE ? ACTIVE : AGING;
+    mRunning = lifetime == Lifetime::BAKE ? AGING : ACTIVE;
   }
 
   /**
@@ -219,7 +220,10 @@ public:
       mRunning--;
       mBaseProperty->ResetToBaseValue(updateBufferIndex);
 
-      // @todo Consider adding mPropertyOwner->SetUpdated(true) here.
+      if(mRunning > 0)
+      {
+        mPropertyOwner->SetUpdated(true);
+      }
     }
   }
 };
index 0baa4f7..9cdd211 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.
@@ -113,8 +113,6 @@ inline NodePropertyFlags UpdateNodes(Node&             node,
 
   UpdateNodeOpacity(node, nodeDirtyFlags, updateBufferIndex);
 
-  node.UpdateUniformHash(updateBufferIndex);
-
   // For partial update, mark all children of an animating node as updated.
   if(updated) // Only set to updated if parent was updated.
   {
index 5b3bf16..d47185a 100644 (file)
@@ -1155,6 +1155,11 @@ void UpdateManager::PostRender()
     renderer->ResetDirtyFlag();
   }
 
+  for(auto&& shader : mImpl->shaders)
+  {
+    shader->SetUpdated(false);
+  }
+
   for(auto&& scene : mImpl->scenes)
   {
     scene->root->SetUpdatedTree(false);
index 8ae7963..5dc2e99 100644 (file)
@@ -281,20 +281,6 @@ void Node::ResetDirtyFlags(BufferIndex updateBufferIndex)
   mUpdateAreaChanged = false;
 }
 
-void Node::UpdateUniformHash(BufferIndex bufferIndex)
-{
-  uint64_t hash = 0xc70f6907UL;
-  for(uint32_t i = 0u, count = mUniformMaps.Count(); i < count; ++i)
-  {
-    hash = mUniformMaps[i].propertyPtr->Hash(bufferIndex, hash);
-  }
-  if(mUniformsHash != hash)
-  {
-    mUniformsHash = hash;
-    SetUpdated(true);
-  }
-}
-
 void Node::SetParent(Node& parentNode)
 {
   DALI_ASSERT_ALWAYS(this != &parentNode);
index 7611531..a99129b 100644 (file)
@@ -918,12 +918,6 @@ public:
    */
   void ResetDirtyFlags(BufferIndex updateBufferIndex);
 
-  /**
-   * Update uniform hash
-   * @param[in] bufferIndex The buffer to read from.
-   */
-  void UpdateUniformHash(BufferIndex bufferIndex);
-
 protected:
   /**
    * Set the parent of a Node.
@@ -1007,7 +1001,6 @@ public: // Default properties
   InheritedColor              mWorldColor;     ///< Full inherited color
   Vector4                     mUpdateAreaHint; ///< Update area hint is provided for damaged area calculation. (x, y, width, height)
 
-  uint64_t       mUniformsHash{0u};     ///< Hash of uniform map property values
   uint32_t       mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
   const uint32_t mId;                   ///< The Unique ID of the node.
 
index 752a56d..3c0653f 100644 (file)
@@ -736,19 +736,6 @@ void Renderer::UpdateUniformMap(BufferIndex updateBufferIndex)
     mRegenerateUniformMap = false;
     SetUpdated(true);
   }
-
-  uint64_t                                  hash                   = 0xc70f6907UL;
-  const SceneGraph::UniformMapDataProvider& uniformMapDataProvider = GetUniformMapDataProvider();
-  const SceneGraph::CollectedUniformMap&    collectedUniformMap    = uniformMapDataProvider.GetCollectedUniformMap();
-  for(uint32_t i = 0u, count = collectedUniformMap.Count(); i < count; ++i)
-  {
-    hash = collectedUniformMap.mUniformMap[i].propertyPtr->Hash(updateBufferIndex, hash);
-  }
-  if(mUniformsHash != hash)
-  {
-    mUniformsHash = hash;
-    SetUpdated(true);
-  }
 }
 
 void Renderer::SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size)
@@ -787,6 +774,15 @@ const CollectedUniformMap& Renderer::GetCollectedUniformMap() const
   return mCollectedUniformMap;
 }
 
+bool Renderer::IsUpdated() const
+{
+  if(Updated() || (mShader && mShader->Updated()))
+  {
+    return true;
+  }
+  return false;
+}
+
 Vector4 Renderer::GetVisualTransformedUpdateArea(BufferIndex updateBufferIndex, const Vector4& originalUpdateArea) noexcept
 {
   if(mVisualProperties)
index 889a791..1886342 100644 (file)
@@ -511,10 +511,7 @@ public:
   /**
    * @copydoc RenderDataProvider::IsUpdated()
    */
-  bool IsUpdated() const override
-  {
-    return Updated();
-  }
+  bool IsUpdated() const override;
 
   /**
    * @copydoc RenderDataProvider::GetVisualTransformedUpdateArea()
@@ -633,7 +630,6 @@ private:
 
   Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
 
-  uint64_t             mUniformsHash{0};             ///< Hash of uniform map property values
   uint32_t             mIndexedDrawFirstElement;     ///< first element index to be drawn using indexed draw
   uint32_t             mIndexedDrawElementsCount;    ///< number of elements to be drawn using indexed draw
   uint32_t             mBlendBitmask;                ///< The bitmask of blending options