mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-25 20:28:48 +08:00
1f3963c543
TryDetile's exact-XOR fast path (PS5 swizzle modes 5/9/24/27) ran the full AddrLib address equation per element: a 16-bit interleave with 32 PopCount calls for every pixel of textures that are millions of elements. Each output bit is parity(x & XMask) XOR parity(y & YMask), and parity distributes over XOR, so the offset factors into independent xTerm(x) ^ yTerm(y) fields. Precompute the per-column X term once and hoist the Y term per row, collapsing the inner loop to one array load and one XOR. Add GnmTilingDetileTests, which lays out a tiled buffer from an independent re-derivation of the mode-27 equation and asserts TryDetile reconstructs it byte-for-byte. Co-authored-by: slick-daddy <slick-daddy@users.noreply.github.com>