From b4496d1d07f76bf6afe22df87cc5a2a6c74bd2d1 Mon Sep 17 00:00:00 2001 From: Eunki Hong Date: Sun, 1 Oct 2023 17:53:54 +0900 Subject: [PATCH] Flush cached program entry at pipeline 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 --- .../gles-impl/gles-graphics-pipeline-cache.cpp | 18 ++++++++++++++---- .../graphics/gles-impl/gles-graphics-program.cpp | 5 +++++ .../graphics/gles-impl/gles-graphics-program.h | 6 ++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/dali/internal/graphics/gles-impl/gles-graphics-pipeline-cache.cpp b/dali/internal/graphics/gles-impl/gles-graphics-pipeline-cache.cpp index 69f45b7..ccf7e61 100755 --- a/dali/internal/graphics/gles-impl/gles-graphics-pipeline-cache.cpp +++ b/dali/internal/graphics/gles-impl/gles-graphics-pipeline-cache.cpp @@ -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 diff --git a/dali/internal/graphics/gles-impl/gles-graphics-program.cpp b/dali/internal/graphics/gles-impl/gles-graphics-program.cpp index 25c67c5..af1baa4 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-program.cpp +++ b/dali/internal/graphics/gles-impl/gles-graphics-program.cpp @@ -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; diff --git a/dali/internal/graphics/gles-impl/gles-graphics-program.h b/dali/internal/graphics/gles-impl/gles-graphics-program.h index e657e5e..050b04b 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-program.h +++ b/dali/internal/graphics/gles-impl/gles-graphics-program.h @@ -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 -- 2.7.4