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;