1bf215546Sopenharmony_ciPanfrost 2bf215546Sopenharmony_ci======== 3bf215546Sopenharmony_ci 4bf215546Sopenharmony_ciThe Panfrost driver stack includes an OpenGL ES implementation for Arm Mali 5bf215546Sopenharmony_ciGPUs based on the Midgard and Bifrost microarchitectures. It is **conformant** 6bf215546Sopenharmony_cion Mali-G52 and Mali-G57 but **non-conformant** on other GPUs. The following 7bf215546Sopenharmony_cihardware is currently supported: 8bf215546Sopenharmony_ci 9bf215546Sopenharmony_ci========= ============ ============ ======= 10bf215546Sopenharmony_ciProduct Architecture OpenGL ES OpenGL 11bf215546Sopenharmony_ci========= ============ ============ ======= 12bf215546Sopenharmony_ciMali T720 Midgard (v4) 2.0 2.1 13bf215546Sopenharmony_ciMali T760 Midgard (v5) 3.1 3.1 14bf215546Sopenharmony_ciMali T820 Midgard (v5) 3.1 3.1 15bf215546Sopenharmony_ciMali T830 Midgard (v5) 3.1 3.1 16bf215546Sopenharmony_ciMali T860 Midgard (v5) 3.1 3.1 17bf215546Sopenharmony_ciMali T880 Midgard (v5) 3.1 3.1 18bf215546Sopenharmony_ciMali G72 Bifrost (v6) 3.1 3.1 19bf215546Sopenharmony_ciMali G31 Bifrost (v7) 3.1 3.1 20bf215546Sopenharmony_ciMali G51 Bifrost (v7) 3.1 3.1 21bf215546Sopenharmony_ciMali G52 Bifrost (v7) 3.1 3.1 22bf215546Sopenharmony_ciMali G76 Bifrost (v7) 3.1 3.1 23bf215546Sopenharmony_ciMali G57 Valhall (v9) 3.1 3.1 24bf215546Sopenharmony_ci========= ============ ============ ======= 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ciOther Midgard and Bifrost chips (T604, T628, G71) are not yet supported. 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ciOlder Mali chips based on the Utgard architecture (Mali 400, Mali 450) are 29bf215546Sopenharmony_cisupported in the Lima driver, not Panfrost. Lima is also available in Mesa. 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ciOther graphics APIs (Vulkan, OpenCL) are not supported at this time. 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ciBuilding 34bf215546Sopenharmony_ci-------- 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ciPanfrost's OpenGL support is a Gallium driver. Since Mali GPUs are 3D-only and 37bf215546Sopenharmony_cido not include a display controller, Mesa uses kmsro to support display 38bf215546Sopenharmony_cicontrollers paired with Mali GPUs. If your board with a Panfrost supported GPU 39bf215546Sopenharmony_cihas a display controller with mainline Linux support not supported by kmsro, 40bf215546Sopenharmony_ciit's easy to add support, see the commit ``cff7de4bb597e9`` as an example. 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_ciLLVM is *not* required by Panfrost's compilers. LLVM support in Mesa can 43bf215546Sopenharmony_cisafely be disabled for most OpenGL ES users with Panfrost. 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ciBuild like ``meson . build/ -Ddri-drivers= -Dvulkan-drivers= 46bf215546Sopenharmony_ci-Dgallium-drivers=panfrost -Dllvm=disabled`` for a build directory 47bf215546Sopenharmony_ci``build``. 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ciFor general information on building Mesa, read :doc:`the install documentation 50bf215546Sopenharmony_ci<../install>`. 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ciChat 53bf215546Sopenharmony_ci---- 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ciPanfrost developers and users hang out on IRC at ``#panfrost`` on OFTC. Note 56bf215546Sopenharmony_cithat registering and authenticating with `NickServ` is required to prevent 57bf215546Sopenharmony_cispam. `Join the chat. <https://webchat.oftc.net/?channels=#panfrost>`_ 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_cidrm-shim 60bf215546Sopenharmony_ci-------- 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ciPanfrost implements ``drm-shim``, stubbing out the Panfrost kernel interface. 63bf215546Sopenharmony_ciUse cases for this functionality include: 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci- Future hardware bring up 66bf215546Sopenharmony_ci- Running shader-db on non-Mali workstations 67bf215546Sopenharmony_ci- Reproducing compiler (and some driver) bugs without Mali hardware 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ciAlthough Mali hardware is usually paired with an Arm CPU, Panfrost is portable C 70bf215546Sopenharmony_cicode and should work on any Linux machine. In particular, you can test the 71bf215546Sopenharmony_cicompiler on shader-db on an Intel desktop. 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_ciTo build Mesa with Panfrost drm-shim, configure meson with 74bf215546Sopenharmony_ci``-Dgallium-drivers=panfrost`` and ``-Dtools=drm-shim``. See the above 75bf215546Sopenharmony_cibuilding section for a full invocation. The drm-shim binary will be built to 76bf215546Sopenharmony_ci``build/src/panfrost/drm-shim/libpanfrost_noop_drm_shim.so``. 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ciTo use, set the ``LD_PRELOAD`` environment variable to the drm-shim binary. It 79bf215546Sopenharmony_cimay also be necessary to set ``LIBGL_DRIVERS_PATH`` to the location where Mesa 80bf215546Sopenharmony_ciwas installed. 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ciBy default, drm-shim mocks a Mali-G52 system. To select a specific Mali GPU, 83bf215546Sopenharmony_ciset the ``PAN_GPU_ID`` environment variable to the desired GPU ID: 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ci========= ============ ======= 86bf215546Sopenharmony_ciProduct Architecture GPU ID 87bf215546Sopenharmony_ci========= ============ ======= 88bf215546Sopenharmony_ciMali-T720 Midgard (v4) 720 89bf215546Sopenharmony_ciMali-T860 Midgard (v5) 860 90bf215546Sopenharmony_ciMali-G72 Bifrost (v6) 6221 91bf215546Sopenharmony_ciMali-G52 Bifrost (v7) 7212 92bf215546Sopenharmony_ciMali-G57 Valhall (v9) 9093 93bf215546Sopenharmony_ci========= ============ ======= 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ciAdditional GPU IDs are enumerated in the ``panfrost_model_list`` list in 96bf215546Sopenharmony_ci``src/panfrost/lib/pan_props.c``. 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ciAs an example: assuming Mesa is installed to a local path ``~/lib`` and Mesa's 99bf215546Sopenharmony_cibuild directory is ``~/mesa/build``, a shader can be compiled for Mali-G52 as:: 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_ci ~/shader-db$ BIFROST_MESA_DEBUG=shaders LIBGL_DRIVERS_PATH=~/lib/dri/ LD_PRELOAD=~/mesa/build/src/panfrost/drm-shim/libpanfrost_noop_drm_shim.so PAN_GPU_ID=7212 ./run shaders/glmark/1-1.shader_test 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ciThe same shader can be compiled for Mali-T720 as:: 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_ci ~/shader-db$ MIDGARD_MESA_DEBUG=shaders LIBGL_DRIVERS_PATH=~/lib/dri/ LD_PRELOAD=~/mesa/build/src/panfrost/drm-shim/libpanfrost_noop_drm_shim.so PAN_GPU_ID=720 ./run shaders/glmark/1-1.shader_test 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_ciThese examples set the compilers' ``shaders`` debug flags to dump the optimized 108bf215546Sopenharmony_ciNIR, backend IR after instruction selection, backend IR after register 109bf215546Sopenharmony_ciallocation and scheduling, and a disassembly of the final compiled binary. 110bf215546Sopenharmony_ci 111bf215546Sopenharmony_ciAs another example, this invocation runs a single dEQP test "on" Mali-G52, 112bf215546Sopenharmony_cipretty-printing GPU data structures and disassembling all shaders 113bf215546Sopenharmony_ci(``PAN_MESA_DEBUG=trace``) as well as dumping raw GPU memory 114bf215546Sopenharmony_ci(``PAN_MESA_DEBUG=dump``). The ``EGL_PLATFORM=surfaceless`` environment variable 115bf215546Sopenharmony_ciand various flags to dEQP mimic the surfaceless environment that our 116bf215546Sopenharmony_cicontinuous integration (CI) uses. This eliminates window system dependencies, 117bf215546Sopenharmony_cialthough it requires a specially built CTS:: 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ci ~/VK-GL-CTS/build/external/openglcts/modules$ PAN_MESA_DEBUG=trace,dump LIBGL_DRIVERS_PATH=~/lib/dri/ LD_PRELOAD=~/mesa/build/src/panfrost/drm-shim/libpanfrost_noop_drm_shim.so PAN_GPU_ID=7212 EGL_PLATFORM=surfaceless ./glcts --deqp-surface-type=pbuffer --deqp-gl-config-name=rgba8888d24s8ms0 --deqp-surface-width=256 --deqp-surface-height=256 -n dEQP-GLES31.functional.shaders.builtin_functions.common.abs.float_highp_compute 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ciU-interleaved tiling 122bf215546Sopenharmony_ci--------------------- 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_ciPanfrost supports u-interleaved tiling. U-interleaved tiling is 125bf215546Sopenharmony_ciindicated by the ``DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED`` modifier. 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_ciThe tiling reorders whole pixels (blocks). It does not compress or modify the 128bf215546Sopenharmony_cipixels themselves, so it can be used for any image format. Internally, images 129bf215546Sopenharmony_ciare divided into tiles. Tiles occur in source order, but pixels (blocks) within 130bf215546Sopenharmony_cieach tile are reordered according to a space-filling curve. 131bf215546Sopenharmony_ci 132bf215546Sopenharmony_ciFor regular formats, 16x16 tiles are used. This harmonizes with the default tile 133bf215546Sopenharmony_cisize for binning and CRCs (transaction elimination). It also means a single line 134bf215546Sopenharmony_ci(16 pixels) at 4 bytes per pixel equals a single 64-byte cache line. 135bf215546Sopenharmony_ci 136bf215546Sopenharmony_ciFor formats that are already block compressed (S3TC, RGTC, etc), 4x4 tiles are 137bf215546Sopenharmony_ciused, where entire blocks are reorder. Most of these formats compress 4x4 138bf215546Sopenharmony_ciblocks, so this gives an effective 16x16 tiling. This justifies the tile size 139bf215546Sopenharmony_ciintuitively, though it's not a rule: ASTC may uses larger blocks. 140bf215546Sopenharmony_ci 141bf215546Sopenharmony_ciWithin a tile, the X and Y bits are interleaved (like Morton order), but with a 142bf215546Sopenharmony_citwist: adjacent bit pairs are XORed. The reason to add XORs is not obvious. 143bf215546Sopenharmony_ciVisually, addresses take the form:: 144bf215546Sopenharmony_ci 145bf215546Sopenharmony_ci | y3 | (x3 ^ y3) | y2 | (y2 ^ x2) | y1 | (y1 ^ x1) | y0 | (y0 ^ x0) | 146bf215546Sopenharmony_ci 147bf215546Sopenharmony_ciReference routines to encode/decode u-interleaved images are available in 148bf215546Sopenharmony_ci``src/panfrost/shared/test/test-tiling.cpp``, which documents the space-filling 149bf215546Sopenharmony_cicurve. This reference implementation is used to unit test the optimized 150bf215546Sopenharmony_ciimplementation used in production. The optimized implementation is available in 151bf215546Sopenharmony_ci``src/panfrost/shared/pan_tiling.c``. 152bf215546Sopenharmony_ci 153bf215546Sopenharmony_ciAlthough these routines are part of Panfrost, they are also used by Lima, as Arm 154bf215546Sopenharmony_ciintroduced the format with Utgard. It is the only tiling supported on Utgard. On 155bf215546Sopenharmony_ciMali-T760 and newer, Arm Framebuffer Compression (AFBC) is more efficient and 156bf215546Sopenharmony_cishould be used instead where possible. However, not all formats are 157bf215546Sopenharmony_cicompressible, so u-interleaved tiling remains an important fallback on Panfrost. 158bf215546Sopenharmony_ci 159