From 0ec8b37a80208c66d87e4322092d40694092bf81 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Thu, 9 Mar 2023 17:27:27 +0900 Subject: [PATCH] Remove uniform hash Use BakerResetter instead of hash Change-Id: I48cf6b8b4446c3e66e8329bfb1a90d2ab1052fbd --- .../update/animation/scene-graph-constraint-base.h | 7 +++--- .../update/animation/scene-graph-constraint.h | 28 +++++++++++++++++++++- dali/internal/update/common/property-resetter.h | 8 +++++-- dali/internal/update/manager/update-algorithms.cpp | 4 +--- dali/internal/update/manager/update-manager.cpp | 5 ++++ dali/internal/update/nodes/node.cpp | 14 ----------- dali/internal/update/nodes/node.h | 7 ------ .../update/rendering/scene-graph-renderer.cpp | 22 +++++++---------- .../update/rendering/scene-graph-renderer.h | 6 +---- 9 files changed, 53 insertions(+), 48 deletions(-) diff --git a/dali/internal/update/animation/scene-graph-constraint-base.h b/dali/internal/update/animation/scene-graph-constraint-base.h index f3f8f08..5bab505 100644 --- a/dali/internal/update/animation/scene-graph-constraint-base.h +++ b/dali/internal/update/animation/scene-graph-constraint-base.h @@ -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. diff --git a/dali/internal/update/animation/scene-graph-constraint.h b/dali/internal/update/animation/scene-graph-constraint.h index d7ba807..dc6a867 100644 --- a/dali/internal/update/animation/scene-graph-constraint.h +++ b/dali/internal/update/animation/scene-graph-constraint.h @@ -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) + { + 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) { diff --git a/dali/internal/update/common/property-resetter.h b/dali/internal/update/common/property-resetter.h index ddbc110..68a3986 100644 --- a/dali/internal/update/common/property-resetter.h +++ b/dali/internal/update/common/property-resetter.h @@ -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); + } } } }; diff --git a/dali/internal/update/manager/update-algorithms.cpp b/dali/internal/update/manager/update-algorithms.cpp index 0baa4f7..9cdd211 100644 --- a/dali/internal/update/manager/update-algorithms.cpp +++ b/dali/internal/update/manager/update-algorithms.cpp @@ -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. { diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index 5b3bf16..d47185a 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -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); diff --git a/dali/internal/update/nodes/node.cpp b/dali/internal/update/nodes/node.cpp index 8ae7963..5dc2e99 100644 --- a/dali/internal/update/nodes/node.cpp +++ b/dali/internal/update/nodes/node.cpp @@ -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); diff --git a/dali/internal/update/nodes/node.h b/dali/internal/update/nodes/node.h index 7611531..a99129b 100644 --- a/dali/internal/update/nodes/node.h +++ b/dali/internal/update/nodes/node.h @@ -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. diff --git a/dali/internal/update/rendering/scene-graph-renderer.cpp b/dali/internal/update/rendering/scene-graph-renderer.cpp index 752a56d..3c0653f 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.cpp +++ b/dali/internal/update/rendering/scene-graph-renderer.cpp @@ -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) diff --git a/dali/internal/update/rendering/scene-graph-renderer.h b/dali/internal/update/rendering/scene-graph-renderer.h index 889a791..1886342 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.h +++ b/dali/internal/update/rendering/scene-graph-renderer.h @@ -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 -- 2.7.4