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: 10358387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9C88B6038F for ; Tue, 24 Apr 2018 00:06:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AB1328C95 for ; Tue, 24 Apr 2018 00:06:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E02328CA1; Tue, 24 Apr 2018 00:06:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE0F428C95 for ; Tue, 24 Apr 2018 00:06:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BEB8A6E31F; Tue, 24 Apr 2018 00:06:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BCE36E31F for ; Tue, 24 Apr 2018 00:06:51 +0000 (UTC) Received: by mail-pf0-x244.google.com with SMTP id p15so10658440pff.11 for ; Mon, 23 Apr 2018 17:06:51 -0700 (PDT) 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=KKvS/p8npghBuZZWVKe6LLAIxtdReiHhBoXiH7F31DaQmTMbtqJlbolnTfiK0RA+jO zq1ed9zLnygL2elDklW1cqn0fjuhcib8o56/z2QWAVyRm4YU5UpaMbpFMEPCDu8WUnP9 WE2Q2PVHwcY8aUkaXjMAl4d8I1l02ClbkNTaybaufGOO3rZ2VbdRekX20xlFs9QPwVZI XmE573PWKhufR0FqTPPu0cqrczJfMCkKfvFTfgYxhroz7fr9+Ix00pUJIwd4enZaLXJX nWXvyujTngmKh8wBYWwL61KiQFiMYjJ8LmJ+7YM0qIjbdmTALm6/vHcKoeGsUdV+YYSO jkoA== X-Gm-Message-State: ALQs6tA3CTXN6dIFqMXLyQI8Z/gto6ndTb1C96OFpz2hvOh7WhXYEue5 pbHrnq9DMpAShCQ9F9QrseEb9xB2UNg= 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) 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Matt Szczesiak , Dmitry Shmidt , Sean Paul , Robert Foss , Alexandru-Cosmin Gheorghe , Liviu Dudau , Alistair Strachan , Marissa Wall , David Hanna MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Rob Herring --- drmdisplaycompositor.cpp | 40 +++++++++++++++++++++------------------- drmdisplaycompositor.h | 3 +++ 2 files changed, 24 insertions(+), 19 deletions(-) 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;