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: [RFC][PATCH 1/2] drm_hwcomposer: Cleanup gl precompositor init and provide uses_GL flag
Date: Mon, 23 Apr 2018 17:06:43 -0700 [thread overview]
Message-ID: <1524528404-12331-1-git-send-email-john.stultz@linaro.org> (raw)
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 <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>
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 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<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 reply other threads:[~2018-04-24 0:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-24 0:06 John Stultz [this message]
2018-04-24 0:06 ` [RFC][PATCH 2/2] drm_hwcomposer: Fall back to client compositon if the gl precompostior fails John Stultz
2018-04-24 0:09 ` John Stultz
2018-04-24 8:09 ` Alexandru-Cosmin Gheorghe
2018-04-24 10:34 ` Stefan Schake
2018-04-24 18:38 ` John Stultz
2018-04-24 19:40 ` Sean Paul
2018-04-25 18:15 ` Alistair Strachan
2018-04-24 1:30 ` [RFC][PATCH 1/2] drm_hwcomposer: Cleanup gl precompositor init and provide uses_GL flag Rob Herring
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=1524528404-12331-1-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.