From eb012298f3109e2faa651e881362aca8bc243d8f Mon Sep 17 00:00:00 2001 From: Liviu Dudau Date: Mon, 15 Jun 2020 17:08:33 +0100 Subject: drm_hwcomposer: Fix ValidateDisplay() when lowest z-order is nonzero ValidateDisplay()'s algorithm for achieving minimal GPU load assumes that the lowest z-order is zero and that layers have sequential z-orders. CalcPixOps() and MarkValidated() are also written with the same assumption. However, there is no such guarantee provided by SurfaceFlinger and VTS tests like PRESENT_DISPLAY_NO_LAYER_STATE_CHANGES fail as they only have one layer with z-order of 10. Normalise the mapping between layers and z-order so that the algorithm works as intended. Signed-off-by: Liviu Dudau Fixes commit b7b81cfba252 ("drm_hwcomposer: Choose client layer range to achieve minimal GPU load") Signed-off-by: John Stultz Change-Id: I71b76b9d151bf506ad6026f5b1f9de6b6c0dc7c1 --- drmhwctwo.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp index 8743b14..8338f59 100644 --- a/drmhwctwo.cpp +++ b/drmhwctwo.cpp @@ -910,9 +910,14 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types, if (avail_planes < layers_.size()) avail_planes--; - std::map z_map; + std::map z_map, z_map_tmp; + uint32_t z_index = 0; + // First create a map of layers and z_order values for (std::pair &l : layers_) - z_map.emplace(std::make_pair(l.second.z_order(), &l.second)); + z_map_tmp.emplace(std::make_pair(l.second.z_order(), &l.second)); + // normalise the map so that the lowest z_order layer has key 0 + for (std::pair &l : z_map_tmp) + z_map.emplace(std::make_pair(z_index++, l.second)); uint32_t total_pixops = CalcPixOps(z_map, 0, z_map.size()), gpu_pixops = 0; -- cgit v1.2.3