* @brief Constructor
*/
explicit Impl(EglGraphicsController& _controller)
- : controller(_controller)
+ : controller(_controller),
+ pipelineEntriesFlushRequired(false),
+ programEntriesFlushRequired(false)
{
// Initialise lookup table
InitialiseStateCompareLookupTable();
};
std::vector<ProgramCacheEntry> programEntries;
+
+ bool pipelineEntriesFlushRequired : 1;
+ bool programEntriesFlushRequired : 1;
};
PipelineCache::PipelineCache(EglGraphicsController& controller)
void PipelineCache::FlushCache()
{
- decltype(mImpl->entries) newEntries;
- newEntries.reserve(mImpl->entries.size());
-
- for(auto& entry : mImpl->entries)
+ if(mImpl->pipelineEntriesFlushRequired)
{
- // Move items which are still in use into the new array
- if(entry.pipeline->GetRefCount() != 0)
+ decltype(mImpl->entries) newEntries;
+ newEntries.reserve(mImpl->entries.size());
+
+ for(auto& entry : mImpl->entries)
{
- newEntries.emplace_back(std::move(entry));
+ // Move items which are still in use into the new array
+ if(entry.pipeline->GetRefCount() != 0)
+ {
+ newEntries.emplace_back(std::move(entry));
+ }
}
- }
- // Move temporary array in place of stored cache
- // Unused pipelines will be deleted automatically
- mImpl->entries = std::move(newEntries);
+ // Move temporary array in place of stored cache
+ // Unused pipelines will be deleted automatically
+ mImpl->entries = std::move(newEntries);
- // Program cache require similar action.
- decltype(mImpl->programEntries) newProgramEntries;
- newProgramEntries.reserve(mImpl->programEntries.size());
+ mImpl->pipelineEntriesFlushRequired = false;
+ }
- for(auto& entry : mImpl->programEntries)
+ if(mImpl->programEntriesFlushRequired)
{
- // Move items which are still in use into the new array
- if(entry.program->GetRefCount() != 0)
+ // Program cache require similar action.
+ decltype(mImpl->programEntries) newProgramEntries;
+ newProgramEntries.reserve(mImpl->programEntries.size());
+
+ for(auto& entry : mImpl->programEntries)
{
- newProgramEntries.emplace_back(std::move(entry));
+ // 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);
+
+ mImpl->programEntriesFlushRequired = false;
}
+}
- mImpl->programEntries = std::move(newProgramEntries);
+void PipelineCache::MarkPipelineCacheFlushRequired()
+{
+ mImpl->pipelineEntriesFlushRequired = true;
+}
+
+void PipelineCache::MarkProgramCacheFlushRequired()
+{
+ mImpl->programEntriesFlushRequired = true;
}
} // namespace Dali::Graphics::GLES
#define DALI_GRAPHICS_GLES_PIPELINE_CACHE_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.
*/
void FlushCache();
+ /**
+ * @brief Notify that we need to flush pipeline cache next FlushCache API.
+ */
+ void MarkPipelineCacheFlushRequired();
+
+ /**
+ * @brief Notify that we need to flush program cache next FlushCache API.
+ */
+ void MarkProgramCacheFlushRequired();
+
private:
/**
* @brief Finds pipeline implementation based on the spec