Skip to content


What is Panfrost?

The Panfrost is open source project for Mali Midgard and Bifrost GPUs. It focused on graphics workload to support OpenGL ES 2.0 and 3.0 but OpenCL yet. The Panfrost is now involved in upstream Mesa and works with a mainline Linux kernel. It has took a huge amount of reverse-engineering effort.

                                    Panfrost Backend
                Panfrost driver     NIR
                Gallium             Compiler
User-space      libdrm
Kernel          Kernel drm

Panfrost in the user space

The data structure passed to the drm in the kernel space looks like as below.

struct drm_panfrost_submit {

    /** Address to GPU mapping of job descriptor */
    __u64 jc;

    /** An optional array of sync objects to wait on before starting this job. */
    __u64 in_syncs;

    /** Number of sync objects to wait on before starting this job. */
    __u32 in_sync_count;

    /** An optional sync object to place the completion fence in. */
    __u32 out_sync;

    /** Pointer to a u32 array of the BOs that are referenced by the job. */
    __u64 bo_handles;

    /** Number of BO handles passed in (size is that times 4). */
    __u32 bo_handle_count;

    /** A combination of PANFROST_JD_REQ_* */
    __u32 requirements;


They XMLify some data types and variable. Check out midgard.xml

commit 4b7056b8c8a384819a00908b76be8bf4d407cdb6 (HEAD)
Author: Alyssa Rosenzweig <>
Date:   Wed Aug 5 18:40:44 2020 -0400

    panfrost: XMLify job_type

    Signed-off-by: Alyssa Rosenzweig <>
    Reviewed-by: Tomeu Vizoso <>
    Part-of: <>

Some relevant functions to the job chain

  • panfrost_add_job(): generates, uploads, and queues a new job.
  • panfrost_launch_grid(): the compute equivalent of dar_vbo. It construct the COMPUTE job and some of its payload [COMPUTE_JOB]
  • panfrost_draw_emit_vertex: generate compute job for vertex shader
  • pandecode_jc() : Entrypoint to start taciing - decode the jc if there is fault.
  • pan_section_pack(): pack the raw data to the job chain. Checkout

Call stack

panfrost_flush -> panfrost_flush_all_batches -> panfrost_batch_submit -> panfrost_batch_submit_jobs -> panfrost_batch_submit_ioctl

Compute job

<!-- Compute job also covers vertex and geometry operations -->
<aggregate name="Compute Job">
  <section name="Header" offset="0" type="Job Header"/>
  <section name="Invocation" offset="32" type="Invocation"/>
  <section name="Parameters" offset="40" type="Compute Job Parameters"/>
  <section name="Draw" offset="64" type="Draw"/>
  <section name="Draw Padding" offset="184" type="Draw Padding"/>

Panfrost on Odroid C4

Feb 2021

Install Armbian Focal (kernel 5.9). Then switch to 3rd party apt source: ppa:oibaf/graphics-drivers

(Note: installing desktop takes long time. Instead, directly try quake3 + xwindow first)