ail: Add unit tests for miptree layouts
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 21 Aug 2022 01:47:57 +0000 (21:47 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 1 Sep 2022 22:30:48 +0000 (22:30 +0000)
commit65c00ba7cbdcebef3fd7a1efcb95b5bdb480e9dc
treeef9af70b449ef7ad8ab753e68479e44bc82e77d7
parent1f89e67883c9af2ccb4444120badfff4abba4cac
ail: Add unit tests for miptree layouts

The equations for calculating miptree offsets are complicated,
nonobvious, and full of subtle footguns. Worse, the driver doesn't
control the offsets -- it must simply agree with the offsets
implicitly calculated in the hardware. The CTS doesn't adequately
exercise all the corner cases. Make sure we have unit tests that do.

The tests themselves are generated by instrumenting agxdecode to scan
GPU memory after uploading test patterns in a variety of layout with a
Metal application.

Thank you to Asahi Lina and Dougall Johnson for the reverse-engineering
that led to this. The tests selected here are a subset of those used for
the reverse-engineering. The full set may be found in Lina's tilecalc
repo:

   https://github.com/asahilina/tilecalc

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
src/asahi/layout/meson.build
src/asahi/layout/tests/test-layout.cpp [new file with mode: 0644]