Project

General

Profile

GraphicsResearch » History » Version 35

Jeremy Rand, 06/22/2019 12:04 PM
Use adj's OpenGL backend switcher repos instead of Jeremy's

1 1 Wolfgang Wiedmeyer
h1. Research on free graphics-related software
2
3 12 Wolfgang Wiedmeyer
{{>toc}}
4
5 5 Wolfgang Wiedmeyer
On this page, information is collected that could help solving graphics issues in Replicant (see #1539). Besides evaluating free implementations that are relevant for currently supported devices, other implementations should also be listed if they are useful for potential future target devices.
6 1 Wolfgang Wiedmeyer
7 8 Wolfgang Wiedmeyer
external resources:
8
"Wikipedia":https://en.wikipedia.org/wiki/Free_and_open-source_graphics_device_driver
9 13 Wolfgang Wiedmeyer
"Debian Mobile":https://wiki.debian.org/Mobile#Drivers
10 8 Wolfgang Wiedmeyer
11 21 Denis 'GNUtoo' Carikli
h2. Multiple backends
12
13 35 Jeremy Rand
See the following repos for work in progress to enable to switch the OpenGL library for individual applications:
14
15
* https://github.com/andresdju/vendor_replicant
16
* https://github.com/andresdju/frameworks_native
17 21 Denis 'GNUtoo' Carikli
18 1 Wolfgang Wiedmeyer
h2. Software rendering
19
20 7 Wolfgang Wiedmeyer
Software rendering uses the CPU and not a dedicated graphics processor for graphics rendering. It is slower than per-GPU implementations and is usually used when it is not possible to make use of the GPU. An advantage is that the same software renderer can work across many different types of hardware, so working on improving a software renderer benefits many different devices, regardless of the SOC and graphics unit that is used. Furthermore, a software renderer doesn't require a kernel driver which makes it easier to work on mainline Linux kernel support for a device until the graphics driver is in mainline.
21 2 Wolfgang Wiedmeyer
22 1 Wolfgang Wiedmeyer
h3. Android software renderer
23 2 Wolfgang Wiedmeyer
24 14 Wolfgang Wiedmeyer
source code: https://git.replicant.us/replicant/frameworks_native/tree/opengl/libagl
25 2 Wolfgang Wiedmeyer
26 26 dl lud
The Android software renderer is currently used on all Replicant-supported devices and it is the fastest software renderer that is available for Replicant devices. It is a software renderer that was developed specifically for Android and it is part of the AOSP source code. The renderer includes optimizations for ARM via "libpixelflinger":https://android.googlesource.com/platform/system/core/+/master/libpixelflinger and "codeflinger":https://android.googlesource.com/platform/system/core/+/master/libpixelflinger/codeflinger/ that do JIT compilation into platform optimized code. Development ceased in 2013 and no work was done to support newer OpenGL ES (GLES) versions (which causes #705).
27 2 Wolfgang Wiedmeyer
28 26 dl lud
Until ca. 2011 (Android 4.0), another library with the name @libagl2@ existed and @surfaceflinger2@ was developed based on Mesa. The source code was later removed and no further development is known. At the time, the work was done to support a newer GLES version for the software renderer. It was abandoned later, probably when Google made it mandatory for Android 4.0 and later devices to pack their own hardware GPU with OpenGL ES 2.0 support. It is questionable if it is worth it to port the old @libagl2@ library to a recent Replicant version, also given that we would be the only ones using and maintaining the code.
29 1 Wolfgang Wiedmeyer
30 31 dl lud
h3. Mesa's llvmpipe
31 1 Wolfgang Wiedmeyer
32 20 Denis 'GNUtoo' Carikli
*Replicant llvmpipe support source code*: https://git.replicant.us/replicant/external_mesa3d
33
*Replicant documentation*: [[Graphics]]
34
*Upstream documentation*: https://www.mesa3d.org/llvmpipe.html
35
*Upstream performance improvement documentation*: https://www.mesa3d.org/perf.html
36 3 Wolfgang Wiedmeyer
37 32 dl lud
For the needs in Replicant, llvmpipe has a GLES implementation that is complete enough. Although, some apps don't work due to minor bugs which seem fixable or which might already be fixed in more recent upstream versions.
38
39
Besides llvmpipe, Mesa has two other software rasterizers: swrast/swr and softpipe, but both are of no interest. swrast's GLES implementation is incomplete and this driver is mostly deprecated in favor of those built upon Gallium (softpipe and llvmpipe). softpipe on the other hand, "is as complete as llvmpipe":https://mesamatrix.net/ but is slower than it.
40 3 Wolfgang Wiedmeyer
41 28 dl lud
The "Android-x86 project":http://www.android-x86.org/ is using llvmpipe and quite a few of their Android-specific frameworks patches are applied in Replicant 6.0. Their Mesa source code fork is also used in Replicant 6.0. A lot of porting work of llvmpipe to Android was done by Jide while Intel is contributing as well. So there is an interest from different parties to have llvmpipe working on Android. Android patches are upstreamed to mainline Mesa.
42 3 Wolfgang Wiedmeyer
43 1 Wolfgang Wiedmeyer
However, llvmpipe is still not ported to ARM which makes it slow. Also for Android, it is mostly used on the x86 platform in other projects. See #705 for more information. Optimizing llvmpipe for ARM seems currently the most promising approach to fix graphics-related issues with Replicant.
44 31 dl lud
45
h3. kms_swrast
46
47
"kms_swrast":https://memcpy.io/kms_swrast-a-hardware-backed-graphics-driver.html is a Mesa driver, built upon Gallium, that uses DRM nodes for memory allocation and to present images on the display, but does the actual OpenGL rendering through a Mesa software renderer such as llvmpipe or softpipe.
48
It may allow noticeable performance improvements by avoiding expensive memory copy operations between the software renderer and DRM.
49
50
Exynos based devices have a working free-software DRM driver that can be used with kms_swrast. Devices that do not have DRM driver can still benefit from kms_swrast by usage of the "VGEM (Virtual GEM) driver":https://www.phoronix.com/scan.php?page=news_item&px=MTA0MTQ.
51 3 Wolfgang Wiedmeyer
52 1 Wolfgang Wiedmeyer
h3. SwiftShader
53 3 Wolfgang Wiedmeyer
54
source code: https://swiftshader.googlesource.com/SwiftShader
55
56 27 dl lud
"Google released SwiftShader as free software in mid 2016":https://blog.chromium.org/2016/06/universal-rendering-with-swiftshader.html. It supports x86 (32 bit and 64 bit) and 32 bit ARM architectures with SDIV/UDIV support. It is used in the Chromium project but also with Android, for example in the Android-x86 project. Swiftshader doesn't seem to depend on any external libraries besides what are provided in its Git repository, therefore it is very easy to compile it and use it as a software renderer for Replicant. All the Android build files are provided so you just need to the add the following packages to PRODUCT_PACKAGES in order to be able to use it:
57 18 Joonas Kylmälä
58
 * libGLESv2_swiftshader
59
 * libEGL_swiftshader
60 1 Wolfgang Wiedmeyer
61 34 dl lud
h3. Pixman
62
63
source code: https://cgit.freedesktop.org/pixman/
64
65
> "Pixman":http://pixman.org/ is a low-level software library for pixel manipulation, providing features such as image compositing and trapezoid rasterization.
66
67
It is highly optimized for ARM processors and has a "fast path for ARM NEON":https://www.phoronix.com/scan.php?page=news_item&px=OTAyOQ. It may be worthwhile to write an OpenGL ES backend for Replicant that detects 2D operations and translates them to Pixman. This could provide a considerable performance improvement over llvmpipe or SwiftShader and, if complete enough, could even replace them.
68
69
On the other hand, writing such translation layer may prove to be an enormous task, as the OpenGL ES 2.0 API is quite extensive. In this scenario we can still benefit from Pixman by reproducing it's ARM NEON fast paths on llvmpipe.
70
71 1 Wolfgang Wiedmeyer
h2. Per-GPU implementations
72
73 9 Wolfgang Wiedmeyer
In the following, free software implementations are listed that should make it possible to use the respective GPU with free software.
74 1 Wolfgang Wiedmeyer
75 23 dl lud
h3. ARM Mali-4xx (Utgard) with Lima
76 7 Wolfgang Wiedmeyer
77 22 dl lud
Supported devices that use Mali 400: Galaxy S 2, Galaxy S 3, Galaxy S 3 4G, Galaxy Note, Galaxy Note 2
78 7 Wolfgang Wiedmeyer
79 22 dl lud
Project page: https://gitlab.freedesktop.org/lima/web/wikis/home
80 1 Wolfgang Wiedmeyer
81 22 dl lud
Lima is still unfinished as of January 2019 but development is going on at a fast pace. The detailed implementation status can be checked "with the piglit test suite":https://gitlab.freedesktop.org/lima/mesa/issues/39#note_79193.
82 7 Wolfgang Wiedmeyer
83 23 dl lud
Lima saw first light with the reverse-engineering efforts by Luc Verhaegen, that produced an experimental driver with it's original page at  
84 22 dl lud
https://limadriver.org . Luc's development stopped around 2014, but in 2017 Qiang Yu took on the task and started development on top of Mesa's Gallium3D driver as "reported by Phoronix":https://www.phoronix.com/scan.php?page=news_item&px=Mali-400-New-Open-Source. 
85
The code is now hosted at "freedesktop.org's GitLab":https://gitlab.freedesktop.org/lima and is getting contributions by many developers besides Qiang Yu.
86 16 Jeremy Rand
87 1 Wolfgang Wiedmeyer
h3. Imagination PowerVR
88
89
supported devices that use PowerVR SGX540: Nexus S, Galaxy S, Galaxy Nexus, Galaxy Tab 2 7.0, Galaxy Tab 2 10.1
90 5 Wolfgang Wiedmeyer
supported devices that use PowerVR SGX530: GTA04
91 8 Wolfgang Wiedmeyer
92
A reverse-engineering project exists:
93 10 Wolfgang Wiedmeyer
"website":http://powervr.gnu.org.ve/doku.php
94
"mailing list":http://listas.gnu.org.ve/listinfo/powervr-devel
95 8 Wolfgang Wiedmeyer
"Libreplanet group":https://libreplanet.org/wiki/Group:PowerVR_drivers
96 1 Wolfgang Wiedmeyer
97
Despite initial reverse-engineering progress until 2013, no further development updates seem to be available. The project website provides documentation.
98 23 dl lud
99
h3. ARM Mali-T6xx/T7xx/T8xx (Midgard) and G7x (Bifrost) with Panfrost
100
101
not used by a supported device
102
Used on several Samsung Galaxy S series phones that are now supported by LineageOs and may be potential targets for Replicant ports: S6
103
(Mali T760MP8), S7 (Mali-T880 MP12) and S9 (Mali-G72 MP18).
104
105
Project page: https://panfrost.freedesktop.org/
106
Source code: https://gitlab.freedesktop.org/panfrost
107
108 33 dl lud
Panfrost is another reverse-engineered driver for ARM Mali GPUs, but aimed at the latest architectures (Midgard and Bifrost). It is still experimental but under active development with a strong community (as of April 2019). "Its implementation of OpenGL ES 2.0 is approaching feature-completeness":https://rosenzweig.io/blog/kodi-supertuxkart-panfrost.html.
109
Panfrost's main focus are the ARM SoCs present on some laptops and single-board computers (SBC), but it is "Intended to work on as many SoCs as possible to make everyone's lives easier":https://gitlab.freedesktop.org/panfrost/mali_kbase.
110
Panfrost is developed by Alyssa Rosenzweig and Lyude Paul, and recently attracted other contributors such as "Tomeu Vizoso":https://blog.tomeuvizoso.net/ and "Rob Herring":https://gitlab.freedesktop.org/robh.
111 23 dl lud
Development can be followed on "Alyssas's blog":https://rosenzweig.io/blog/.
112 1 Wolfgang Wiedmeyer
113 24 dl lud
h3. Qualcomm Adreno with freedreno
114 1 Wolfgang Wiedmeyer
115
not used by a supported device
116 9 Wolfgang Wiedmeyer
117
wiki: https://github.com/freedreno/freedreno/wiki
118
119
freedreno is actively developed. Linux kernel component is available in mainline since version 3.12. It needs to be investigated how well freedreno could work on potential target devices. However, even when using freedreno, non-free firmware is very likely still needed.
120
121
Generally speaking, Qualcomm devices have a lot of blobs and no modem isolation which is the reason why no Qualcomm-based device is yet supported by Replicant. See [[TargetsEvaluation]] for some analysis. We have not yet identified a Qualcomm-based device that would be a promising target for Replicant and where freedreno could be used on.
122 15 Wolfgang Wiedmeyer
123 24 dl lud
h3. Vivante GCxxxx with Etnaviv
124 15 Wolfgang Wiedmeyer
125
not used by a supported device
126
127
For some Vivante GCxxxx GPU variants, a free driver, Etnaviv, exists. See "wikipedia":https://en.wikipedia.org/wiki/Free_and_open-source_graphics_device_driver#Vivante for some details. It would be interesting to investigate devices using such a GPU if they would be good Replicant targets. It also needs to be checked if non-free firmware needs to be loaded to the GPU.
128 29 dl lud
129
h2. Gralloc
130
131
In order to have a working software rendering on Replicant 9 we will need a gralloc (graphics memory allocator) library that:
132
* Implements the "Android Gralloc HAL":https://source.android.com/devices/graphics/implement#gralloc_hal API version 1.
133
* Is compatible with "drm-hwcomposer":https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer (a libre implementation, based on Linux's DRM, of Android's Hardware Composer HAL).
134
* Is compatible with Mesa and particularly its llvmpipe software renderer.
135
* (optional) Is compatible with SwiftShader.
136
137 30 dl lud
There are currently 3 free-software grallocs under evaluation:
138 29 dl lud
* "drm_gralloc":https://osdn.net/projects/android-x86/scm/git/external-drm_gralloc/summary - Directly uses Linux DRM for buffer allocation. Built by the Android-x86 team and now getting phased out in favor of gbm_gralloc.
139
* "gbm_gralloc":https://osdn.net/projects/android-x86/scm/git/external-gbm_gralloc/summary - Uses Mesa's GBM (Generic Buffer Management) for buffer allocation through libgbm. GBM itself will then call DRM. Originally "by Rob Herring":https://github.com/robherring/gbm_gralloc, but now maintained by Android-x86.
140 1 Wolfgang Wiedmeyer
* "minigbm":https://github.com/intel/minigbm - Uses its own embedded GBM implementation. Does not depend on Mesa. Built by Intel for their Android-IA project now dubbed "Project Celadon":https://github.com/projectceladon. Also used by Google "in ChromiumOS":https://chromium.googlesource.com/chromiumos/platform/minigbm/.
141 30 dl lud
142
The table bellow summarizes the capabilities of these 3 gralloc implementations (sourced from the "slides":https://xdc2018.x.org/slides/XDC2018_Android-x86_Tech_Talk.pdf of "Mauro's Rossi talk at XDC 2018":https://www.youtube.com/watch?v=O1D_XYaxs-c):
143
144
|_. project |_. API version |_. GEM/flink names |_. PRIME fd |_. binderization |
145
|=. drm_gralloc |=. 0 |=. Yes |=. incomplete |=. No |
146
|=. gbm_gralloc |=. 0 |=. N/A |=. Yes |=. Yes |
147
|=. minigbm |=. 0, 1 |=. N/A |=. Yes |=. Yes |
148
149
Key:
150
* *project*: the implementation name.
151
* *API version*: lists the supported versions of Android's gralloc HAL.
152
* *GEM/flink names*: whether there is support for GEM (Graphics Execution Manager) object sharing through GEM names. GEM names are unique 32 bit integers, created via the flink operation, that point to a unique GEM object inside a DRM device. GEM names are mostly deprecated due to security reasons.
153
* *PRIME fd*: whether there is support for buffer sharing between different DRM drivers through PRIME, the successor of GEM names. PRIME allows the conversion of local GEM handles to DMA-BUF file descriptors and vice-versa, via the DMA Buffer Sharing API.
154
* *binderization*: whether there is support for using a binder, a structure that allows memory sharing between different processes on the same machine (for instance a Queue).