1*61046927SAndroid Build Coastguard WorkerLima 2*61046927SAndroid Build Coastguard Worker==== 3*61046927SAndroid Build Coastguard Worker 4*61046927SAndroid Build Coastguard WorkerLima is an open source graphics driver which supports Mali Utgard 5*61046927SAndroid Build Coastguard Worker(Mali-4xx) embedded GPUs from ARM. It’s a reverse-engineered, 6*61046927SAndroid Build Coastguard Workercommunity-developed driver, and is not endorsed by ARM. Lima was 7*61046927SAndroid Build Coastguard Workerupstreamed in Mesa 19.1 and Linux kernel 5.2. 8*61046927SAndroid Build Coastguard Worker 9*61046927SAndroid Build Coastguard Worker======== ============ =========== 10*61046927SAndroid Build Coastguard WorkerProduct Architecture Status 11*61046927SAndroid Build Coastguard Worker======== ============ =========== 12*61046927SAndroid Build Coastguard WorkerMali-400 Utgard Supported 13*61046927SAndroid Build Coastguard WorkerMali-450 Utgard Supported 14*61046927SAndroid Build Coastguard WorkerMali-470 Utgard Unsupported 15*61046927SAndroid Build Coastguard Worker======== ============ =========== 16*61046927SAndroid Build Coastguard Worker 17*61046927SAndroid Build Coastguard WorkerNewer Mali chips based on the Midgard/Bifrost architectures (Mali T or G 18*61046927SAndroid Build Coastguard Workerseries) are handled by the :doc:`Panfrost <panfrost>` driver, not Lima. 19*61046927SAndroid Build Coastguard Worker 20*61046927SAndroid Build Coastguard WorkerNote that the Mali GPU is only for rendering: the GPU does not control a 21*61046927SAndroid Build Coastguard Workerdisplay and has little to do with display-related issues. 22*61046927SAndroid Build Coastguard WorkerEach SoC has its own separate display engine to control the display 23*61046927SAndroid Build Coastguard Workeroutput. To display the contents rendered by the Mali GPU to a screen, a 24*61046927SAndroid Build Coastguard Workerseparate `display driver <#display-drivers>`__ is also required, which 25*61046927SAndroid Build Coastguard Workeris able to share buffers with the GPU. In Mesa, this is handled by 26*61046927SAndroid Build Coastguard Worker``kmsro``. 27*61046927SAndroid Build Coastguard Worker 28*61046927SAndroid Build Coastguard WorkerSupported APIs 29*61046927SAndroid Build Coastguard Worker-------------- 30*61046927SAndroid Build Coastguard Worker 31*61046927SAndroid Build Coastguard WorkerLima mainly targets **OpenGL ES 2.0**, as well as **OpenGL 2.1** 32*61046927SAndroid Build Coastguard Worker(desktop) to some extent. 33*61046927SAndroid Build Coastguard Worker 34*61046927SAndroid Build Coastguard WorkerThe OpenGL (desktop) implementation is enabled by Mesa and Gallium, 35*61046927SAndroid Build Coastguard Workerwhere it is possible to reuse the same implementation backend. That way, 36*61046927SAndroid Build Coastguard Workerit is possible to support running a majority of Linux desktop 37*61046927SAndroid Build Coastguard Workerapplications designed for OpenGL. It is not possible to fully support 38*61046927SAndroid Build Coastguard WorkerOpenGL (desktop), though, due to hardware limitations. Some (but not 39*61046927SAndroid Build Coastguard Workerall) features of OpenGL 2.1 that are not supported directly in hardware 40*61046927SAndroid Build Coastguard Workerare enabled by internal shader transformations. 41*61046927SAndroid Build Coastguard WorkerCheck the `known hardware limitations <#known-hardware-limitations>`__ 42*61046927SAndroid Build Coastguard Workerlist for additional information. 43*61046927SAndroid Build Coastguard Worker 44*61046927SAndroid Build Coastguard Worker**OpenGL ES 1.1** and **OpenGL 1.x** are also provided by Mesa and 45*61046927SAndroid Build Coastguard Workersimilarly supported to some extent in Lima. 46*61046927SAndroid Build Coastguard Worker 47*61046927SAndroid Build Coastguard WorkerDisplay drivers 48*61046927SAndroid Build Coastguard Worker--------------- 49*61046927SAndroid Build Coastguard Worker 50*61046927SAndroid Build Coastguard WorkerThese are some display drivers that have been tested with Lima: 51*61046927SAndroid Build Coastguard Worker 52*61046927SAndroid Build Coastguard Worker- Allwinner: ``sun4i-drm`` 53*61046927SAndroid Build Coastguard Worker- Amlogic: ``meson`` 54*61046927SAndroid Build Coastguard Worker- Ericsson MCDE: ``mcde`` 55*61046927SAndroid Build Coastguard Worker- Exynos: ``exynos`` 56*61046927SAndroid Build Coastguard Worker- Rockchip: ``rockchip`` 57*61046927SAndroid Build Coastguard Worker- Tiny DRM: ``tinydrm`` 58*61046927SAndroid Build Coastguard Worker- Xilinx ZynqMP: ``zynqmp-dpsub`` 59*61046927SAndroid Build Coastguard Worker 60*61046927SAndroid Build Coastguard WorkerEnvironment variables 61*61046927SAndroid Build Coastguard Worker--------------------- 62*61046927SAndroid Build Coastguard Worker 63*61046927SAndroid Build Coastguard WorkerThese are some Lima-specific environment variables that may aid in 64*61046927SAndroid Build Coastguard Workerdebugging. None of this is required for normal use. 65*61046927SAndroid Build Coastguard Worker 66*61046927SAndroid Build Coastguard Worker.. envvar:: LIMA_DEBUG 67*61046927SAndroid Build Coastguard Worker 68*61046927SAndroid Build Coastguard Worker accepts the following comma-separated list of flags: 69*61046927SAndroid Build Coastguard Worker 70*61046927SAndroid Build Coastguard Worker ``bocache`` 71*61046927SAndroid Build Coastguard Worker print debug info for BO cache 72*61046927SAndroid Build Coastguard Worker ``diskcache`` 73*61046927SAndroid Build Coastguard Worker print debug info for shader disk cache 74*61046927SAndroid Build Coastguard Worker ``dump`` 75*61046927SAndroid Build Coastguard Worker dump GPU command stream to ``$PWD/lima.dump`` 76*61046927SAndroid Build Coastguard Worker ``gp`` 77*61046927SAndroid Build Coastguard Worker print GP shader compiler result of each stage 78*61046927SAndroid Build Coastguard Worker ``noblit`` 79*61046927SAndroid Build Coastguard Worker use generic u_blitter instead of Lima-specific 80*61046927SAndroid Build Coastguard Worker ``nobocache`` 81*61046927SAndroid Build Coastguard Worker disable BO cache 82*61046927SAndroid Build Coastguard Worker ``nogrowheap`` 83*61046927SAndroid Build Coastguard Worker disable growable heap buffer 84*61046927SAndroid Build Coastguard Worker ``notiling`` 85*61046927SAndroid Build Coastguard Worker don’t use tiled buffers 86*61046927SAndroid Build Coastguard Worker ``pp`` 87*61046927SAndroid Build Coastguard Worker print PP shader compiler result of each stage 88*61046927SAndroid Build Coastguard Worker ``precompile`` 89*61046927SAndroid Build Coastguard Worker precompile shaders for shader-db 90*61046927SAndroid Build Coastguard Worker ``shaderdb`` 91*61046927SAndroid Build Coastguard Worker print shader information for shaderdb 92*61046927SAndroid Build Coastguard Worker ``singlejob`` 93*61046927SAndroid Build Coastguard Worker disable multi job optimization 94*61046927SAndroid Build Coastguard Worker 95*61046927SAndroid Build Coastguard Worker 96*61046927SAndroid Build Coastguard Worker.. envvar:: LIMA_CTX_NUM_PLB 97*61046927SAndroid Build Coastguard Worker 98*61046927SAndroid Build Coastguard Worker set number of PLB per context (used for development purposes) 99*61046927SAndroid Build Coastguard Worker 100*61046927SAndroid Build Coastguard Worker.. envvar:: LIMA_PLB_MAX_BLK 101*61046927SAndroid Build Coastguard Worker 102*61046927SAndroid Build Coastguard Worker set PLB max block (used for development purposes) 103*61046927SAndroid Build Coastguard Worker 104*61046927SAndroid Build Coastguard Worker.. envvar:: LIMA_PPIR_FORCE_SPILLING 105*61046927SAndroid Build Coastguard Worker 106*61046927SAndroid Build Coastguard Worker force spilling of variables in PPIR (used for development purposes) 107*61046927SAndroid Build Coastguard Worker 108*61046927SAndroid Build Coastguard Worker.. envvar:: LIMA_PLB_PP_STREAM_CACHE_SIZE 109*61046927SAndroid Build Coastguard Worker 110*61046927SAndroid Build Coastguard Worker set PP stream cache size (used for development purposes) 111*61046927SAndroid Build Coastguard Worker 112*61046927SAndroid Build Coastguard WorkerKnown hardware limitations 113*61046927SAndroid Build Coastguard Worker-------------------------- 114*61046927SAndroid Build Coastguard Worker 115*61046927SAndroid Build Coastguard WorkerHere are some known caveats in OpenGL support: 116*61046927SAndroid Build Coastguard Worker 117*61046927SAndroid Build Coastguard Worker- ``glPolygonMode()`` with ``GL_LINE`` is not supported. This is not part of 118*61046927SAndroid Build Coastguard Worker OpenGL ES 2.0 and so it is not possible to reverse engineer. 119*61046927SAndroid Build Coastguard Worker 120*61046927SAndroid Build Coastguard Worker- Precision limitations in fragment shaders: 121*61046927SAndroid Build Coastguard Worker 122*61046927SAndroid Build Coastguard Worker - In general, only 123*61046927SAndroid Build Coastguard Worker `FP16 <https://en.wikipedia.org/wiki/Half-precision_floating-point_format>`__ 124*61046927SAndroid Build Coastguard Worker precision is supported in fragment shaders. Specifying ``highp`` 125*61046927SAndroid Build Coastguard Worker will have no effect. 126*61046927SAndroid Build Coastguard Worker - Integers are not supported in hardware, they are lowered down to 127*61046927SAndroid Build Coastguard Worker FP16. 128*61046927SAndroid Build Coastguard Worker - There is a higher precision (FP24) path for texture lookups, if 129*61046927SAndroid Build Coastguard Worker there is *no* math performed on texture coordinates obtained from 130*61046927SAndroid Build Coastguard Worker varyings. If there is *any* calculation done in the texture 131*61046927SAndroid Build Coastguard Worker coordinates, the texture coordinates will fall back to FP16 and 132*61046927SAndroid Build Coastguard Worker that may affect the quality of the texture lookup. 133*61046927SAndroid Build Coastguard Worker 134*61046927SAndroid Build Coastguard Worker- Lima supports FP16 textures in OpenGL ES (through 135*61046927SAndroid Build Coastguard Worker :ext:`GL_OES_texture_half_float<GL_OES_texture_float>`), but not in OpenGL. 136*61046927SAndroid Build Coastguard Worker This is because it would require :ext:`GL_ARB_texture_float` which would 137*61046927SAndroid Build Coastguard Worker also require 32-bit float textures, that the Mali-4xx does not support. 138*61046927SAndroid Build Coastguard Worker- Rendering to FP16 is possible, but the result is clamped to the 139*61046927SAndroid Build Coastguard Worker [0.0,1.0] range. 140*61046927SAndroid Build Coastguard Worker 141*61046927SAndroid Build Coastguard WorkerBug Reporting 142*61046927SAndroid Build Coastguard Worker------------- 143*61046927SAndroid Build Coastguard Worker 144*61046927SAndroid Build Coastguard WorkerPlease try the latest Mesa development branch or at least Mesa latest 145*61046927SAndroid Build Coastguard Workerrelease before reporting issues. Please review the 146*61046927SAndroid Build Coastguard Worker:doc:`Mesa bug report guidelines <../bugs>`. 147*61046927SAndroid Build Coastguard Worker 148*61046927SAndroid Build Coastguard WorkerIssues should be filed as a `Mesa issue`_. 149*61046927SAndroid Build Coastguard WorkerLima tags will be added accordingly by the developers. 150*61046927SAndroid Build Coastguard Worker 151*61046927SAndroid Build Coastguard Worker`apitrace <https://github.com/apitrace/apitrace>`__ traces are very 152*61046927SAndroid Build Coastguard Workerwelcome in issue reports and significantly ease the debug and fix 153*61046927SAndroid Build Coastguard Workerprocess. 154*61046927SAndroid Build Coastguard Worker 155*61046927SAndroid Build Coastguard WorkerFAQ 156*61046927SAndroid Build Coastguard Worker--- 157*61046927SAndroid Build Coastguard Worker 158*61046927SAndroid Build Coastguard WorkerWill Lima support OpenGL 3.x+ / OpenGL ES 3.x+ / OpenCL / Vulkan ? 159*61046927SAndroid Build Coastguard Worker~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 160*61046927SAndroid Build Coastguard Worker 161*61046927SAndroid Build Coastguard Worker**No.** The Mali-4xx was designed to implement OpenGL ES 2.0 and OpenGL 162*61046927SAndroid Build Coastguard WorkerES 1.1. The hardware lacks features to properly implement some features 163*61046927SAndroid Build Coastguard Workerrequired by newer APIs. 164*61046927SAndroid Build Coastguard Worker 165*61046927SAndroid Build Coastguard WorkerHow complete is Lima? Is reverse engineering complete? 166*61046927SAndroid Build Coastguard Worker~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 167*61046927SAndroid Build Coastguard Worker 168*61046927SAndroid Build Coastguard WorkerAt the time of writing, with local runs of the 169*61046927SAndroid Build Coastguard Worker`OpenGL ES Conformance Tests <https://github.com/KhronosGroup/VK-GL-CTS/>`__ 170*61046927SAndroid Build Coastguard Worker(dEQP) for OpenGL ES 2.0, Lima reports **97%** pass rate. 171*61046927SAndroid Build Coastguard WorkerThis coverage is on par with coverage provided by the ARM Mali driver. 172*61046927SAndroid Build Coastguard WorkerSome tests that pass with Lima fail on Mali and vice versa. Some of 173*61046927SAndroid Build Coastguard Workerthese issues are related to precision limitations which likely don’t 174*61046927SAndroid Build Coastguard Workeraffect end user applications. 175*61046927SAndroid Build Coastguard Worker 176*61046927SAndroid Build Coastguard WorkerThe work being done in Lima at this stage is largely decoupled from 177*61046927SAndroid Build Coastguard Workerreverse engineering. Reverse engineering is still useful sometimes to 178*61046927SAndroid Build Coastguard Workerobtain details on how to implement low level features (e.g. how to 179*61046927SAndroid Build Coastguard Workerenable some missing legacy OpenGL ES 1.1 feature to support an 180*61046927SAndroid Build Coastguard Workeradditional application), but with the current information Lima is 181*61046927SAndroid Build Coastguard Workeralready able to cover most of OpenGL ES 2.0. 182*61046927SAndroid Build Coastguard Worker 183*61046927SAndroid Build Coastguard WorkerMuch of the work to be done is related to plumbing features within the 184*61046927SAndroid Build Coastguard Workerframeworks provided by Mesa, fixing bugs (e.g. artifacts or crashes in 185*61046927SAndroid Build Coastguard Workerspecific applications), shader compiler improvements, which are not 186*61046927SAndroid Build Coastguard Workernecessarily related to new hardware bits and not related at all to the 187*61046927SAndroid Build Coastguard WorkerMali driver. 188*61046927SAndroid Build Coastguard Worker 189*61046927SAndroid Build Coastguard WorkerWhen will Feature XYZ be supported? Is there a roadmap for features implementation? 190*61046927SAndroid Build Coastguard Worker~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 191*61046927SAndroid Build Coastguard Worker 192*61046927SAndroid Build Coastguard WorkerThere is no established roadmap for features implementation. 193*61046927SAndroid Build Coastguard WorkerDevelopment is driven by improving coverage in existing OpenGL test 194*61046927SAndroid Build Coastguard Workerframeworks, adding support to features that enable more existing Linux 195*61046927SAndroid Build Coastguard Workerapplications, and fixing issues reported by users in their applications. 196*61046927SAndroid Build Coastguard WorkerDevelopment is fully based on community contributions. 197*61046927SAndroid Build Coastguard Worker 198*61046927SAndroid Build Coastguard WorkerIf some desired feature is missing or there is an OpenGL-related bug 199*61046927SAndroid Build Coastguard Workerwhile running some application, please do file a `Mesa issue`_. 200*61046927SAndroid Build Coastguard WorkerIssues that are not reproduced by an existing test suite or common 201*61046927SAndroid Build Coastguard Workerapplication and are also not reported by users are just likely not going 202*61046927SAndroid Build Coastguard Workerto be noticed and fixed. 203*61046927SAndroid Build Coastguard Worker 204*61046927SAndroid Build Coastguard WorkerHow does Lima compare to Mali (blob)? How is performance? 205*61046927SAndroid Build Coastguard Worker~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 206*61046927SAndroid Build Coastguard Worker 207*61046927SAndroid Build Coastguard WorkerBy the fact that Lima is a fully open source driver and leverages a lot 208*61046927SAndroid Build Coastguard Workerof Mesa and Linux functionality, feature-wise Lima is able to support 209*61046927SAndroid Build Coastguard Workermany things that Mali does not. As already mentioned, supporting OpenGL 210*61046927SAndroid Build Coastguard Worker2.1 is one of them. This allows Lima to support many more Linux desktop 211*61046927SAndroid Build Coastguard Workerapplications out of the box. Through the abstractions implemented in 212*61046927SAndroid Build Coastguard WorkerMesa, Lima supports a number of OpenGL and OpenGL ES extensions that 213*61046927SAndroid Build Coastguard Workeroriginally the Mali did not support. Lima is also aligned with the 214*61046927SAndroid Build Coastguard Workercurrent status of the Linux graphics stack and is therefore able to 215*61046927SAndroid Build Coastguard Workerleverage modern features (such as zero copy pipelines) much more 216*61046927SAndroid Build Coastguard Workerseamlessly. Finally, Lima continues to gain improvements as the Linux 217*61046927SAndroid Build Coastguard Workergraphics ecosystem evolves. 218*61046927SAndroid Build Coastguard Worker 219*61046927SAndroid Build Coastguard WorkerThe entire software stack of the Mali driver and the software stack with 220*61046927SAndroid Build Coastguard WorkerLima are significantly different which makes it hard to offer a single 221*61046927SAndroid Build Coastguard Workernumber comparison for performance of the GPU driver. The difference 222*61046927SAndroid Build Coastguard Workerreally depends on the type of application. Keep in mind that hardware 223*61046927SAndroid Build Coastguard Workercontaining a Mali-4xx is usually quite limited for modern standards and 224*61046927SAndroid Build Coastguard Workerit might not perform as well as hoped. For example: while it is now 225*61046927SAndroid Build Coastguard Workertechnically possible to run full GL modern desktop environments at 1080p 226*61046927SAndroid Build Coastguard Worker(which might not have been even possible before due to limited GL 227*61046927SAndroid Build Coastguard Workersupport), that might not be very performant due to memory bandwidth, CPU 228*61046927SAndroid Build Coastguard Workerand GPU limitations of the SoC with a Mali-4xx. 229*61046927SAndroid Build Coastguard Worker 230*61046927SAndroid Build Coastguard WorkerOverall performance with Lima is good for many applications where the 231*61046927SAndroid Build Coastguard WorkerMali-4xx would be a suitable target GPU. 232*61046927SAndroid Build Coastguard WorkerBut bottom line for a performance evaluation, you need to try with your 233*61046927SAndroid Build Coastguard Workertarget application. If performance with Lima does not seem right in some 234*61046927SAndroid Build Coastguard Workerapplication where it should reasonably perform better, please file a 235*61046927SAndroid Build Coastguard Worker`Mesa issue`_ (in which case some indication on why Lima in particular 236*61046927SAndroid Build Coastguard Workerseems to be the bottleneck would also be helpful). 237*61046927SAndroid Build Coastguard Worker 238*61046927SAndroid Build Coastguard WorkerCommunication channels 239*61046927SAndroid Build Coastguard Worker---------------------- 240*61046927SAndroid Build Coastguard Worker 241*61046927SAndroid Build Coastguard Worker- `#lima channel <irc://irc.oftc.net/lima>`__ on `irc.oftc.net <https://webchat.oftc.net/>`__ 242*61046927SAndroid Build Coastguard Worker- `lima mailing list <https://lists.freedesktop.org/mailman/listinfo/lima>`__ 243*61046927SAndroid Build Coastguard Worker- `dri-devel mailing list <https://lists.freedesktop.org/mailman/listinfo/dri-devel>`__ 244*61046927SAndroid Build Coastguard Worker 245*61046927SAndroid Build Coastguard WorkerDump tool 246*61046927SAndroid Build Coastguard Worker--------- 247*61046927SAndroid Build Coastguard Worker 248*61046927SAndroid Build Coastguard WorkerA tool to dump the runtime of the closed source Mali driver for 249*61046927SAndroid Build Coastguard Workerreverse engineering is available at: 250*61046927SAndroid Build Coastguard Workerhttps://gitlab.freedesktop.org/lima/mali-syscall-tracker 251*61046927SAndroid Build Coastguard Worker 252*61046927SAndroid Build Coastguard WorkerReference 253*61046927SAndroid Build Coastguard Worker--------- 254*61046927SAndroid Build Coastguard Worker 255*61046927SAndroid Build Coastguard WorkerLuc Verhaegen’s original Lima site: 256*61046927SAndroid Build Coastguard Workerhttps://web.archive.org/web/20180101212947/http://limadriver.org/ 257*61046927SAndroid Build Coastguard Worker 258*61046927SAndroid Build Coastguard Worker.. _Mesa issue: https://gitlab.freedesktop.org/mesa/mesa/-/issues?label_name%5B%5D=lima 259