Commit graph

24 commits

Author SHA1 Message Date
Caio Oliveira
d404f5934d intel/mda: Use -W for color words diff and -U for regular unified diff
Also add colors to -Y.  Default continue to be the "color words" now
called -W.  As before, MDA_DIFF_COMMAND environment variable can be
used to set a custom diff command.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39595>
2026-01-28 22:11:11 +00:00
Caio Oliveira
05fc275837 intel/mda: Change the matching logic
Previously the matching logic was designed to match names
like this

```
99993681767ac...32132a.anv.mda.tar/CS/NIR8/046-ssa
```

So up until the first slash of a pattern, a prefix match would be used,
followed by fuzzy matching for the remaining pattern.  This don't
work well when there are subdirectories in the name, so when we see

```
before/99993681767ac...32132a.anv.mda.tar/CS/NIR8/046-ssa
before/91132154353bd...090919.anv.mda.tar/CS/NIR8/046-ssa
after/91132154353bd...090919.anv.mda.tar/CS/NIR8/046-ssa
```

the first entry can't be matched by `before/9999/first` since the fuzzy
match will kick in for the 9999 and if the second entry has four 9s
(which it does here) there would be multiple choices.

In practice the flexibility of fuzzy matching is not really needed
since we've been using consistent small prefixes (like CS, NIR8, BRW,
etc).  The exception is the last part (the object versions, i.e.
"pass names"), where sometimes is convenient to reach by a substring.

The new matching logic is to use prefix match by default, except when
matching the "object version", where substring match is used. In the
example a possible set of the patterns to identify each entry can be
`b/99/ssa`, `b/91/ssa` and `a/91/ssa`.

The patch adds a few tests to the `is_match()` to clarify the behavior.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39506>
2026-01-28 21:56:59 +00:00
Caio Oliveira
b91c576ae7 intel/mda: add difflog command
Compares versions of two objects one by one.  Useful to compare two
shader compilations and find the first pass that changed.

This could already be done by using something like
`diff <(mda log ...) <(mda log ...)` but it is useful enough to become
a builtin.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39420>
2026-01-28 18:00:45 +00:00
Caio Oliveira
375e9d1094 intel/mda: Handle better processing a lot of archives
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Keep only the metadata when initially parsing the files.  Then re-load
the relevant archives again when necessary.

The old code was just keeping everything in memory, which was slow when
looking at a directory containing archives resulted from processing
a large fossil file.

Extra care is taken with `search` commands to ensure we don't keep
unnecessary contents around.  At some point we could reorganize so
find_all is not used here, but for now this should be fine.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38228>
2025-12-13 01:21:08 +00:00
Caio Oliveira
5474e9bfdc intel/mda: Use function to read content of objects
Preparation for a later patch that will make the content be loaded
on-demand.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38228>
2025-12-13 01:21:08 +00:00
Dylan Baker
a6102f7432 intel/mda: Use a vector to track the contents variable
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
I'm not really sure why Coverity doesn't tag the `delete[]` as a
potential leak since it also happens after ASSERT macros, like it did
with the call to `fclose()`.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37744>
2025-10-30 20:03:24 +00:00
Dylan Baker
9509d0d8b8 intel/mda: Use GTEST fixtures to manage File handles
Coverity points out that if the asserts fail, then the file won't be
closed, and therefore wont be deleted. We'd like to avoid littering the
temp directory with useless files.

This uses GTEST's `TEST_F` feature with a custom class to manager the
creation and destruction of the tmpfile.

CID: 1666502
CID: 1666525
CID: 1666579
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37744>
2025-10-30 20:03:24 +00:00
Alyssa Rosenzweig
b824ef83ab util/dynarray: infer type in append
Most of the time, we can infer the type to append in
util_dynarray_append using __typeof__, which is standardized in C23 and
support in Jesse's MSMSVCV. This patch drops the type argument most of
the time, making util_dynarray a little more ergonomic to use.

This is done in four steps.

First, rename util_dynarray_append -> util_dynarray_append_typed

    bash -c "find . -type f -exec sed -i -e 's/util_dynarray_append(/util_dynarray_append_typed(/g' \{} \;"

Then, add a new append that infers the type. This is much more ergonomic
for what you want most of the time.

Next, use type-inferred append as much as possible, via Coccinelle
patch (plus manual fixup):

    @@
    expression dynarray, element;
    type type;
    @@

    -util_dynarray_append_typed(dynarray, type, element);
    +util_dynarray_append(dynarray, element);

Finally, hand fixup cases that Coccinelle missed or incorrectly
translated, of which there were several because we can't used the
untyped append with a literal (since the sizeof won't do what you want).

All four steps are squashed to produce a single patch changing every
util_dynarray_append call site in tree to either drop a type parameter
(if possible) or insert a _typed suffix (if we can't infer). As such,
the final patch is best reviewed by hand even though it was
tool-assisted.

No Long Linguine Meals were involved in the making of this patch.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38038>
2025-10-24 18:32:07 +00:00
Caio Oliveira
6fe5d7b0a4 intel/mda: Allow to specify directories with -f
If you have before/after mda files in separate directories, this make
easier to import them.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37806>
2025-10-23 22:21:14 +00:00
Dylan Baker
38e1a43f53 intel/mda: Fix potential underflow in printing code
The actual chances of this happening seem dubious, but the cleaned up
code seems nice. printf returns a value >= 0 on success, which is the
number of characters it writes a return < 0 means that an error
occurred, and then errno is set. Which negative value doesn't seem to be
specified, but it also seems unlikely that any implementation would
return `-MAX_INT`...

Anyway, this is fixed by converting the generic `print_repeated` to a
`print_separator` that avoids the need to do arithmetic at all by just
stopping the loop at 1 instead of 0, and then printing a newline.

CID: 1666497
CID: 1666256
CID: 1666531
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37746>
2025-10-21 21:55:53 +00:00
Dylan Baker
f25e59b951 intel/mda/tests: use an ASSERT on fread()
Coverity is pointing out that we should check this, and in reality if
this isn't what we expect the rest of the test is probably invalid
anyway.

CID: 1666504
CID: 1666544
CID: 1666552
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37750>
2025-10-21 14:39:18 -07:00
Mauro Rossi
7b50b8966b intel/mda: Fix gnu-empty-initializer warning
This also causes build errors on older Android prebuilt clang.

Fixes: bccc0fa9 ("intel/mda: Add code to produce mesa debug archives")
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37586>
2025-09-26 08:30:16 +00:00
Tim Van Patten
f90e0f0797 intel: Convert getenv() to os_get_option()
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
os_get_option() is a wrapper for getenv() that checks properties in
Android. It should be a no-op for other OS but will allow full use of
env vars in Android.

The environment variable names are automatically renamed by
os_get_option() and the order of precedence thus becomes:

1. getenv (non-Android)
2. debug.mesa.* (Android)
3. vendor.mesa.* (Android)
4. mesa.* (Android, as a fallback for older versions)

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37587>
2025-09-25 17:01:18 -06:00
Caio Oliveira
f00fca998e intel/mda: Add MDA_FILTER to select which archives to generate
Matches if names contains the filter value, multiple values separated by
commas.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
34198545aa intel/mda: Use archive filename as directory name instead of hardcoded "mda/"
This changes debug_archiver to create files inside a directory named
after the archive filename (e.g., "debug.anv.mda/") instead of the
hardcoded "mda/" directory.  This prevents conflicts if multiple
mda.tar files are extracted in the same location.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
3ff37e97a0 intel/mda: Allow more toplevel directory names inside mda.tar files
Will allow generate anv.tar with unique "first directory name" instead
of always "mda/", avoiding overlaps if user untars the files.  The name
still must end with "mda/".

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
a1d66c18c9 intel/mda: If MDA_PREFIX=timestamp use the actual timestamp as a prefix
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
c21494576e intel/mda: Add MDA_OUTPUT_DIR and MDA_PREFIX environment variable support
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
dfdc883833 intel/mda: Add pager support
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
ceb1baf939 intel/mda: Handle non-contiguous object versions in mda.tar files
Allow archives to have interleaved entries where different object
versions don't appear together.  This gives more flexibility to the
drivers when producing the mda.tar files.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
38b462e09a intel/mda: Add -U and -Y diff options
Make more ergonomic to use the common unified and side-by-side diffs,
and also optionally set the context lines (for -U) and the width (for -Y).
This should cover most common cases.  MDA_DIFF_COMMAND is still available
for full control.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
ef3cafe44e intel/mda: Add search/searchall commands
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
44f39eea55 intel/mda: Add tool to inspect mesa debug archives
The debug archive files are regular tar files, so can be
inspected by tar, and also used direct by file managers and editors.
However a few common tasks are worth having already set up in the
repository.

This tool adds convenience to some of those tasks, including

- Print last version of a shader representation;
- Print a `git-log`-like view of the changes of a shader;
- Comparing two shaders, e.g. SIMD8 and SIMD16 shaders in
  Intel;
- Comparing two specific versions of any shaders.

See the "manual" inside the commit for more details.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00
Caio Oliveira
bccc0fa984 intel/mda: Add code to produce mesa debug archives
Uses the tar format to collect multiple output files.  It can
be inspected using the regular UNIX tools, but a later commit
will add a specialized tool to perform common tasks.

The tar implementation is enough to fulfill the current needs
without adding a dependency.  There's also a small test mostly
to ensure scaffolding is there in case we need to expand the
implementation.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
2025-09-24 23:08:45 -07:00