summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sdm/libs/core/drm/hw_device_drm.cpp9
-rw-r--r--sdm/libs/core/drm/hw_device_drm.h1
2 files changed, 6 insertions, 4 deletions
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index adb7b95d..aa318be3 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -300,9 +300,10 @@ void HWDeviceDRM::Registry::MapBufferToFbId(Layer* layer, LayerBuffer* buffer) {
}
uint64_t handle_id = buffer->handle_id;
+ bool legacy_path = !handle_id || disable_fbid_cache_;
- if (!handle_id || disable_fbid_cache_) {
- // Legacy: Remove & Create fb_id in each frame
+ if (legacy_path || (layer->buffer_map->buffer_map.size() > fbid_cache_limit_)) {
+ // Clear fb_id map in each frame in legacy path or if the map size exceeds limit.
layer->buffer_map->buffer_map.clear();
}
@@ -325,8 +326,8 @@ void HWDeviceDRM::Registry::MapOutputBufferToFbId(LayerBuffer *output_buffer) {
uint64_t handle_id = output_buffer->handle_id;
- if (!handle_id || disable_fbid_cache_) {
- // Legacy: Remove & Create fb_id in each frame
+ if (!handle_id || disable_fbid_cache_ || (output_buffer_map_.size() > fbid_cache_limit_)) {
+ // Clear output buffer map in each frame in legacy path or if the map size exceeds limit.
output_buffer_map_.clear();
}
diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h
index 203b6bb6..728b47c5 100644
--- a/sdm/libs/core/drm/hw_device_drm.h
+++ b/sdm/libs/core/drm/hw_device_drm.h
@@ -157,6 +157,7 @@ class HWDeviceDRM : public HWInterface {
bool disable_fbid_cache_ = false;
std::unordered_map<uint64_t, std::shared_ptr<LayerBufferObject>> output_buffer_map_ {};
BufferAllocator *buffer_allocator_ = {};
+ const uint8_t fbid_cache_limit_ = 16;
};
protected: