Skip to content

Draft: intel: Combine INTEL_DEBUG=optimizer in a single file

Caio Oliveira requested to merge cmarcelo/mesa:intel-debug-archive into main

On top of !29114 (merged).

Instead of producing multiple files for the backend optimization steps, produce a single file per Vulkan pipeline that contains information about the Mesa version used, and all the steps, with potential to add more content. The new file can be opened by anything that handles tar files (tar command itself, file manages, editors).

The MR also contains a small tool (need include mda in the list of -Dtools for meson), that can among other things show a sequence of diffs for a shader showing what changed in each optimization pass.

For anv, an archive file is used per pipeline. For Iris, an archive file per shader is created.

The MR itself points into a more general solution that will be able to collect other metadata and NIR shaders. Would be good to know if this is something other drivers may care about.

What I'd like try in a separate MR(s) on top of this one:

  • For Intel: include BRW NIR passes.
  • Improve NIR_PASS and friends to play nice if we have a debug_archiver available.
  • Make a way to provide our debug_archiver to Vulkan Runtime / Gallium when they are applying NIR passes.
  • Command in the tool to export to a git repo. Each "object" (shader representation) becomes a file, and each version is a change that produces a new commit. This allows existing Git tooling. Given amount of work that the mda tool in this MR is already doing, I'm less interested in this particular feature than I was before. I can still do it if there's demand.

Example of use:


Help message:

mda [-f FILENAME] CMD [ARGS...]

Reads *.mda.tar files generated by Mesa drivers, these
files contain debugging information about a pipeline or
a single shader stage.

Without command, all the objects are listed, an object can
be a particular internal shader form or other metadata.
Objects are identified by matching a PATTERN in the form


The two first parts (file and prefix) are optional, so
'CS', 'before@CS', '123/CS' and 'before@123/CS' are all valid.

Objects may have multiple versions, e.g. multiple versions
of a shader stage generated during optimization.  When not
specified, commands use the last version in the archive.
Versions are identified by a number between parenthesis in
the `log` commands output.

By default all *.mda.tar files are read.  To specify a single
file to read use the -f FILENAME flag before the command.


    list                           list all objects
    print       PATTERN [V]        formatted print version V (or last) of an object
    printraw    PATTERN [V]        raw dump of version V (or last) of object
    log         PATTERN            print changes between versions
    logfull     PATTERN            print full contents of all versions
    logsum      PATTERN            print the names of the versions
    diff        PATTERN V1 V2      compare two versions of an object
    diff        PATTERN1 PATTERN2  compare two objects
    info                           print metadata about the archive

The diff program used by mda can be configured by setting
the MDA_DIFF_COMMAND environment variable.  By default it
uses git-diff -- that works even without a git repository:

    MDA_DIFF_COMMAND="git diff --no-index --color-words %s %s | tail -n +4"

When showing SPIR-V files, a disassembler program is used.
It can be configured by setting the MDA_SPIRV_DIS_COMMAND
environment variable.  By default it uses

    MDA_SPIRV_DIS_COMMAND="spirv-dis --color %s"
Old example 2


Old example 1


Edited by Caio Oliveira

Merge request reports