mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-07 13:39:55 +00:00
A GPU-direct storage write-back retiles the image's elements into an uninitialised device scratch buffer and then copies whole ranges of it into the import or the import's unit shadow. The retile writes only the bytes elements occupy, so every other byte of the copied ranges was stored from uninitialised scratch memory: the padding of the tile blocks a surface covers only partly (its last block column and row), mip tail blocks, the bytes between mips and the pitch padding of linear surfaces. Another surface over the same memory, or the CPU, then read garbage there instead of what the memory held. Both the block-window path and the whole-layer path did this. Before the retile, the bytes of the copied ranges that no element holds are now copied into the scratch from where they are current (a fresh unit shadow, else the import), so the write-back stores them unchanged. Whole tile blocks every byte of which holds an element are left out (CoveredMipBytes), so only partly covered blocks pay for the extra copy. Tests: CoveredMipBytes against the XOR address equations of the four 64 KiB XOR modes at every element size; a device test that stores cleared images over patterned memory (tiled with and without mip chains, off a 64 KiB boundary, 4 KiB standard, linear; plain and watched memory) and checks every byte that is not a texel kept its pattern.