| 1 |
drm-shim |
| 2 |
======== |
| 3 |
|
| 4 |
Panfrost implements ``drm-shim``, stubbing out the Panfrost kernel interface. |
| 5 |
Use cases for this functionality include: |
| 6 |
|
| 7 |
- Future hardware bring up |
| 8 |
- Running shader-db on non-Mali workstations |
| 9 |
- Reproducing compiler (and some driver) bugs without Mali hardware |
| 10 |
|
| 11 |
Although Mali hardware is usually paired with an Arm CPU, Panfrost is portable C |
| 12 |
code and should work on any Linux machine. In particular, you can test the |
| 13 |
compiler on shader-db on an Intel desktop. |
| 14 |
|
| 15 |
To build Mesa with Panfrost drm-shim, configure Meson with |
| 16 |
``-Dgallium-drivers=panfrost`` and ``-Dtools=drm-shim``. See the above |
| 17 |
building section for a full invocation. The drm-shim binary will be built to |
| 18 |
``build/src/panfrost/drm-shim/libpanfrost_noop_drm_shim.so``. |
| 19 |
|
| 20 |
To use, set the ``LD_PRELOAD`` environment variable to the drm-shim binary. |
| 21 |
|
| 22 |
By default, drm-shim mocks a Mali-G52 system. To select a specific Mali GPU, |
| 23 |
set the ``PAN_GPU_ID`` environment variable to the desired GPU ID: |
| 24 |
|
| 25 |
========= ============= ======= |
| 26 |
Product Architecture GPU ID |
| 27 |
========= ============= ======= |
| 28 |
Mali-T720 Midgard (v4) 720 |
| 29 |
Mali-T860 Midgard (v5) 860 |
| 30 |
Mali-G72 Bifrost (v6) 6221 |
| 31 |
Mali-G52 Bifrost (v7) 7212 |
| 32 |
Mali-G57 Valhall (v9) 9093 |
| 33 |
Mali-G610 Valhall (v10) a867 |
| 34 |
========= ============= ======= |
| 35 |
|
| 36 |
Additional GPU IDs are enumerated in the ``panfrost_model_list`` list in |
| 37 |
``src/panfrost/lib/pan_props.c``. |
| 38 |
|
| 39 |
As an example: assuming Mesa is installed to a local path ``~/lib`` and Mesa's |
| 40 |
build directory is ``~/mesa/build``, a shader can be compiled for Mali-G52 as: |
| 41 |
|
| 42 |
.. code-block:: sh |
| 43 |
|
| 44 |
~/shader-db$ BIFROST_MESA_DEBUG=shaders \ |
| 45 |
LD_PRELOAD=~/mesa/build/src/panfrost/drm-shim/libpanfrost_noop_drm_shim.so \ |
| 46 |
PAN_GPU_ID=7212 \ |
| 47 |
./run shaders/glmark/1-1.shader_test |
| 48 |
|
| 49 |
The same shader can be compiled for Mali-T720 as: |
| 50 |
|
| 51 |
.. code-block:: sh |
| 52 |
|
| 53 |
~/shader-db$ MIDGARD_MESA_DEBUG=shaders \ |
| 54 |
LD_PRELOAD=~/mesa/build/src/panfrost/drm-shim/libpanfrost_noop_drm_shim.so \ |
| 55 |
PAN_GPU_ID=720 \ |
| 56 |
./run shaders/glmark/1-1.shader_test |
| 57 |
|
| 58 |
These examples set the compilers' ``shaders`` debug flags to dump the optimized |
| 59 |
NIR, backend IR after instruction selection, backend IR after register |
| 60 |
allocation and scheduling, and a disassembly of the final compiled binary. |
| 61 |
|
| 62 |
As another example, this invocation runs a single dEQP test "on" Mali-G52, |
| 63 |
pretty-printing GPU data structures and disassembling all shaders |
| 64 |
(``PAN_MESA_DEBUG=trace``) as well as dumping raw GPU memory |
| 65 |
(``PAN_MESA_DEBUG=dump``). The ``EGL_PLATFORM=surfaceless`` environment variable |
| 66 |
and various flags to dEQP mimic the surfaceless environment that our |
| 67 |
continuous integration (CI) uses. This eliminates window system dependencies, |
| 68 |
although it requires a specially built CTS: |
| 69 |
|
| 70 |
.. code-block:: sh |
| 71 |
|
| 72 |
~/VK-GL-CTS/build/external/openglcts/modules$ PAN_MESA_DEBUG=trace,dump \ |
| 73 |
LD_PRELOAD=~/mesa/build/src/panfrost/drm-shim/libpanfrost_noop_drm_shim.so \ |
| 74 |
PAN_GPU_ID=7212 EGL_PLATFORM=surfaceless \ |
| 75 |
./glcts --deqp-surface-type=pbuffer \ |
| 76 |
--deqp-gl-config-name=rgba8888d24s8ms0 --deqp-surface-width=256 \ |
| 77 |
--deqp-surface-height=256 -n \ |
| 78 |
dEQP-GLES31.functional.shaders.builtin_functions.common.abs.float_highp_compute |