Flush cached program entry at pipeline 79/299479/2
authorEunki Hong <eunkiki.hong@samsung.com>
Sun, 1 Oct 2023 08:53:54 +0000 (17:53 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Mon, 2 Oct 2023 02:17:36 +0000 (11:17 +0900)
Since there was no timing to clean-up the program entry,
we need to flush it at Flush timing

Change-Id: Ic37c5ab8ccc55761aa3cb8e8b641f636de23dfc2
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
dali/internal/graphics/gles-impl/gles-graphics-pipeline-cache.cpp
dali/internal/graphics/gles-impl/gles-graphics-program.cpp
dali/internal/graphics/gles-impl/gles-graphics-program.h

index 69f45b7..ccf7e61 100755 (executable)
@@ -480,10 +480,20 @@ void PipelineCache::FlushCache()
   // Unused pipelines will be deleted automatically
   mImpl->entries = std::move(newEntries);
 
-  // TODO: program cache may require similar action. However,
-  //       since there is always one wrapper for Program object
-  //       kept in the pipeline, then death of pipeline will result
-  //       killing the program (if program isn't in use anymore)
+  // Program cache require similar action.
+  decltype(mImpl->programEntries) newProgramEntries;
+  newProgramEntries.reserve(mImpl->programEntries.size());
+
+  for(auto& entry : mImpl->programEntries)
+  {
+    // Move items which are still in use into the new array
+    if(entry.program->GetRefCount() != 0)
+    {
+      newProgramEntries.emplace_back(std::move(entry));
+    }
+  }
+
+  mImpl->programEntries = std::move(newProgramEntries);
 }
 
 } // namespace Dali::Graphics::GLES
index 25c67c5..af1baa4 100644 (file)
@@ -221,6 +221,11 @@ uint32_t ProgramImpl::Release()
   return --mImpl->refCount;
 }
 
+uint32_t ProgramImpl::GetRefCount() const
+{
+  return mImpl->refCount;
+}
+
 const GLES::Reflection& ProgramImpl::GetReflection() const
 {
   return *mImpl->reflection;
index e657e5e..050b04b 100644 (file)
@@ -87,6 +87,12 @@ public:
   uint32_t Release();
 
   /**
+   * @brief Retrieves ref count
+   * @return Refcount value
+   */
+  [[nodiscard]] uint32_t GetRefCount() const;
+
+  /**
    * @brief Returns reflection
    *
    * @return Valid reflection associated with the Program