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