summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiviu Dudau <Liviu.Dudau@arm.com>2020-06-15 17:08:33 +0100
committerJohn Stultz <john.stultz@linaro.org>2020-07-03 19:10:22 +0000
commiteb012298f3109e2faa651e881362aca8bc243d8f (patch)
tree9f6cb51297dea20349c7aa6af4590410cfdc940c
parentfdcdeabd7e50f2ff005333b135c1d0b440296a85 (diff)
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 <liviu.dudau@arm.com> Fixes commit b7b81cfba252 ("drm_hwcomposer: Choose client layer range to achieve minimal GPU load") Signed-off-by: John Stultz <john.stultz@linaro.org> Change-Id: I71b76b9d151bf506ad6026f5b1f9de6b6c0dc7c1
-rw-r--r--drmhwctwo.cpp9
1 files 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<uint32_t, DrmHwcTwo::HwcLayer *> z_map;
+ std::map<uint32_t, DrmHwcTwo::HwcLayer *> z_map, z_map_tmp;
+ uint32_t z_index = 0;
+ // First create a map of layers and z_order values
for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &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<const uint32_t, DrmHwcTwo::HwcLayer *> &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;