From: John Stultz <john.stultz@linaro.org>
To: dri-devel <dri-devel@lists.freedesktop.org>
Cc: Rob Herring <rob.herring@linaro.org>,
Matt Szczesiak <matt.szczesiak@arm.com>,
Dmitry Shmidt <dimitrysh@google.com>,
Sean Paul <seanpaul@google.com>,
Robert Foss <robert.foss@collabora.com>,
Alexandru-Cosmin Gheorghe <Alexandru-Cosmin.Gheorghe@arm.com>,
Liviu Dudau <Liviu.Dudau@arm.com>,
Alistair Strachan <astrachan@google.com>,
Marissa Wall <marissaw@google.com>,
David Hanna <david.hanna11@gmail.com>
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 [thread overview]
Message-ID: <1524769557-6108-3-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <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 <marissaw@google.com>
Cc: Sean Paul <seanpaul@google.com>
Cc: Dmitry Shmidt <dimitrysh@google.com>
Cc: Robert Foss <robert.foss@collabora.com>
Cc: Matt Szczesiak <matt.szczesiak@arm.com>
Cc: Liviu Dudau <Liviu.Dudau@arm.com>
Cc: David Hanna <david.hanna11@gmail.com>
Cc: Rob Herring <rob.herring@linaro.org>
Cc: Alexandru-Cosmin Gheorghe <Alexandru-Cosmin.Gheorghe@arm.com>
Cc: Alistair Strachan <astrachan@google.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
drmdisplaycompositor.cpp | 40 +++++++++++++++++++++-------------------
drmdisplaycompositor.h | 3 +++
2 files changed, 24 insertions(+), 19 deletions(-)
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<DrmCompositionRegion> ®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<DrmCompositionRegion> ®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<DrmCompositionRegion> &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;
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2018-04-26 19:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-26 19:05 [PATCH hwc 1/4] drm_hwcomposer: Andorid.mk : Mark libdrmhwc_utils as vendor module John Stultz
2018-04-26 19:05 ` [PATCH hwc 2/4] drm_hwcomposer: Use log/log.h instead of cutils/log.h John Stultz
2018-04-26 19:34 ` Robert Foss
2018-04-26 19:05 ` John Stultz [this message]
2018-04-26 19:43 ` [PATCH hwc 3/4] drm_hwcomposer: Cleanup gl precompositor init and provide uses_GL flag Robert Foss
2018-04-26 19:05 ` [PATCH hwc 4/4] drm_hwcomposer: Fall back to client compositon if the gl precompostior fails John Stultz
2018-04-27 12:17 ` Robert Foss
2018-04-26 19:32 ` [PATCH hwc 1/4] drm_hwcomposer: Andorid.mk : Mark libdrmhwc_utils as vendor module Robert Foss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1524769557-6108-3-git-send-email-john.stultz@linaro.org \
--to=john.stultz@linaro.org \
--cc=Alexandru-Cosmin.Gheorghe@arm.com \
--cc=Liviu.Dudau@arm.com \
--cc=astrachan@google.com \
--cc=david.hanna11@gmail.com \
--cc=dimitrysh@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=marissaw@google.com \
--cc=matt.szczesiak@arm.com \
--cc=rob.herring@linaro.org \
--cc=robert.foss@collabora.com \
--cc=seanpaul@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox