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