Skip to contentSkip to conversation

drm_hwcomposer: Changes to support HiKey/HiKey960

RFC PATCH Superseded John Stultz 3 participants 11 messages Jan 10, 2018 – Jan 12, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover drm_hwcomposer: Changes to support HiKey/HiKey960

This patchset is an inital RFC I wanted to send out to get some early review and feedback.

I've been working to enable the drm_hwcomposer for HiKey and HiKey960 boards in AOSP, and this patchset contains the required changes to the drm_hwcomposer code to get things working.

I'm really quite naive when it comes to graphics, and I'm sure I don't fully understand the drm_hwcomposer code, so forgive me if I've done anything terribly stupid here.

There are a few terrible hacks involved, which I'd really love to get any guidance on how things should be properly done here.

The first is I'm using Rob's patch to force use of single plane, without which I don't get anything on the screen.

The second is that after getting the drm_hwcomposer running, I was seeing tons of tearing, which was exactly the behavior I'm making this effort to avoid. So I have another hack patch that removes some checks that fail which keep us from doing fence handling properly. Again, any tips for what deeper issues need to be addressed would be helpful!

Finally, the third hack isn't in this patchset, but in the kernel, where with the drm_hwcomposer, on initialization, we would hit the case where it was trying to enable vsync while the crtc is off. So I worked around that here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?h=dev/hikey-hwcomposer-deps&id=30aa3e944e5c87fd4f61333a123d365e99825e3a

For that last issue, I'm not sure if this is due to some quirk w/ the drm_hwcomposer initialization, or some other quirk of the kirin drm driver, but in development of this, I've also worked with an older drm based hwc implementations which didn't trigger this issue.

Anyway, outside of those hacks I'm sure there can be further improvement as well, so I wanted to get it out for some initial review.

If anyone wants to try the code out on either a HiKey or HiKey960, you will need this patchset on top of the freedesktop/master branch of drm_hwcomposer. You'll also need the freedesktop/master branch of libdrm. You'll need the following patches to the device/linaro/hikey project:
https://github.com/johnstultz-work/android_device_linaro_hikey/commits/drm_hwc

And you'll need to replace the kernel Image-dtb with one built from the following tree:
https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/hikey-hwcomposer-deps

Any thoughts or feedback will be very much appreciated!

Many thanks to Rob Herring and Matt Szczesiak for help to get this working so far!

Thanks so much for your time!
-john

Cc Marissa Wall <[email protected]>
Cc Sean Paul <[email protected]>
Cc Dmitry Shmidt <[email protected]>
Cc Robert Foss <[email protected]>
Cc Matt Szczesiak <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc David Hanna <[email protected]>
Cc Rob Herring <[email protected]>

John Stultz (3):
drm_hwcomposer: glworker: Add build time options for certain shader
feature names
drm_hwcomposer: Add platformhisi buffer importer for hikey and

    hikey960

drm_hwcomposer: HACK: Fix tearing on hikey/hikey960

Rob Herring (2):
drm_hwcomposer: provide a common gralloc handle definition
drm_hwcomposer: HACK: force single plane

 Android.mk               |  13 ++-
 drmdisplaycompositor.cpp |   9 ++-
 drmhwctwo.cpp            |   4 +-
 glworker.cpp             |  15 +++-
 gralloc_drm_handle.h     |  87 +++++++++++++++++++++
 platformhisi.cpp         | 200 +++++++++++++++++++++++++++++++++++++++++++++++
 platformhisi.h           |  50 ++++++++++++
 7 files changed, 368 insertions(+), 10 deletions(-)
 create mode 100644 gralloc_drm_handle.h
 create mode 100644 platformhisi.cpp
 create mode 100644 platformhisi.h
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

RFC PATCH 1/5 drm_hwcomposer: provide a common gralloc handle definition

From: Rob Herring <[email protected]>

EGL, gralloc, and HWC must all have a common definition of fd's and int's in native_handle_t to share the fd and width, height, format, etc. of a dmabuf.

Move the definition into HWC so we aren't dependent on a specific gralloc implementation and so we don't have to create an importer just for different native_handle_t layouts. This will allow supporting multiple gralloc implementations that conform to this layout.

For now, this is aligned with gbm_gralloc's struct. Once we change gbm_gralloc and mesa to point to this copy, we can make modifications to the struct.

Change-Id I0e0e9994c7a13e6c47f00a70d13cd2ef9b1543d3
Cc Marissa Wall <[email protected]>
Cc Sean Paul <[email protected]>
Cc Dmitry Shmidt <[email protected]>
Cc Robert Foss <[email protected]>
Cc Matt Szczesiak <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc David Hanna <[email protected]>

[jstultz: This patch is important to be able to build AOSP
without having to include the gbm_gralloc project.]

---
 Android.mk           |  1 -
 gralloc_drm_handle.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 gralloc_drm_handle.h
Android.mk +0 -1
index 8b11e37..ee5b8bf 100644
@@ -47,7 +47,6 @@ LOCAL_SHARED_LIBRARIES := \
 LOCAL_STATIC_LIBRARIES := libdrmhwc_utils
 
 LOCAL_C_INCLUDES := \
-	external/drm_gralloc \
 	system/core/libsync
 
 LOCAL_SRC_FILES := \
gralloc_drm_handle.h new file +87 -0

87 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

RFC PATCH 2/5 drm_hwcomposer: glworker: Add build time options for certain shader feature names

In reply to John Stultz

In order to get the hikey960, which uses the mali bifrost driver working with drm_hwcomposer, its needed to tweak some extension and funciton names used in the shaders.

Specifically:
* GL_OES_EGL_image_external_essl3 instead of
GL_OES_EGL_image_external
* texture() instead of texture2D()

Which is configured using a build time definition.

Credit to Matt Szczesiak for suggesting these changes to get hikey960 working!

I'm a bit new to all this, and I expect there may be a better way to do this, so I'd love any feedback or comments!

Change-Id I2c8f08341ad086479b66241b903c79b00f2a0feb
Cc Marissa Wall <[email protected]>
Cc Sean Paul <[email protected]>
Cc Dmitry Shmidt <[email protected]>
Cc Robert Foss <[email protected]>
Cc Matt Szczesiak <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc David Hanna <[email protected]>
Cc Rob Herring <[email protected]>
---
 glworker.cpp | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
glworker.cpp +13 -2
index ca726bf..c35d1b6 100644
@@ -41,6 +41,17 @@
 
 #define MAX_OVERLAPPING_LAYERS 64
 
+#ifdef USE_TEXTURE_FN
+ #define TEXTURE_STR "texture"
+#else
+ #define TEXTURE_STR "texture2D"
+#endif
+
+#ifdef USE_IMAGE_EXTERNAL_ESSL3
+ #define IMAGE_EXTERNAL_STR "GL_OES_EGL_image_external_essl3"
+#else
+ #define IMAGE_EXTERNAL_STR "GL_OES_EGL_image_external"
+#endif
 namespace android {
 
 // clang-format off
@@ -237,7 +248,7 @@ static std::string GenerateFragmentShader(int layer_count) {
   std::ostringstream fragment_shader_stream;
   fragment_shader_stream << "#version 300 es\n"
                          << "#define LAYER_COUNT " << layer_count << "\n"
-                         << "#extension GL_OES_EGL_image_external : require\n"
+                         << "#extension " << IMAGE_EXTERNAL_STR << " : require\n"
                          << "precision mediump float;\n";
   for (int i = 0; i < layer_count; ++i) {
     fragment_shader_stream << "uniform samplerExternalOES uLayerTexture" << i
@@ -257,7 +268,7 @@ static std::string GenerateFragmentShader(int layer_count) {
       fragment_shader_stream << "  if (alphaCover > 0.5/255.0) {\n";
     // clang-format off
     fragment_shader_stream
-        << "  texSample = texture2D(uLayerTexture" << i << ",\n"
+        << "  texSample = " << TEXTURE_STR << "(uLayerTexture" << i << ",\n"
         << "                        fTexCoords[" << i << "]);\n"
         << "  multRgb = texSample.rgb *\n"
         << "            max(texSample.a, uLayerPremult[" << i << "]);\n"
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

RFC PATCH 3/5 drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960

In reply to John Stultz

This allows for importing buffers allocated from the hikey and hikey960 gralloc implelementations.

Change-Id I81abdd4d1dc7d9f2ef31078c91679b532d3262fd
Cc Marissa Wall <[email protected]>
Cc Sean Paul <[email protected]>
Cc Dmitry Shmidt <[email protected]>
Cc Robert Foss <[email protected]>
Cc Matt Szczesiak <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc David Hanna <[email protected]>
Cc Rob Herring <[email protected]>
---
 Android.mk       |  12 ++++
 platformhisi.cpp | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 platformhisi.h   |  50 ++++++++++++++
 3 files changed, 262 insertions(+)
 create mode 100644 platformhisi.cpp
 create mode 100644 platformhisi.h
Android.mk +12 -0
index ee5b8bf..caafce1 100644
@@ -66,6 +66,7 @@ LOCAL_SRC_FILES := \
 	hwcutils.cpp \
 	platform.cpp \
 	platformdrmgeneric.cpp \
+	platformhisi.cpp \
 	separate_rects.cpp \
 	virtualcompositorworker.cpp \
 	vsyncworker.cpp
@@ -74,7 +75,18 @@ LOCAL_CPPFLAGS += \
 	-DHWC2_USE_CPP11 \
 	-DHWC2_INCLUDE_STRINGIFICATION
 
+
+ifeq ($(TARGET_PRODUCT),hikey960)
+LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER -DUSE_IMAGE_EXTERNAL_ESSL3 -DUSE_TEXTURE_FN
+LOCAL_C_INCLUDES += device/linaro/hikey/gralloc960/
+else
+ifeq ($(TARGET_PRODUCT),hikey)
+LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER -DHIKEY
+LOCAL_C_INCLUDES += device/linaro/hikey/gralloc/
+else
 LOCAL_CPPFLAGS += -DUSE_DRM_GENERIC_IMPORTER
+endif
+endif
 
 LOCAL_MODULE := hwcomposer.drm
 LOCAL_MODULE_TAGS := optional
platformhisi.cpp new file +200 -0

200 lines not on this page · raw message

platformhisi.h new file +50 -0

50 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

RFC PATCH 4/5 drm_hwcomposer: HACK: force single plane

In reply to John Stultz

From: Rob Herring <[email protected]>

Change from Rob to force use of single plane.

Without this we don't see anything on the screen.

Suggestions for alternative solutions here would be greatly appreciated!

Change-Id Ic963c356ab1ef241d92fde6c890936b560f52051
Cc Marissa Wall <[email protected]>
Cc Sean Paul <[email protected]>
Cc Dmitry Shmidt <[email protected]>
Cc Robert Foss <[email protected]>
Cc Matt Szczesiak <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc David Hanna <[email protected]>
Cc Rob Herring <[email protected]>
---
 drmhwctwo.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drmhwctwo.cpp +1 -3
index dfca1a6..5ab4595 100644
@@ -692,12 +692,10 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
       case HWC2::Composition::SolidColor:
       case HWC2::Composition::Cursor:
       case HWC2::Composition::Sideband:
+      default:
         layer.set_validated_type(HWC2::Composition::Client);
         ++*num_types;
         break;
-      default:
-        layer.set_validated_type(layer.sf_type());
-        break;
     }
   }
   return *num_types ? HWC2::Error::HasChanges : HWC2::Error::None;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

RFC PATCH 5/5 drm_hwcomposer: HACK: Fix tearing on hikey/hikey960

In reply to John Stultz

When using drm_hwcomposer with the hikey/hikey960 boards, the resulting display shows lots of tearing.

I'm not much of an expert in how this code should work, but it seems that we never call sync_wait(), and thus don't seem to be handling the fences properly? I'm not sure.

Anyway, in a daze, I started cutting out code trying to make sure we call the CreateNextTimelineFence() and fb.set_release_fence_fd().

After doing so the tearing went away. I'm really not sure what is wrong that requires these hacks. It may be the hikey/hikey960 drm driver is incorrectly reporting or handling something?

We do only have a single plane and no hardware compositing on the boards, so we are having to force the gpu to do all the compositing.

Any ideas for what a proper fix here would be? Or even just hints on why this might make things work?

Change-Id Ifba58f6f1cb00e5271892c0241e4891abe211f22
Cc Marissa Wall <[email protected]>
Cc Sean Paul <[email protected]>
Cc Dmitry Shmidt <[email protected]>
Cc Robert Foss <[email protected]>
Cc Matt Szczesiak <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc David Hanna <[email protected]>
Cc Rob Herring <[email protected]>
---
 drmdisplaycompositor.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drmdisplaycompositor.cpp +5 -4
index acd13b8..6c391d6 100644
@@ -299,10 +299,11 @@ int DrmDisplayCompositor::ApplySquash(DrmDisplayComposition *display_comp) {
                                    display_comp->importer());
   pre_compositor_->Finish();
 
-  if (ret) {
+/*  if (ret) {
     ALOGE("Failed to squash layers");
     return ret;
   }
+*/
 
   ret = display_comp->CreateNextTimelineFence();
   if (ret <= 0) {
@@ -390,8 +391,8 @@ int DrmDisplayCompositor::PrepareFrame(DrmDisplayComposition *display_comp) {
   std::vector<DrmHwcLayer> &layers = display_comp->layers();
   std::vector<DrmCompositionPlane> &comp_planes =
       display_comp->composition_planes();
-  std::vector<DrmCompositionRegion> &squash_regions =
-      display_comp->squash_regions();
+//  std::vector<DrmCompositionRegion> &squash_regions =
+//      display_comp->squash_regions();
   std::vector<DrmCompositionRegion> &pre_comp_regions =
       display_comp->pre_comp_regions();
 
@@ -405,7 +406,7 @@ int DrmDisplayCompositor::PrepareFrame(DrmDisplayComposition *display_comp) {
   }
 
   int squash_layer_index = -1;
-  if (squash_regions.size() > 0) {
+  if (1) { //squash_regions.size() > 0) {
     squash_framebuffer_index_ = (squash_framebuffer_index_ + 1) % 2;
     ret = ApplySquash(display_comp);
     if (ret)
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Re: [RFC][PATCH 2/5] drm_hwcomposer: glworker: Add build time options for certain shader feature names

In reply to John Stultz
Quoted 10 lines · John Stultz

In order to get the hikey960, which uses the mali bifrost driver working with drm_hwcomposer, its needed to tweak some extension and funciton names used in the shaders.

Specifically:
* GL_OES_EGL_image_external_essl3 instead of
GL_OES_EGL_image_external
* texture() instead of texture2D()

Which is configured using a build time definition.

Build time is kinda uncool, at least in the spirit of multiarch kernels :-) Can't we try a few alternatives until the glsl compiler takes it? For extensions you could/should even query them upfront and then pick the right one.
-Daniel

Quoted 67 lines

Credit to Matt Szczesiak for suggesting these changes to get hikey960 working!

I'm a bit new to all this, and I expect there may be a better way to do this, so I'd love any feedback or comments!

Change-Id I2c8f08341ad086479b66241b903c79b00f2a0feb
Cc Marissa Wall <[email protected]>
Cc Sean Paul <[email protected]>
Cc Dmitry Shmidt <[email protected]>
Cc Robert Foss <[email protected]>
Cc Matt Szczesiak <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc David Hanna <[email protected]>
Cc Rob Herring <[email protected]>
---
 glworker.cpp | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
glworker.cpp +13 -2
index ca726bf..c35d1b6 100644
@@ -41,6 +41,17 @@
 
 #define MAX_OVERLAPPING_LAYERS 64
 
+#ifdef USE_TEXTURE_FN
+ #define TEXTURE_STR "texture"
+#else
+ #define TEXTURE_STR "texture2D"
+#endif
+
+#ifdef USE_IMAGE_EXTERNAL_ESSL3
+ #define IMAGE_EXTERNAL_STR "GL_OES_EGL_image_external_essl3"
+#else
+ #define IMAGE_EXTERNAL_STR "GL_OES_EGL_image_external"
+#endif
 namespace android {
 
 // clang-format off
@@ -237,7 +248,7 @@ static std::string GenerateFragmentShader(int layer_count) {
   std::ostringstream fragment_shader_stream;
   fragment_shader_stream << "#version 300 es\n"
                          << "#define LAYER_COUNT " << layer_count << "\n"
-                         << "#extension GL_OES_EGL_image_external : require\n"
+                         << "#extension " << IMAGE_EXTERNAL_STR << " : require\n"
                          << "precision mediump float;\n";
   for (int i = 0; i < layer_count; ++i) {
     fragment_shader_stream << "uniform samplerExternalOES uLayerTexture" << i
@@ -257,7 +268,7 @@ static std::string GenerateFragmentShader(int layer_count) {
       fragment_shader_stream << "  if (alphaCover > 0.5/255.0) {\n";
     // clang-format off
     fragment_shader_stream
-        << "  texSample = texture2D(uLayerTexture" << i << ",\n"
+        << "  texSample = " << TEXTURE_STR << "(uLayerTexture" << i << ",\n"
         << "                        fTexCoords[" << i << "]);\n"
         << "  multRgb = texSample.rgb *\n"
         << "            max(texSample.a, uLayerPremult[" << i << "]);\n"
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [RFC][PATCH 1/5] drm_hwcomposer: provide a common gralloc handle definition

In reply to John Stultz
Quoted 24 lines · John Stultz

From: Rob Herring <[email protected]>

EGL, gralloc, and HWC must all have a common definition of fd's and int's in native_handle_t to share the fd and width, height, format, etc. of a dmabuf.

Move the definition into HWC so we aren't dependent on a specific gralloc implementation and so we don't have to create an importer just for different native_handle_t layouts. This will allow supporting multiple gralloc implementations that conform to this layout.

For now, this is aligned with gbm_gralloc's struct. Once we change gbm_gralloc and mesa to point to this copy, we can make modifications to the struct.

Change-Id I0e0e9994c7a13e6c47f00a70d13cd2ef9b1543d3
Cc Marissa Wall <[email protected]>
Cc Sean Paul <[email protected]>
Cc Dmitry Shmidt <[email protected]>
Cc Robert Foss <[email protected]>
Cc Matt Szczesiak <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc David Hanna <[email protected]>
Quoted 8 lines

[jstultz: This patch is important to be able to build AOSP
without having to include the gbm_gralloc project.]

---
 Android.mk           |  1 -
 gralloc_drm_handle.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 gralloc_drm_handle.h

We have since decided that libdrm is a better place for this. Robert Foss is working on that.

But you shouldn't need this at all with your custom importer.

Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [RFC][PATCH 1/5] drm_hwcomposer: provide a common gralloc handle definition

Quoted 34 lines · Rob Herring
Quoted 24 lines · John Stultz

From: Rob Herring <[email protected]>

EGL, gralloc, and HWC must all have a common definition of fd's and int's in native_handle_t to share the fd and width, height, format, etc. of a dmabuf.

Move the definition into HWC so we aren't dependent on a specific gralloc implementation and so we don't have to create an importer just for different native_handle_t layouts. This will allow supporting multiple gralloc implementations that conform to this layout.

For now, this is aligned with gbm_gralloc's struct. Once we change gbm_gralloc and mesa to point to this copy, we can make modifications to the struct.

Change-Id I0e0e9994c7a13e6c47f00a70d13cd2ef9b1543d3
Cc Marissa Wall <[email protected]>
Cc Sean Paul <[email protected]>
Cc Dmitry Shmidt <[email protected]>
Cc Robert Foss <[email protected]>
Cc Matt Szczesiak <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc David Hanna <[email protected]>
Quoted 8 lines

[jstultz: This patch is important to be able to build AOSP
without having to include the gbm_gralloc project.]

---
 Android.mk           |  1 -
 gralloc_drm_handle.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 gralloc_drm_handle.h
Quoted 4 lines

We have since decided that libdrm is a better place for this. Robert Foss is working on that.

But you shouldn't need this at all with your custom importer.

Unfortunately the platformdrmgeneric.cpp is part of the build either way, and tries to #include the gralloc_drm_handle.h file (the USE_DRM_GENERIC_IMPORTER conditional is under the includes), which causes build failures.

But I'll rework the Andorid.mk logic to conditionally add the platformhisi.cpp or platformdrmgeneric.cpp so this patch can be skipped.

thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw

Re: [RFC][PATCH 5/5] drm_hwcomposer: HACK: Fix tearing on hikey/hikey960

In reply to John Stultz
Quoted 16 lines · John Stultz

When using drm_hwcomposer with the hikey/hikey960 boards, the resulting display shows lots of tearing.

I'm not much of an expert in how this code should work, but it seems that we never call sync_wait(), and thus don't seem to be handling the fences properly? I'm not sure.

Anyway, in a daze, I started cutting out code trying to make sure we call the CreateNextTimelineFence() and fb.set_release_fence_fd().

After doing so the tearing went away. I'm really not sure what is wrong that requires these hacks. It may be the hikey/hikey960 drm driver is incorrectly reporting or handling something?

Quoted 6 lines

We do only have a single plane and no hardware compositing on the boards, so we are having to force the gpu to do all the compositing.

Any ideas for what a proper fix here would be? Or even just hints on why this might make things work?

So I've maybe started to understand things a bit (though probably not much) more here. Again, my apologies for being very new to all this.

This patch actually isn't necessary on the HiKey960, as in the mix of testing both boards, I didn't get it working until after the HiKey board so I incorrectly assumed this would be needed.

This patch is really only useful to avoid the tearing I see with the HiKey board.

The core issue on HiKey is that in DrmDisplayCompositor::PrepareFrame(), when we initialize the precompositor_ to a new GLWorkerCompositor, the eglCreateContext() call fails because we're asking for version 3, which the HiKey's utgard mali implementation doesn't support (thus why the pre_compositor_->Composite() call always fails in ApplySquash() - though still need to figure out why squash_regions are empty).

Asking for version 2 gets us along a bit further, but then I hit other trouble with the eglMakeCurrent() call in BeginContext, as passing EGL_NO_SURFACE, EGL_NO_SURFACE without EGL_NO_CONTEXT seems to trigger an error in the mali GL implementation. However, using EGL_NO_CONTEXT causes surfaceflinger to crash, so I just hacked it up to skip the eglMakeCurrent call to keep things going.

The next issue that I run into is maybe the more problematic one: The vertex and fragment shaders in the glworker.c are marked as "#version 300 es", which utgard can't handle (apparently it maxes out at "#version 100", but can't seemingly handle other syntax like "in").

So the bigger question I guess I have is: Is the drm_hwcomposer as a project targeting a certain minimal GLES version, or is it open to supporting older/limited hardware like the utgard level mali? I can look into trying to figure out if what needs to be done can be done in a simpler shader language, or alternatively we can add fallback code to still allow for fence handling for tear-free functionality w/o the GL compositor (which is basically what this hack patch in-effect allows).

Are either of these preferred? Or none?

Thoughts?

thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw

Re: [RFC][PATCH 5/5] drm_hwcomposer: HACK: Fix tearing on hikey/hikey960

Quoted 54 lines · John Stultz
Quoted 16 lines · John Stultz

When using drm_hwcomposer with the hikey/hikey960 boards, the resulting display shows lots of tearing.

I'm not much of an expert in how this code should work, but it seems that we never call sync_wait(), and thus don't seem to be handling the fences properly? I'm not sure.

Anyway, in a daze, I started cutting out code trying to make sure we call the CreateNextTimelineFence() and fb.set_release_fence_fd().

After doing so the tearing went away. I'm really not sure what is wrong that requires these hacks. It may be the hikey/hikey960 drm driver is incorrectly reporting or handling something?

Quoted 6 lines

We do only have a single plane and no hardware compositing on the boards, so we are having to force the gpu to do all the compositing.

Any ideas for what a proper fix here would be? Or even just hints on why this might make things work?

So I've maybe started to understand things a bit (though probably not much) more here. Again, my apologies for being very new to all this.

This patch actually isn't necessary on the HiKey960, as in the mix of testing both boards, I didn't get it working until after the HiKey board so I incorrectly assumed this would be needed.

This patch is really only useful to avoid the tearing I see with the HiKey board.

The core issue on HiKey is that in DrmDisplayCompositor::PrepareFrame(), when we initialize the precompositor_ to a new GLWorkerCompositor, the eglCreateContext() call fails because we're asking for version 3, which the HiKey's utgard mali implementation doesn't support (thus why the pre_compositor_->Composite() call always fails in ApplySquash() - though still need to figure out why squash_regions are empty).

Asking for version 2 gets us along a bit further, but then I hit other trouble with the eglMakeCurrent() call in BeginContext, as passing EGL_NO_SURFACE, EGL_NO_SURFACE without EGL_NO_CONTEXT seems to trigger an error in the mali GL implementation. However, using EGL_NO_CONTEXT causes surfaceflinger to crash, so I just hacked it up to skip the eglMakeCurrent call to keep things going.

The next issue that I run into is maybe the more problematic one: The vertex and fragment shaders in the glworker.c are marked as "#version 300 es", which utgard can't handle (apparently it maxes out at "#version 100", but can't seemingly handle other syntax like "in").

Quoted 8 lines

So the bigger question I guess I have is: Is the drm_hwcomposer as a project targeting a certain minimal GLES version, or is it open to supporting older/limited hardware like the utgard level mali? I can look into trying to figure out if what needs to be done can be done in a simpler shader language, or alternatively we can add fallback code to still allow for fence handling for tear-free functionality w/o the GL compositor (which is basically what this hack patch in-effect allows).

It requires ES 3.0 'cause no one has implemented anything else... Doesn't passing CTS since N at least require ES 3.0?

I think having a fallback path that requires no GL is needed. The fence handling there should be simple pass thru to/from the kernel display driver.

Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel