1*61046927SAndroid Build Coastguard Worker 2*61046927SAndroid Build Coastguard WorkerU-interleaved tiling 3*61046927SAndroid Build Coastguard Worker==================== 4*61046927SAndroid Build Coastguard Worker 5*61046927SAndroid Build Coastguard WorkerPanfrost supports u-interleaved tiling. U-interleaved tiling is 6*61046927SAndroid Build Coastguard Workerindicated by the ``DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED`` modifier. 7*61046927SAndroid Build Coastguard Worker 8*61046927SAndroid Build Coastguard WorkerThe tiling reorders whole pixels (blocks). It does not compress or modify the 9*61046927SAndroid Build Coastguard Workerpixels themselves, so it can be used for any image format. Internally, images 10*61046927SAndroid Build Coastguard Workerare divided into tiles. Tiles occur in source order, but pixels (blocks) within 11*61046927SAndroid Build Coastguard Workereach tile are reordered according to a space-filling curve. 12*61046927SAndroid Build Coastguard Worker 13*61046927SAndroid Build Coastguard WorkerFor regular formats, 16x16 tiles are used. This harmonizes with the default tile 14*61046927SAndroid Build Coastguard Workersize for binning and CRCs (transaction elimination). It also means a single line 15*61046927SAndroid Build Coastguard Worker(16 pixels) at 4 bytes per pixel equals a single 64-byte cache line. 16*61046927SAndroid Build Coastguard Worker 17*61046927SAndroid Build Coastguard WorkerFor formats that are already block compressed (S3TC, RGTC, etc), 4x4 tiles are 18*61046927SAndroid Build Coastguard Workerused, where entire blocks are reorder. Most of these formats compress 4x4 19*61046927SAndroid Build Coastguard Workerblocks, so this gives an effective 16x16 tiling. This justifies the tile size 20*61046927SAndroid Build Coastguard Workerintuitively, though it's not a rule: ASTC may uses larger blocks. 21*61046927SAndroid Build Coastguard Worker 22*61046927SAndroid Build Coastguard WorkerWithin a tile, the X and Y bits are interleaved (like Morton order), but with a 23*61046927SAndroid Build Coastguard Workertwist: adjacent bit pairs are XORed. The reason to add XORs is not obvious. 24*61046927SAndroid Build Coastguard WorkerVisually, addresses take the form:: 25*61046927SAndroid Build Coastguard Worker 26*61046927SAndroid Build Coastguard Worker | y3 | (x3 ^ y3) | y2 | (y2 ^ x2) | y1 | (y1 ^ x1) | y0 | (y0 ^ x0) | 27*61046927SAndroid Build Coastguard Worker 28*61046927SAndroid Build Coastguard WorkerReference routines to encode/decode u-interleaved images are available in 29*61046927SAndroid Build Coastguard Worker``src/panfrost/shared/test/test-tiling.cpp``, which documents the space-filling 30*61046927SAndroid Build Coastguard Workercurve. This reference implementation is used to unit test the optimized 31*61046927SAndroid Build Coastguard Workerimplementation used in production. The optimized implementation is available in 32*61046927SAndroid Build Coastguard Worker``src/panfrost/shared/pan_tiling.c``. 33*61046927SAndroid Build Coastguard Worker 34*61046927SAndroid Build Coastguard WorkerAlthough these routines are part of Panfrost, they are also used by Lima, as Arm 35*61046927SAndroid Build Coastguard Workerintroduced the format with Utgard. It is the only tiling supported on Utgard. On 36*61046927SAndroid Build Coastguard WorkerMali-T760 and newer, Arm Framebuffer Compression (AFBC) is more efficient and 37*61046927SAndroid Build Coastguard Workershould be used instead where possible. However, not all formats are 38*61046927SAndroid Build Coastguard Workercompressible, so u-interleaved tiling remains an important fallback on Panfrost. 39