From 6a2813e96d567c5c9fdfb2d25534d9d4c2fdaab9 Mon Sep 17 00:00:00 2001 From: Sushil Chauhan Date: Wed, 23 May 2018 15:25:52 -0700 Subject: sdm: Clear fb_id map if it exceeds the size limit Clear the fb_id map of SDM HW layer, if it exceeds the size limit. It is required for cases like pre-rotation where new buffer handles are allocated and new unique handle ids are used on same HWC layer for consecutive draw cycles involving device rotations. CRs-Fixed: 2247747 Change-Id: Iec71c42572f589717ad8f5677f84ff16e0aaaf01 --- sdm/libs/core/drm/hw_device_drm.cpp | 9 +++++---- sdm/libs/core/drm/hw_device_drm.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'sdm/libs/core/drm') 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> output_buffer_map_ {}; BufferAllocator *buffer_allocator_ = {}; + const uint8_t fbid_cache_limit_ = 16; }; protected: -- cgit v1.2.3