[RFC][PATCH 2/2] drm_hwcomposer: Fall back to client compositon if the gl precompostior fails

Stefan Schake stschake at gmail.com
Tue Apr 24 10:34:16 UTC 2018


On Tue, Apr 24, 2018 at 10:09 AM, Alexandru-Cosmin Gheorghe
<Alexandru-Cosmin.Gheorghe at arm.com> wrote:
> On Mon, Apr 23, 2018 at 05:06:44PM -0700, John Stultz wrote:
>> 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 <marissaw at google.com>
>> Cc: Sean Paul <seanpaul at google.com>
>> Cc: Dmitry Shmidt <dimitrysh at google.com>
>> Cc: Robert Foss <robert.foss at collabora.com>
>> Cc: Matt Szczesiak <matt.szczesiak at arm.com>
>> Cc: Liviu Dudau <Liviu.Dudau at arm.com>
>> Cc: David Hanna <david.hanna11 at gmail.com>
>> Cc: Rob Herring <rob.herring at linaro.org>
>> Cc: Alexandru-Cosmin Gheorghe <Alexandru-Cosmin.Gheorghe at arm.com>
>> Cc: Alistair Strachan <astrachan at google.com>
>> Signed-off-by: John Stultz <john.stultz at linaro.org>
>> Signed-off-by: John Stultz <john.stultz at 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) {
>
> Something is not entirely correct here, you can't assume just because
> you have planes available they can be used.
> E.g Layer has rotation, but the plane doesn't support it.
> This part is handled by the planning part in presentDisplay which
> falls back on GPU.
>
> I think the easiest and safe way is to just fallback to
> Composition::Client whenever the GLCompositor failed to initialize.
>

I agree, this would only work out for the single plane case where you end
up using client composition for everything.

In the spirit of DRM what we would probably want is to atomic test a
composition, and if that fails we can still fallback to client or GL
compositor depending on its availability. And then in a far far away
future we might even do a few iterations simplifying our composition until
it atomic tests correctly so we can still offload some "simple" parts
like the cursor.

Thanks,
Stefan


More information about the dri-devel mailing list