If the gl precompositor isn't being used, we cannot accept
every layer as a device composited layer.

Thus this patch adds some extra logic in the validate function
to try to map layers to available device planes, falling back
to client side compositing if we run-out of planes.

Credit to Rob Herring, who's work this single plane patch was
originally based on.

Feedback or alternative ideas would be greatly appreciated!

Cc: Marissa Wall <maris...@google.com>
Cc: Sean Paul <seanp...@google.com>
Cc: Dmitry Shmidt <dimitr...@google.com>
Cc: Robert Foss <robert.f...@collabora.com>
Cc: Matt Szczesiak <matt.szczes...@arm.com>
Cc: Liviu Dudau <liviu.du...@arm.com>
Cc: David Hanna <david.hann...@gmail.com>
Cc: Rob Herring <rob.herr...@linaro.org>
Cc: Alexandru-Cosmin Gheorghe <alexandru-cosmin.gheor...@arm.com>
Cc: Alistair Strachan <astrac...@google.com>
Signed-off-by: John Stultz <john.stu...@linaro.org>
Signed-off-by: John Stultz <john.stu...@linaro.org>
---
 drmhwctwo.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index dfca1a6..437a439 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -686,6 +686,15 @@ HWC2::Error 
DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
   supported(__func__);
   *num_types = 0;
   *num_requests = 0;
+  int avail_planes = primary_planes_.size() + overlay_planes_.size();
+
+  /*
+   * If more layers then planes, save one plane
+   * for client composited layers
+   */
+  if (avail_planes < layers_.size())
+       avail_planes--;
+
   for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) {
     DrmHwcTwo::HwcLayer &layer = l.second;
     switch (layer.sf_type()) {
@@ -695,6 +704,15 @@ HWC2::Error 
DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
         layer.set_validated_type(HWC2::Composition::Client);
         ++*num_types;
         break;
+      case HWC2::Composition::Device:
+        if (!compositor_.uses_GL() && !avail_planes) {
+          layer.set_validated_type(HWC2::Composition::Client);
+          ++*num_types;
+          break;
+        } else {
+          avail_planes--;
+       }
+       /* fall through */
       default:
         layer.set_validated_type(layer.sf_type());
         break;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to