From patchwork Tue Feb 6 04:33:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 126942 Delivered-To: patches@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2570214ljc; Mon, 5 Feb 2018 20:33:12 -0800 (PST) X-Received: by 10.101.86.201 with SMTP id w9mr911352pgs.434.1517891592710; Mon, 05 Feb 2018 20:33:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517891592; cv=none; d=google.com; s=arc-20160816; b=F0qZP6XxaOv9tyz8SheeICn7TpfuNd0zg8DIL8c1xB14Q2LnhwEl940xmBqptu0G39 MRNX1cl/1ifNGU2Is01I0y/RIDTGaYvEpLu/57n5oygnMr8Z71z+hg/jWnYZyPy/8szz M9VqKVDuJ+FHEjuS4a0cssrT0umpYvokFGA+XBIm3e2CkBssHsx0pVSxwtFdvIozNblk +D5rwOapJX2DVNBr+C4FEkhLHvmn4QWtj0sSlZ+1SLKLjpBg4qmb+0qiVDSb6SURDAFX O7keC0PoFvx3z0vyMxHDHeLYFrhckmOFa8JG3sP2riCrpNm0wHzD/Na3m9bLYIVbweHD gT7w== 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=fzcpBDt5aDSdLawT3XY5N4gpB6+Y6YMaqIY7R/lbOEU=; b=WikxxaXh+083Otav78vjVVM0gawM3qs4VQ16wXlW9cixSde+UQFsZTKn5c5ex6u9Xr QuRQRaUr/g0PK+WD78LjHt5Uctzb2igHusgYIa24YW87fQaCBayIM/hDdQU9ocSVDm68 xNF7xkY+c32pHuN8d7CRcaUQB6oaOH2Kj9Re/BS2sfZyKejlIlDGGnbnTglT7QUnZDRl iLRN11ijOD6M8NlxFqKsHmALOo54aki7S2/dgH8K2Eng1SDNEhH8KaKXOo4nfLl5L8Ha vVSaQoCWoIZAIlCY0fTi8vlKgBBazg+lIA9dzh932rdt0kYJldTo410T31howWRaPn92 +5BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FBOA9Tjr; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 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-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id q77sor529107pfa.103.2018.02.05.20.33.12 for (Google Transport Security); Mon, 05 Feb 2018 20:33:12 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FBOA9Tjr; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 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=fzcpBDt5aDSdLawT3XY5N4gpB6+Y6YMaqIY7R/lbOEU=; b=FBOA9Tjr+yNZPoWmRBIWMOEB9HjKNUEiuGJStYucPQEt5bIbmObOk6qHwzw279ky8l jrLOp0PdxNYkQfKvOJOplwx4qT1E8cbKKd1laWjWTPgU3/9DHJdgJo9pckagh7BKXnye qDxzATI31EUbZLvhoHqra2VCiGYekgD+ncQOw= 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=fzcpBDt5aDSdLawT3XY5N4gpB6+Y6YMaqIY7R/lbOEU=; b=HP4llzIznm1d5EnmNpiuFW40ER0f3g82XrKilC1fRdvOt3wJxLJMfxdBJfX2cMTAA9 uhgvxO7rxtgVP+Qb7QFXUOak1xoCWFnKj2xQMpPvj7i37NMokV2EyjK2TRkVhkEZfYGo nWxXQY/wrvnY6cBsmLU5VuvRWUeeAX4UBGzxK+l+ZQ0GeOm9xe+63Y6DYm7bKClmxR/x y3+pppAmp3/acNyGkokyltQlIfpmDZabEfB/gfy9bG0pgtNO7Bjr95OiVa30NJT3KvY3 cbrg0rOcyNxcIu65cvfFYuuRe98+Jb+2ht6lJVLaf2AkIydgQlVkQAHZGARh/lf29Y9p BC6g== X-Gm-Message-State: APf1xPD9SbeN7IWLJXvMU8K21SFqk11Jf5uinNV2cxY/q4vZd5dTUiNh 7Ch6ND/zrHEY6JWkKmv/6JDyUwB3cJhulw== X-Google-Smtp-Source: AH8x226lBrjvWrpMX0qwDYg7wbS+chWg19Tz8rrlVM1i9AI+oXkHuTjz3s9k9MseWOXXk7nilqtW0w== X-Received: by 10.98.24.80 with SMTP id 77mr1126077pfy.145.1517891592016; Mon, 05 Feb 2018 20:33:12 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:600:5100:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id u84sm21354607pfg.10.2018.02.05.20.33.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Feb 2018 20:33:10 -0800 (PST) From: John Stultz To: Rob Herring Cc: John Stultz Subject: [EARLYREVIEW][PATCH] drm_hwcomposer: Use client compositing if there is only one plane Date: Mon, 5 Feb 2018 20:33:05 -0800 Message-Id: <1517891585-25047-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 Wanted to see if this was closer to what you were thinking on this change. I probably need to split it into two patches (the first changing the pre_compositor initialization, and the second chosing the client compositing). I suspect I'm still off, so let me know what you think. thanks -john Originally based on work by Rob Herring, this patch changes ValidateDisplay() so that if there is only one plane or we are not using the hwcomposer GL compositor (defaulting to surfaceflinger instead), we modify Device composited layers to be Client composited. Without this, on devices with just one plane, nothing gets displayed on the screen. Suggestions for alternative solutions here would be greatly appreciated! Change-Id: Ic963c356ab1ef241d92fde6c890936b560f52051 Signed-off-by: John Stultz --- v2: * Rework Rob's change to check planes v3: * Integrate Rob's feedback to conditionalize on GL compositor usage as well --- drmdisplaycompositor.cpp | 40 +++++++++++++++++++++------------------- drmdisplaycompositor.h | 3 +++ drmhwctwo.cpp | 7 +++++++ 3 files changed, 31 insertions(+), 19 deletions(-) -- 2.7.4 diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp index 3a20b31..f401208 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; diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp index dfca1a6..ed8793b 100644 --- a/drmhwctwo.cpp +++ b/drmhwctwo.cpp @@ -688,6 +688,7 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types, *num_requests = 0; for (std::pair &l : layers_) { DrmHwcTwo::HwcLayer &layer = l.second; + int planes = primary_planes_.size() + overlay_planes_.size(); switch (layer.sf_type()) { case HWC2::Composition::SolidColor: case HWC2::Composition::Cursor: @@ -695,6 +696,12 @@ 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() || planes == 1) { + layer.set_validated_type(HWC2::Composition::Client); + ++*num_types; + break; + } default: layer.set_validated_type(layer.sf_type()); break;