1bf215546Sopenharmony_ciLima
2bf215546Sopenharmony_ci====
3bf215546Sopenharmony_ci
4bf215546Sopenharmony_ciLima is an open source graphics driver which supports Mali Utgard
5bf215546Sopenharmony_ci(Mali-4xx) embedded GPUs from ARM. It’s a reverse-engineered,
6bf215546Sopenharmony_cicommunity-developed driver, and is not endorsed by ARM. Lima was
7bf215546Sopenharmony_ciupstreamed in Mesa 19.1 and Linux kernel 5.2.
8bf215546Sopenharmony_ci
9bf215546Sopenharmony_ci========  ============ ===========
10bf215546Sopenharmony_ciProduct   Architecture   Status
11bf215546Sopenharmony_ci========  ============ ===========
12bf215546Sopenharmony_ciMali-400     Utgard     Supported
13bf215546Sopenharmony_ciMali-450     Utgard     Supported
14bf215546Sopenharmony_ciMali-470     Utgard    Unsupported
15bf215546Sopenharmony_ci========  ============ ===========
16bf215546Sopenharmony_ci
17bf215546Sopenharmony_ciNewer Mali chips based on the Midgard/Bifrost architectures (Mali T or G
18bf215546Sopenharmony_ciseries) are handled by the :doc:`Panfrost <panfrost>` driver, not Lima.
19bf215546Sopenharmony_ci
20bf215546Sopenharmony_ciNote that the Mali GPU is only for rendering: the GPU does not control a
21bf215546Sopenharmony_cidisplay and has little to do with display-related issues.
22bf215546Sopenharmony_ciEach SoC has its own separate display engine to control the display
23bf215546Sopenharmony_cioutput. To display the contents rendered by the Mali GPU to a screen, a
24bf215546Sopenharmony_ciseparate `display driver <#display-drivers>`__ is also required, which
25bf215546Sopenharmony_ciis able to share buffers with the GPU. In Mesa, this is handled by
26bf215546Sopenharmony_ci``kmsro``.
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ciSupported APIs
29bf215546Sopenharmony_ci--------------
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ciLima mainly targets **OpenGL ES 2.0**, as well as **OpenGL 2.1**
32bf215546Sopenharmony_ci(desktop) to some extent.
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ciThe OpenGL (desktop) implementation is enabled by Mesa and Gallium,
35bf215546Sopenharmony_ciwhere it is possible to reuse the same implementation backend. That way,
36bf215546Sopenharmony_ciit is possible to support running a majority of Linux desktop
37bf215546Sopenharmony_ciapplications designed for OpenGL. It is not possible to fully support
38bf215546Sopenharmony_ciOpenGL (desktop), though, due to hardware limitations. Some (but not
39bf215546Sopenharmony_ciall) features of OpenGL 2.1 that are not supported directly in hardware
40bf215546Sopenharmony_ciare enabled by internal shader transformations.
41bf215546Sopenharmony_ciCheck the `known hardware limitations <#known-hardware-limitations>`__
42bf215546Sopenharmony_cilist for additional information.
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_ci**OpenGL ES 1.1** and **OpenGL 1.x** are also provided by Mesa and
45bf215546Sopenharmony_cisimilarly supported to some extent in Lima.
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ciDisplay drivers
48bf215546Sopenharmony_ci---------------
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ciThese are some display drivers that have been tested with Lima:
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ci- Allwinner: ``sun4i-drm``
53bf215546Sopenharmony_ci- Amlogic: ``meson``
54bf215546Sopenharmony_ci- Ericsson MCDE: ``mcde``
55bf215546Sopenharmony_ci- Exynos: ``exynos``
56bf215546Sopenharmony_ci- Rockchip: ``rockchip``
57bf215546Sopenharmony_ci- Tiny DRM: ``tinydrm``
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ciEnvironment variables
60bf215546Sopenharmony_ci---------------------
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_ciThese are some Lima-specific environment variables that may aid in
63bf215546Sopenharmony_cidebugging. None of this is required for normal use.
64bf215546Sopenharmony_ci
65bf215546Sopenharmony_ci.. envvar:: LIMA_DEBUG <flags> ("")
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ciaccepts the following comma-separated list of flags:
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ci  ``bocache``
70bf215546Sopenharmony_ci    print debug info for BO cache
71bf215546Sopenharmony_ci  ``diskcache``
72bf215546Sopenharmony_ci    print debug info for shader disk cache
73bf215546Sopenharmony_ci  ``dump``
74bf215546Sopenharmony_ci    dump GPU command stream to ``$PWD/lima.dump``
75bf215546Sopenharmony_ci  ``gp``
76bf215546Sopenharmony_ci    print GP shader compiler result of each stage
77bf215546Sopenharmony_ci  ``noblit``
78bf215546Sopenharmony_ci    use generic u_blitter instead of lima-specific
79bf215546Sopenharmony_ci  ``nobocache``
80bf215546Sopenharmony_ci    disable BO cache
81bf215546Sopenharmony_ci  ``nogrowheap``
82bf215546Sopenharmony_ci    disable growable heap buffer
83bf215546Sopenharmony_ci  ``notiling``
84bf215546Sopenharmony_ci    don’t use tiled buffers
85bf215546Sopenharmony_ci  ``pp``
86bf215546Sopenharmony_ci    print PP shader compiler result of each stage
87bf215546Sopenharmony_ci  ``precompile``
88bf215546Sopenharmony_ci    precompile shaders for shader-db
89bf215546Sopenharmony_ci  ``shaderdb``
90bf215546Sopenharmony_ci    print shader information for shaderdb
91bf215546Sopenharmony_ci  ``singlejob``
92bf215546Sopenharmony_ci    disable multi job optimization
93bf215546Sopenharmony_ci
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ci.. envvar:: LIMA_CTX_NUM_PLB <int> (None)
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ciset number of PLB per context (used for development purposes)
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_ci.. envvar:: LIMA_PLB_MAX_BLK <int> (None)
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ciset PLB max block (used for development purposes)
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ci.. envvar:: LIMA_PPIR_FORCE_SPILLING <int> (None)
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_ciforce spilling of variables in ppir (used for development purposes)
106bf215546Sopenharmony_ci
107bf215546Sopenharmony_ci.. envvar:: LIMA_PLB_PP_STREAM_CACHE_SIZE <int> (None)
108bf215546Sopenharmony_ci
109bf215546Sopenharmony_ciset PP stream cache size (used for development purposes)
110bf215546Sopenharmony_ci
111bf215546Sopenharmony_ciKnown hardware limitations
112bf215546Sopenharmony_ci--------------------------
113bf215546Sopenharmony_ci
114bf215546Sopenharmony_ciHere are some known caveats in OpenGL support:
115bf215546Sopenharmony_ci
116bf215546Sopenharmony_ci- ``glPolygonMode()`` with ``GL_LINE`` is not supported. This is not part of
117bf215546Sopenharmony_ci  OpenGL ES 2.0 and so it is not possible to reverse engineer.
118bf215546Sopenharmony_ci
119bf215546Sopenharmony_ci- Precision limitations in fragment shaders:
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_ci  - In general, only
122bf215546Sopenharmony_ci    `FP16 <https://en.wikipedia.org/wiki/Half-precision_floating-point_format>`__
123bf215546Sopenharmony_ci    precision is supported in fragment shaders. Specifying ``highp``
124bf215546Sopenharmony_ci    will have no effect.
125bf215546Sopenharmony_ci  - Integers are not supported in hardware, they are lowered down to
126bf215546Sopenharmony_ci    FP16.
127bf215546Sopenharmony_ci  - There is a higher precision (FP24) path for texture lookups, if
128bf215546Sopenharmony_ci    there is *no* math performed on texture coordinates obtained from
129bf215546Sopenharmony_ci    varyings. If there is *any* calculation done in the texture
130bf215546Sopenharmony_ci    coordinates, the texture coordinates will fall back to FP16 and
131bf215546Sopenharmony_ci    that may affect the quality of the texture lookup.
132bf215546Sopenharmony_ci
133bf215546Sopenharmony_ci- Lima supports FP16 textures in OpenGL ES (through
134bf215546Sopenharmony_ci  ``GL_OES_texture_half_float``), but not in OpenGL.
135bf215546Sopenharmony_ci  This is because it would require ``ARB_texture_float`` which would also
136bf215546Sopenharmony_ci  require 32-bit float textures, that the Mali-4xx does not support.
137bf215546Sopenharmony_ci- Rendering to FP16 is possible, but the result is clamped to the
138bf215546Sopenharmony_ci  [0.0,1.0] range.
139bf215546Sopenharmony_ci
140bf215546Sopenharmony_ciBug Reporting
141bf215546Sopenharmony_ci-------------
142bf215546Sopenharmony_ci
143bf215546Sopenharmony_ciPlease try the latest Mesa development branch or at least Mesa latest
144bf215546Sopenharmony_cirelease before reporting issues. Please review the
145bf215546Sopenharmony_ci:doc:`Mesa bug report guidelines <../bugs>`.
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ciIssues should be filed as a `Mesa issue`_.
148bf215546Sopenharmony_ciLima tags will be added accordingly by the developers.
149bf215546Sopenharmony_ci
150bf215546Sopenharmony_ci`apitrace <https://github.com/apitrace/apitrace>`__ traces are very
151bf215546Sopenharmony_ciwelcome in issue reports and significantly ease the debug and fix
152bf215546Sopenharmony_ciprocess.
153bf215546Sopenharmony_ci
154bf215546Sopenharmony_ciFAQ
155bf215546Sopenharmony_ci---
156bf215546Sopenharmony_ci
157bf215546Sopenharmony_ciWill Lima support OpenGL 3.x+ / OpenGL ES 3.x+ / OpenCL / Vulkan ?
158bf215546Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ci**No.** The Mali-4xx was designed to implement OpenGL ES 2.0 and OpenGL
161bf215546Sopenharmony_ciES 1.1. The hardware lacks features to properly implement some features
162bf215546Sopenharmony_cirequired by newer APIs.
163bf215546Sopenharmony_ci
164bf215546Sopenharmony_ciHow complete is Lima? Is reverse engineering complete?
165bf215546Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
166bf215546Sopenharmony_ci
167bf215546Sopenharmony_ciAt the time of writing, with local runs of the
168bf215546Sopenharmony_ci`OpenGL ES Conformance Tests <https://github.com/KhronosGroup/VK-GL-CTS/>`__
169bf215546Sopenharmony_ci(deqp) for OpenGL ES 2.0, Lima reports **97%** pass rate.
170bf215546Sopenharmony_ciThis coverage is on par with coverage provided by the ARM Mali driver.
171bf215546Sopenharmony_ciSome tests that pass with Lima fail on Mali and vice versa. Some of
172bf215546Sopenharmony_cithese issues are related to precision limitations which likely don’t
173bf215546Sopenharmony_ciaffect end user applications.
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_ciThe work being done in Lima at this stage is largely decoupled from
176bf215546Sopenharmony_cireverse engineering. Reverse engineering is still useful sometimes to
177bf215546Sopenharmony_ciobtain details on how to implement low level features (e.g. how to
178bf215546Sopenharmony_cienable some missing legacy OpenGL ES 1.1 feature to support an
179bf215546Sopenharmony_ciadditional application), but with the current information Lima is
180bf215546Sopenharmony_cialready able to cover most of OpenGL ES 2.0.
181bf215546Sopenharmony_ci
182bf215546Sopenharmony_ciMuch of the work to be done is related to plumbing features within the
183bf215546Sopenharmony_ciframeworks provided by Mesa, fixing bugs (e.g. artifacts or crashes in
184bf215546Sopenharmony_cispecific applications), shader compiler improvements, which are not
185bf215546Sopenharmony_cinecessarily related to new hardware bits and not related at all to the
186bf215546Sopenharmony_ciMali driver.
187bf215546Sopenharmony_ci
188bf215546Sopenharmony_ciWhen will Feature XYZ be supported? Is there a roadmap for features implementation?
189bf215546Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190bf215546Sopenharmony_ci
191bf215546Sopenharmony_ciThere is no established roadmap for features implementation.
192bf215546Sopenharmony_ciDevelopment is driven by improving coverage in existing OpenGL test
193bf215546Sopenharmony_ciframeworks, adding support to features that enable more existing Linux
194bf215546Sopenharmony_ciapplications, and fixing issues reported by users in their applications.
195bf215546Sopenharmony_ciDevelopment is fully based on community contributions.
196bf215546Sopenharmony_ci
197bf215546Sopenharmony_ciIf some desired feature is missing or there is an OpenGL-related bug
198bf215546Sopenharmony_ciwhile running some application, please do file a `Mesa issue`_.
199bf215546Sopenharmony_ciIssues that are not reproduced by an existing test suite or common
200bf215546Sopenharmony_ciapplication and are also not reported by users are just likely not going
201bf215546Sopenharmony_cito be noticed and fixed.
202bf215546Sopenharmony_ci
203bf215546Sopenharmony_ciHow does Lima compare to Mali (blob)? How is performance?
204bf215546Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205bf215546Sopenharmony_ci
206bf215546Sopenharmony_ciBy the fact that Lima is a fully open source driver and leverages a lot
207bf215546Sopenharmony_ciof Mesa and Linux functionality, feature-wise Lima is able to support
208bf215546Sopenharmony_cimany things that Mali does not. As already mentioned, supporting OpenGL
209bf215546Sopenharmony_ci2.1 is one of them. This allows Lima to support many more Linux desktop
210bf215546Sopenharmony_ciapplications out of the box. Through the abstractions implemented in
211bf215546Sopenharmony_ciMesa, Lima supports a number of OpenGL and OpenGL ES extensions that
212bf215546Sopenharmony_cioriginally the Mali did not support. Lima is also aligned with the
213bf215546Sopenharmony_cicurrent status of the Linux graphics stack and is therefore able to
214bf215546Sopenharmony_cileverage modern features (such as zero copy pipelines) much more
215bf215546Sopenharmony_ciseamlessly. Finally, Lima continues to gain improvements as the Linux
216bf215546Sopenharmony_cigraphics ecosystem evolves.
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_ciThe entire software stack of the Mali driver and the software stack with
219bf215546Sopenharmony_ciLima are significantly different which makes it hard to offer a single
220bf215546Sopenharmony_cinumber comparison for performance of the GPU driver. The difference
221bf215546Sopenharmony_cireally depends on the type of application. Keep in mind that hardware
222bf215546Sopenharmony_cicontaining a Mali-4xx is usually quite limited for modern standards and
223bf215546Sopenharmony_ciit might not perform as well as hoped. For example: while it is now
224bf215546Sopenharmony_citechnically possible to run full GL modern desktop environments at 1080p
225bf215546Sopenharmony_ci(which might not have been even possible before due to limited GL
226bf215546Sopenharmony_cisupport), that might not be very performant due to memory bandwidth, CPU
227bf215546Sopenharmony_ciand GPU limitations of the SoC with a Mali-4xx.
228bf215546Sopenharmony_ci
229bf215546Sopenharmony_ciOverall performance with Lima is good for many applications where the
230bf215546Sopenharmony_ciMali-4xx would be a suitable target GPU.
231bf215546Sopenharmony_ciBut bottom line for a performance evaluation, you need to try with your
232bf215546Sopenharmony_citarget application. If performance with Lima does not seem right in some
233bf215546Sopenharmony_ciapplication where it should reasonably perform better, please file a
234bf215546Sopenharmony_ci`Mesa issue`_ (in which case some indication on why Lima in particular
235bf215546Sopenharmony_ciseems to be the bottleneck would also be helpful).
236bf215546Sopenharmony_ci
237bf215546Sopenharmony_ciCommunication channels
238bf215546Sopenharmony_ci----------------------
239bf215546Sopenharmony_ci
240bf215546Sopenharmony_ci- `#lima channel <irc://irc.oftc.net/lima>`__ on `irc.oftc.net <https://webchat.oftc.net/>`__
241bf215546Sopenharmony_ci- `lima mailing list <https://lists.freedesktop.org/mailman/listinfo/lima>`__
242bf215546Sopenharmony_ci- `dri-devel mailing list <https://lists.freedesktop.org/mailman/listinfo/dri-devel>`__
243bf215546Sopenharmony_ci
244bf215546Sopenharmony_ciDump tool
245bf215546Sopenharmony_ci---------
246bf215546Sopenharmony_ci
247bf215546Sopenharmony_ciA tool to dump the runtime of the closed source Mali driver for
248bf215546Sopenharmony_cireverse engineering is available at:
249bf215546Sopenharmony_cihttps://gitlab.freedesktop.org/lima/mali-syscall-tracker
250bf215546Sopenharmony_ci
251bf215546Sopenharmony_ciReference
252bf215546Sopenharmony_ci---------
253bf215546Sopenharmony_ci
254bf215546Sopenharmony_ciLuc Verhaegen’s original Lima site:
255bf215546Sopenharmony_cihttp://web.archive.org/web/20180106112822/http://limadriver.org/
256bf215546Sopenharmony_ci
257bf215546Sopenharmony_ci.. _Mesa issue: https://gitlab.freedesktop.org/mesa/mesa/issues?label_name%5B%5D=lima
258