From patchwork Thu Apr 26 19:05:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 134530 Delivered-To: patches@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2720658lji; Thu, 26 Apr 2018 12:06:06 -0700 (PDT) X-Received: by 2002:a17:902:a24:: with SMTP id 33-v6mr35379145plo.72.1524769566061; Thu, 26 Apr 2018 12:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524769566; cv=none; d=google.com; s=arc-20160816; b=JIWHnIPzV7nqUMffTFWBKeWYf4RDKj2EuazCfe3vmPaW1KYUJnunabrqbzEq+HFm5F +ksUBz5g3Rz8Rug326jQF7NRHNvg/lugR4lfDZLvqLZDSr3txcoLjbtdgWGms5k6JOYg X0SiPXmAN9KdIdqAkA7g77MoqTBeRFI+ShV3FqP4lwvLBWrFM4By9f1F3uknA8rKZ+x2 9BkogPUdwfThi6Eu59wMzy5Cfuz/eQcqsUykIw5XVMFBu2d/+XaDMduZwHXPFyX94TGq Xl9oEY9A9dHc9H9Mfl7FVN8bA5t5DDgk8iV2hsfU52F5bTwbUZEd4zHLjxwLWd2N9jez /MoA== 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=UyHERUhYQcftCPrA+HNwDGZ0lcKeFKtSjhwMtHpmSF4=; b=kpz9rEndbjCjvTH7+RPsdX1Caz66YvFOS/b/njf6IJ/PiTruiCeLvtzFEzq1NyH2eL 6N1X+7fPoHqyBMup13uOklSxZNIs3BfW7Q5SEl9FR0tE89iMRs8qwMcrynG1bQ6p5ByK mEpVG3tQ/VUuUnVBcIsXuuX4ZgjoP9w5wj/MabFMUH8BhsDeTevAKA/bkmNX1exGiDqw uoX1pbqUpNle6/ZJHexulNI7fvoB7tGuqKi6i/hfDOjVYmvs7Xd1haeetiY0rNHA4A7B 2/+Nx3kOGPFlFPt+85rkCEqfoaMnTgDZ5mUg8lLxZrRwIN5a2ggIg1+l6HfP7OLcZ29I wMqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LP7HFYDa; 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 y21-v6sor2362456pll.103.2018.04.26.12.06.05 for (Google Transport Security); Thu, 26 Apr 2018 12:06:06 -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=LP7HFYDa; 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=UyHERUhYQcftCPrA+HNwDGZ0lcKeFKtSjhwMtHpmSF4=; b=LP7HFYDalCsOOo/hp0DsVPqyIYGrXQLzIG5SQfjWyDPjUpejurUAucbz407D8lsklB SmFPW+vQMW6pK8tFj/c47/rfCM32SuY7PceQnbLV+pE00uDs4VdLYNA7Obn2oXyZXIwC SKakdPHGH3IvN403lV1tJc9150lr1fHoPMk3g= 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=UyHERUhYQcftCPrA+HNwDGZ0lcKeFKtSjhwMtHpmSF4=; b=bEb+tkJzuTiojOetZc3y/JvDco9JeVnsG4hU5SDKyOOvPZWxbVf5GoQFir988bL8ZP c+o+8fPKvsHgRDn/RFbvLrKbvD8cxsZKaKt/H8b3L3VaB85pEl0PnkQpaRktXX4JocYt bLFdBqNLCGOfhuf8NSLTDmRXnBHpzZ44yuAOvKQxzaGSwY3gHedE1GmCW7YqkvYPo7P4 omrxW7fUOiypWu9NjfIrFwmBAmQ82Av7w+bi+w30Bi/1A4y9bPx7SnAtg1fjqgoVEfUW ups/N2YusSKBRsvPzRLDsGivl4KGfUlUEJ32+o15EoT7aCX9CPNlKeHWCwURYSOl5n/Z SnKw== X-Gm-Message-State: ALQs6tAo4FbihBoGvmraU+oh3zKAgP99CrXtYg+dITkWp5DajBIYHCpt iJBzflq8yk5kmk2AJ+AHkvaW7+Y+ X-Google-Smtp-Source: AIpwx49Qu2VufSqerz0aIkIo+F0IWDIztqzCjf0dd5CXGr9QTork+Lhj0WyaDj0P/1Uo5Mo6ldOQDw== X-Received: by 2002:a17:902:b691:: with SMTP id c17-v6mr35629041pls.192.1524769565587; Thu, 26 Apr 2018 12:06:05 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:600:5100:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id a15sm33710956pfn.31.2018.04.26.12.06.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Apr 2018 12:06:04 -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: [PATCH hwc 3/4] drm_hwcomposer: Cleanup gl precompositor init and provide uses_GL flag Date: Thu, 26 Apr 2018 12:05:56 -0700 Message-Id: <1524769557-6108-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524769557-6108-1-git-send-email-john.stultz@linaro.org> References: <1524769557-6108-1-git-send-email-john.stultz@linaro.org> 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. 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 Reviewed-by: Rob Herring Signed-off-by: John Stultz --- drmdisplaycompositor.cpp | 40 +++++++++++++++++++++------------------- drmdisplaycompositor.h | 3 +++ 2 files changed, 24 insertions(+), 19 deletions(-) -- 2.7.4 Acked-by: Robert Foss diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp index e570923..40af3be 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;