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