From patchwork Tue Apr 24 00:06:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 134031 Delivered-To: patches@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1597194lji; Mon, 23 Apr 2018 17:06:50 -0700 (PDT) X-Received: by 2002:a17:902:24e:: with SMTP id 72-v6mr22175538plc.87.1524528410622; Mon, 23 Apr 2018 17:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524528410; cv=none; d=google.com; s=arc-20160816; b=Xa2APnnXgKf6xZpoYQklWBKYI3xYmgpc4hns43nqRs2M9ILdhViujc4B4hdEoLyBoT 0zFrJMGOaSJ+V2HWWGyqyq9empbIK3dV9OiZCuKf7puJEUNdaALx73/uNy/I9nc7hLn9 XeX7ZsIotmf0j9lkF3yHyEz9z86kELiDQ88ExrfpFqSUrIwgxdoN3Dms4IfO5RFsG/eN W0dAYdjUfHlieSwkL87hmi2O1j+qsLCSs2AypNYj0fRicL5e3MU9ZuDN4sJJxs/cW5zK japebXMuw8WjebQ/XgvmcTEnyqIuYa3utPCLMPxtKdD4cnKa8AY6qPalmBiGhrXW9b6Y yOxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=sVlvzxglEjxSi60taLi7o9ASGiew/sUIwG6CIRZziRg=; b=BFo8mFtCOAbioiLrhXM5WAhk1UE3WvdlP118aJFcgelpW6xKCm9CRWnSqFXdZbgwJB 1rkxOy6VyOVEMa6adtZCd9fAw7t+7L3m84JW5xWMc4tjsB17gDzMs4Ic2xK/cZ8agks2 lmUGcbI2PuM1bg/Kjvy/MwnOdsZCC0JmV0sF4xTzgBx38nYL/pPqxN8T2b0Ef8f0Cobw ziCLSsoAY7rIupN9FzmHMJ15bMVswflRQelSC4dsUx0TvzL+Lum8UDHYvlEITwmF4hbw jUzrF3xCSt5slWwRHwtDnEz819S0MI42ijRwegYmlXZJMpz4fX0deIHzw3rfzNmm3jEO BWrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Trz3Z52g; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x6sor416448pfn.55.2018.04.23.17.06.50 for (Google Transport Security); Mon, 23 Apr 2018 17:06:50 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Trz3Z52g; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=sVlvzxglEjxSi60taLi7o9ASGiew/sUIwG6CIRZziRg=; b=Trz3Z52gH3ve1V/w8HSGtF1LK+WEem2UllamM/LzCmAjSjf52UJ/E/BbPna8APCB83 AiPv6mhNLeO6ViWTXf9is2MEuj7ZGRGHgeBY6SXgO96YS/myp+4ImcJxyk+wH0RTiW5L 12jSW3T4p/wtYu5JynLt9PdHRcp/Fqu74rWsQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sVlvzxglEjxSi60taLi7o9ASGiew/sUIwG6CIRZziRg=; b=N2o67F43aUSbzhj9OEVUCAXszlu5qx244ITbZr9RJvr8nHZjcgi1MdEgdag1EKjRas zRKEZyBwksD1oTiCNzQ55R3CWXAp6yvxlqIlfBNsVBFQI/QZXD5VvznGmjYS+L5fKeo5 TByQAdIc0XnJwE8SdOHqxDBAZtl6mFaAk22dIvCJnmAi1nbCnC3+yNoGseR/406oIDGa WVY4N36VQ9lkRuBO9PbwA+HL+QV0VeQf53jDFP9VXdkMJBqKJBJNN67JvK/16E+906n9 +7kQ71fHjcY3Qt/4KxneZH0Jsk+GGNUzPaXEzzoWwOTA7uvoYzgPphfNf8nX8dhm3Czx VbDQ== X-Gm-Message-State: ALQs6tCsqNjQ8qYxDmM84/DMjgh7MZR2XrksY/PkCv+ncfQTydGOzqFF TRzG/9xcJzN3v9YsXwhOOfl2X1Y/ X-Google-Smtp-Source: AIpwx49H50o9GwPEiUiz19ovygPOThu0b2kyxbWVeutzmUpMogZQ1XW57wERBckL6XMY9Oj5YuNopQ== X-Received: by 10.98.69.142 with SMTP id n14mr21734722pfi.42.1524528409692; Mon, 23 Apr 2018 17:06:49 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:600:5100:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id x137sm23909976pfd.162.2018.04.23.17.06.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Apr 2018 17:06:48 -0700 (PDT) From: John Stultz To: dri-devel Cc: John Stultz , Marissa Wall , Sean Paul , Dmitry Shmidt , Robert Foss , Matt Szczesiak , Liviu Dudau , David Hanna , Rob Herring , Alexandru-Cosmin Gheorghe , Alistair Strachan Subject: [RFC][PATCH 1/2] drm_hwcomposer: Cleanup gl precompositor init and provide uses_GL flag Date: Mon, 23 Apr 2018 17:06:43 -0700 Message-Id: <1524528404-12331-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 The drm_hwcomposer has its own GL pre-compositor which is used to squish layers when there are more layers then planes on the display hardware. In many ways this duplicates the client-side GL compositing that is done in SurfaceFlinger, but in theory can be more highly optimized for the hardware. Unfortunately, due to these optimizations, the drm_hwcomposer's pre-compositor becomes somewhat hardware specific (originally targeting nvidia hardware, I believe). So on some hardware, the gl precompositor may not actually initialize due to hardware missing features, or the hardware supporting different shader APIs. Rather then try to rework the drm_hwcomposers precompositor to be more generic, I instead suggest that when the precompositor fails to initialize, we simply fall back to the already more widely compatible client compositor in SurfaceFlinger. Thus, this patch cleans up some of the precompositor initialization, which didn't handle failures well. Feedback or alternative ideas would be greatly appreciated! Cc: Marissa Wall Cc: Sean Paul Cc: Dmitry Shmidt Cc: Robert Foss Cc: Matt Szczesiak Cc: Liviu Dudau Cc: David Hanna Cc: Rob Herring Cc: Alexandru-Cosmin Gheorghe Cc: Alistair Strachan Signed-off-by: John Stultz --- drmdisplaycompositor.cpp | 40 +++++++++++++++++++++------------------- drmdisplaycompositor.h | 3 +++ 2 files changed, 24 insertions(+), 19 deletions(-) -- 2.7.4 Reviewed-by: Rob Herring diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp index e556e86..5c6bf9b 100644 --- a/drmdisplaycompositor.cpp +++ b/drmdisplaycompositor.cpp @@ -222,6 +222,13 @@ int DrmDisplayCompositor::Init(DrmResources *drm, int display) { return ret; } + pre_compositor_.reset(new GLWorkerCompositor()); + ret = pre_compositor_->Init(); + if (ret) { + ALOGE("Failed to initialize OpenGL compositor %d", ret); + pre_compositor_.reset(); + } + initialized_ = true; return 0; } @@ -294,14 +301,16 @@ int DrmDisplayCompositor::ApplySquash(DrmDisplayComposition *display_comp) { } std::vector ®ions = display_comp->squash_regions(); - ret = pre_compositor_->Composite(display_comp->layers().data(), + if (pre_compositor_) { + ret = pre_compositor_->Composite(display_comp->layers().data(), regions.data(), regions.size(), fb.buffer(), display_comp->importer()); - pre_compositor_->Finish(); + pre_compositor_->Finish(); - if (ret) { - ALOGE("Failed to squash layers"); - return ret; + if (ret) { + ALOGE("Failed to squash layers"); + return ret; + } } ret = display_comp->CreateNextTimelineFence(); @@ -328,14 +337,16 @@ int DrmDisplayCompositor::ApplyPreComposite( } std::vector ®ions = display_comp->pre_comp_regions(); - ret = pre_compositor_->Composite(display_comp->layers().data(), + if (pre_compositor_) { + ret = pre_compositor_->Composite(display_comp->layers().data(), regions.data(), regions.size(), fb.buffer(), display_comp->importer()); - pre_compositor_->Finish(); + pre_compositor_->Finish(); - if (ret) { - ALOGE("Failed to pre-composite layers"); - return ret; + if (ret) { + ALOGE("Failed to pre-composite layers"); + return ret; + } } ret = display_comp->CreateNextTimelineFence(); @@ -395,15 +406,6 @@ int DrmDisplayCompositor::PrepareFrame(DrmDisplayComposition *display_comp) { std::vector &pre_comp_regions = display_comp->pre_comp_regions(); - if (!pre_compositor_) { - pre_compositor_.reset(new GLWorkerCompositor()); - int ret = pre_compositor_->Init(); - if (ret) { - ALOGE("Failed to initialize OpenGL compositor %d", ret); - return ret; - } - } - int squash_layer_index = -1; if (squash_regions.size() > 0) { squash_framebuffer_index_ = (squash_framebuffer_index_ + 1) % 2; diff --git a/drmdisplaycompositor.h b/drmdisplaycompositor.h index f1965fb..ed6c5f9 100644 --- a/drmdisplaycompositor.h +++ b/drmdisplaycompositor.h @@ -98,6 +98,9 @@ class DrmDisplayCompositor { return &squash_state_; } + bool uses_GL() { + return !!pre_compositor_; + } private: struct ModeState { bool needs_modeset = false; From patchwork Tue Apr 24 00:06:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 134032 Delivered-To: patches@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1597220lji; Mon, 23 Apr 2018 17:06:52 -0700 (PDT) X-Received: by 10.99.125.19 with SMTP id y19mr18491962pgc.160.1524528412726; Mon, 23 Apr 2018 17:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524528412; cv=none; d=google.com; s=arc-20160816; b=yRUwRXG9g8LY+fzsDXdRRqA6hDK2dhC9RsbiPUTi7208yVPA7h2gS6+B2P4SQQ30YV yoyMw3zTkkFLxBZioqqG+EeT45dBbKa21HIWFVoFWSDxBXvksx/gtdzRzl+nuW+dbwS7 uISRF1SBAUsO0ZHMK7p+uLuDsP/z5H7z+u/wiOpkPwB8UgJv9SshciSlo4+Fp5xC1ZEy wX29765i5U3fa/69us9XLEwdxGw8d25RPL8pIFrNwjzm/o5psAmDs0Z//IzRmTtQ1kRp PPWQfFIc+aNHq8A4nIkvcE5WaFlIPot0j8Y4xSrj0IlBF6CY0OnHTYevmA8F3aet53Iq O1uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=3qP0BuNZd0G17EwFfNyBvNKLeemyvGXNnBYOZWFkx+8=; b=qvOpFjOLW1303XQ1l3vkxZAHJm7n5sIAJDUsshCcfbaCTqnNSaJ79V23r9tdMGR/1W haMiS/Ws2x4fBDZQ7eNE1vZ1MpXWSgyKiTvBv5Dbc8w7pvgcrBuHtYI95m5AGZkasXTV 4FTR3mZ6C47XiM7nZZCXWeo1YRoQlHmfQQkY2PX4EdYAPogdtAik67mqkWTk3ox3UmhN 2YejUB6h0RIOGiasDaebkAzAE0Kr3H0mzduTtY+hPYSbEZpy1L7YG5EG/nNdeahKjVJQ yTr30Wwq6rDy9vfDWYuaM4oacb9Lw92p39k2AnuWlWJw9TXuP8fCtOip6m2fF1CIqIGu nlQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=djP8pMMB; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 92-v6sor4843650pli.109.2018.04.23.17.06.52 for (Google Transport Security); Mon, 23 Apr 2018 17:06:52 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=djP8pMMB; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3qP0BuNZd0G17EwFfNyBvNKLeemyvGXNnBYOZWFkx+8=; b=djP8pMMBIB7nQLN+kLzQ3zE/EZHE7Xh+d1r6wp/4uhYCB+Utx3qLbSQX+BgJrcOA+0 JyIPNH04aPlNcfUYLgySoUZMrNfFuhBAO1W0bPWY3HOp1rjsoWi7sTFKB24L0mPZeYSm FYRZ91CiTO+6gfzDEOy08TeDRzbLvYjX0Tk4Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3qP0BuNZd0G17EwFfNyBvNKLeemyvGXNnBYOZWFkx+8=; b=MEa3je30u+m9/X7jtV/yjDAb/S9qhnZ34zFlm1CZpLXIOioHHm9hdK678kHjn5cvcp QXUBz0/Q7DHle6JjnALZ96KN6A0DogiAbRiEf0AUjEzxNAVpk0Bl9/3sVMTIiMLtpj7g K5+eq/beBQo7Q27OJCowSPnZTA8ErcKaH32Qb/J1PTLls/Cs8SXw3QuUqSDGHK6glSnF A/6okCkTENJnnQg/hLltYLorm/OUBCZkoiA3OSoIH9VWGPC9gegsl8b6JVRrEPoCl/M0 etjFJqkRg/urBF572AJ9GT4cKk9VLnx3PTG2kXBKSWABwygcH4i/hbWmhS87jTNaclSA VXFw== X-Gm-Message-State: ALQs6tCsfzcPTRthED4WY3d9HGiH3eb6dvExoEHXF+AIXFVF8P9y6qgh hTHfzJaaEifa0QwCggmxxU7Y2Zlc X-Google-Smtp-Source: AIpwx4/FClpqi+YHzg6J90Hiu6eo471nAOWmKmPZjIlUtnXGR2xYOhzNLAbF+yVDp51wHT1G57RPLw== X-Received: by 2002:a17:902:284b:: with SMTP id e69-v6mr22225605plb.240.1524528412161; Mon, 23 Apr 2018 17:06:52 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:600:5100:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id x137sm23909976pfd.162.2018.04.23.17.06.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Apr 2018 17:06:50 -0700 (PDT) From: John Stultz To: dri-devel Cc: John Stultz , Marissa Wall , Sean Paul , Dmitry Shmidt , Robert Foss , Matt Szczesiak , Liviu Dudau , David Hanna , Rob Herring , Alexandru-Cosmin Gheorghe , Alistair Strachan Subject: [RFC][PATCH 2/2] drm_hwcomposer: Fall back to client compositon if the gl precompostior fails Date: Mon, 23 Apr 2018 17:06:44 -0700 Message-Id: <1524528404-12331-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524528404-12331-1-git-send-email-john.stultz@linaro.org> References: <1524528404-12331-1-git-send-email-john.stultz@linaro.org> 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 Cc: Sean Paul Cc: Dmitry Shmidt Cc: Robert Foss Cc: Matt Szczesiak Cc: Liviu Dudau Cc: David Hanna Cc: Rob Herring Cc: Alexandru-Cosmin Gheorghe Cc: Alistair Strachan Signed-off-by: John Stultz Signed-off-by: John Stultz --- drmhwctwo.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.7.4 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 &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;