diff options
author | Rodrigo Locatti <reinuseslisp@airmail.cc> | 2021-03-31 00:31:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 00:31:52 +0200 |
commit | 5ee669466fcebd2258229ed6bfe6b5e5529e0200 (patch) | |
tree | 6dbf84fb5c2c9656f1d1ef6c46b2527ea1a205ff /src/video_core/textures/decoders.h | |
parent | Merge pull request #6116 from german77/userArgument (diff) | |
parent | astc_decoder: Refactor for style and more efficient memory use (diff) | |
download | yuzu-5ee669466fcebd2258229ed6bfe6b5e5529e0200.tar yuzu-5ee669466fcebd2258229ed6bfe6b5e5529e0200.tar.gz yuzu-5ee669466fcebd2258229ed6bfe6b5e5529e0200.tar.bz2 yuzu-5ee669466fcebd2258229ed6bfe6b5e5529e0200.tar.lz yuzu-5ee669466fcebd2258229ed6bfe6b5e5529e0200.tar.xz yuzu-5ee669466fcebd2258229ed6bfe6b5e5529e0200.tar.zst yuzu-5ee669466fcebd2258229ed6bfe6b5e5529e0200.zip |
Diffstat (limited to 'src/video_core/textures/decoders.h')
-rw-r--r-- | src/video_core/textures/decoders.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h index d7cdc81e8..4c14cefbf 100644 --- a/src/video_core/textures/decoders.h +++ b/src/video_core/textures/decoders.h @@ -23,8 +23,22 @@ constexpr u32 GOB_SIZE_SHIFT = GOB_SIZE_X_SHIFT + GOB_SIZE_Y_SHIFT + GOB_SIZE_Z_ using SwizzleTable = std::array<std::array<u32, GOB_SIZE_X>, GOB_SIZE_Y>; -/// Returns a z-order swizzle table -SwizzleTable MakeSwizzleTable(); +/** + * This table represents the internal swizzle of a gob, in format 16 bytes x 2 sector packing. + * Calculates the offset of an (x, y) position within a swizzled texture. + * Taken from the Tegra X1 Technical Reference Manual. pages 1187-1188 + */ +constexpr SwizzleTable MakeSwizzleTable() { + SwizzleTable table{}; + for (u32 y = 0; y < table.size(); ++y) { + for (u32 x = 0; x < table[0].size(); ++x) { + table[y][x] = ((x % 64) / 32) * 256 + ((y % 8) / 2) * 64 + ((x % 32) / 16) * 32 + + (y % 2) * 16 + (x % 16); + } + } + return table; +} +constexpr SwizzleTable SWIZZLE_TABLE = MakeSwizzleTable(); /// Unswizzles a block linear texture into linear memory. void UnswizzleTexture(std::span<u8> output, std::span<const u8> input, u32 bytes_per_pixel, |