GloDroid / glodroid_manifest

Android port that aims to bring both user- and developer-friendly experience in using AOSP with a set of single-board computers (SBC), phones and other devices.
471 stars 67 forks source link

Allow overriding modifiers for graphic buffers #47

Closed rsglobal closed 4 years ago

rsglobal commented 4 years ago

Currently GloDroid graphics pipeline supports only LINEAR buffers. Since tiled buffers can increase UI performance (increase GPU cache hits), it makes sense to try to enable it.

After fixing mesa issue with modifiers: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6045 , now it possible to use different (mixed) buffer modifiers.

Experimental results showed that using TILED modifiers for all buffers except HWFB (Composition on client side) gives huge performance gain comparing to using linear buffers (Composition on client side case). UI performance increase feels like about 4x on v3d GPU, and about 1.5x-2x on MALI-400.

Action items:

  1. Import modifier by drm_hwomposer generic importer.
  2. Allow to override modifiers with gbm_gralloc, (enable AFBC, different tiling models, etc.). Similar is hard-coded here: https://gitlab.collabora.com/spurv/gbm_gralloc/-/commit/c61679f897f76ddbab2ff3dd11a7cde9847fbfd9 Overriding should be enabled via properties for different buffer usage flags separately.
rsglobal commented 4 years ago

Pinephone build using tiled graphic buffers only: https://drive.google.com/file/d/1Oj9tT9Pz1z67R5wsxzwt8pm0u0pgl2Qp/view?usp=sharing

@nas00, could you check how UI performance changed on PP?

nas00 commented 4 years ago

Yes, it feel likes 2-3x speed increase in places - heres a quick video

nas00 commented 4 years ago

However, video playback appears to be broken - youtube shows black window with correct sound in browser but randomly works sometimes.

logcat contains repeating gralloc-gbm messages like this:

07-23 22:36:25.396 10014 10085 E MESA : error: import buffer offset not properly aligned 07-23 22:36:25.396 10014 10085 E MESA : 07-23 22:36:25.396 10014 10085 E OpenGLRenderer: error creating EGLImage: 0x3003 07-23 22:36:25.396 10014 10085 E OpenGLRenderer: Failed to create image. size=640x360 st=640 usage=0x133 fmt=842094169 07-23 22:36:25.396 10014 10085 W OpenGLRenderer: [SurfaceTexture-844-10014-2] updateAndRelease: unable to createImage on display=0x1 slot=9 07-23 22:36:25.397 10014 10085 E SurfaceTexturePlatformWrapper: Error calling updateTexImage 07-23 22:36:25.397 10014 10085 E SurfaceTexturePlatformWrapper: java.lang.RuntimeException: Error during updateTexImage (see logcat for details) 07-23 22:36:25.397 10014 10085 E SurfaceTexturePlatformWrapper: at android.graphics.SurfaceTexture.nativeUpdateTexImage(Native Method) 07-23 22:36:25.397 10014 10085 E SurfaceTexturePlatformWrapper: at android.graphics.SurfaceTexture.updateTexImage(SurfaceTexture.java:248) 07-23 22:36:25.397 10014 10085 E SurfaceTexturePlatformWrapper: at org.chromium.ui.gl.SurfaceTexturePlatformWrapper.updateTexImage(PG:8) 07-23 22:36:25.402 387 10181 D GRALLOC-GBM: handle 0xeba0278db210, hnd 0xeba0278db210, usage 0x33 07-23 22:36:25.402 387 10181 I GRALLOC-GBM: lock bo 0xeba0278e2cb0, cnt=0, usage=33 07-23 22:36:25.427 387 10181 D GRALLOC-GBM: handle 0xeba0278ddbb0, hnd 0xeba0278ddbb0, usage 0x33 07-23 22:36:25.427 387 10181 I GRALLOC-GBM: lock bo 0xeba0278d5390, cnt=0, usage=33 07-23 22:36:25.439 387 10181 D GRALLOC-GBM: handle 0xeba0278ce970, hnd 0xeba0278ce970, usage 0x33 07-23 22:36:25.439 387 10181 I GRALLOC-GBM: lock bo 0xeba0278d6ad0, cnt=0, usage=33 07-23 22:36:25.454 387 10181 D GRALLOC-GBM: handle 0xeba0278e6c70, hnd 0xeba0278e6c70, usage 0x33 07-23 22:36:25.454 387 10181 I GRALLOC-GBM: lock bo 0xeba0278d5f30, cnt=0, usage=33 07-23 22:36:25.464 387 10181 D GRALLOC-GBM: handle 0xeba0278da130, hnd 0xeba0278da130, usage 0x33 07-23 22:36:25.464 387 10181 I GRALLOC-GBM: lock bo 0xeba0278d11f0, cnt=0, usage=33 07-23 22:36:25.467 387 10181 D GRALLOC-GBM: handle 0xeba0278d4af0, hnd 0xeba0278d4af0, usage 0x33 07-23 22:36:25.467 387 10181 I GRALLOC-GBM: lock bo 0xeba0278da430, cnt=0, usage=33 07-23 22:36:25.482 10014 10069 D : PlayerBase::stop() from IPlayer 07-23 22:36:25.482 10014 10069 D AudioTrack: stop(13): called with 478940 frames delivered

and dmesg mentions this once:

[ 99.050778] lima 1c40000.gpu: mmu page fault at 0x233a000 from bus id 0 of type read on ppmmu0 [ 99.059575] lima 1c40000.gpu: mmu page fault at 0x233a040 from bus id 0 of type read on ppmmu1 [ 99.069281] lima 1c40000.gpu: pp task error 0 int_state=0 status=5 [ 99.075900] lima 1c40000.gpu: pp task error 1 int_state=0 status=5 [ 99.085131] lima 1c40000.gpu: mmu resume [ 99.091357] lima 1c40000.gpu: mmu resume

nas00 commented 4 years ago

Youtube videos shot in horizontal aspect ratio work at 240p or below. Portrait videos work at 360p or below. Going above those limits results in frozen/flickering picture or black frame.

rsglobal commented 4 years ago

@nas00 , thank you for testing. Can you check today's integration build. Youtube issue should be fixed.

nas00 commented 4 years ago

360p now works reliably. 480p and 720p mostly give 'An error occurred' message or frozen/black frame. 1080p works half of time.

Here's a log - single youtube video stepped through 144p, 240p, 360p, 480p, 720p, 1080p.

-144p worked -240p worked -360p worked -480p&720p didn't work and generated GRALLOC-GBM: lock bo messages (although page reload seemed to make one play properly) -1080p worked

youtube.log

rsglobal commented 4 years ago

Thanks, I've applied some fixes and updated integration build.

nas00 commented 4 years ago

Video playback seems to work up to 720p now. Tried 1080p but frozen frame - possibly related to pinephone overheating in this hot weather so will test when cooler. Still no audio. Also, notice every video gives repeating messages like these now:

08-10 23:01:40.205 304 11031 D GRALLOC-GBM: handle 0xf739b06f2f30, hnd 0xf739b06f2f30, usage 0x33 08-10 23:01:40.205 304 11031 I GRALLOC-GBM: lock bo 0xf739b06f49d0, cnt=0, usage=33

Edit: Confirmed that 1080p youtube is frozen or black frame.

rsglobal commented 4 years ago

Audio functionality restored. logcat messages is debug messages, I will silence them later.

nas00 commented 4 years ago

Good job - 1080p and audio both working fine now.

rsglobal commented 4 years ago

After more investigation, it turns out that using modifiers does not offer much performance increasing on lima, we will improve GPU off-loading instead. As for AFBC, separated ticket will be created when we will be ready for it.