diff options
| -rw-r--r-- | src/video_core/morton.cpp | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/video_core/morton.cpp b/src/video_core/morton.cpp index b68f4fb13..69b6be73a 100644 --- a/src/video_core/morton.cpp +++ b/src/video_core/morton.cpp | |||
| @@ -191,45 +191,6 @@ static MortonCopyFn GetSwizzleFunction(MortonSwizzleMode mode, Surface::PixelFor | |||
| 191 | return morton_to_linear_fns[static_cast<std::size_t>(format)]; | 191 | return morton_to_linear_fns[static_cast<std::size_t>(format)]; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | /// 8x8 Z-Order coordinate from 2D coordinates | ||
| 195 | static u32 MortonInterleave(u32 x, u32 y) { | ||
| 196 | static const u32 xlut[] = {0x00, 0x01, 0x04, 0x05, 0x10, 0x11, 0x14, 0x15}; | ||
| 197 | static const u32 ylut[] = {0x00, 0x02, 0x08, 0x0a, 0x20, 0x22, 0x28, 0x2a}; | ||
| 198 | return xlut[x % 8] + ylut[y % 8]; | ||
| 199 | } | ||
| 200 | |||
| 201 | /// Calculates the offset of the position of the pixel in Morton order | ||
| 202 | static u32 GetMortonOffset(u32 x, u32 y, u32 bytes_per_pixel) { | ||
| 203 | // Images are split into 8x8 tiles. Each tile is composed of four 4x4 subtiles each | ||
| 204 | // of which is composed of four 2x2 subtiles each of which is composed of four texels. | ||
| 205 | // Each structure is embedded into the next-bigger one in a diagonal pattern, e.g. | ||
| 206 | // texels are laid out in a 2x2 subtile like this: | ||
| 207 | // 2 3 | ||
| 208 | // 0 1 | ||
| 209 | // | ||
| 210 | // The full 8x8 tile has the texels arranged like this: | ||
| 211 | // | ||
| 212 | // 42 43 46 47 58 59 62 63 | ||
| 213 | // 40 41 44 45 56 57 60 61 | ||
| 214 | // 34 35 38 39 50 51 54 55 | ||
| 215 | // 32 33 36 37 48 49 52 53 | ||
| 216 | // 10 11 14 15 26 27 30 31 | ||
| 217 | // 08 09 12 13 24 25 28 29 | ||
| 218 | // 02 03 06 07 18 19 22 23 | ||
| 219 | // 00 01 04 05 16 17 20 21 | ||
| 220 | // | ||
| 221 | // This pattern is what's called Z-order curve, or Morton order. | ||
| 222 | |||
| 223 | const unsigned int block_height = 8; | ||
| 224 | const unsigned int coarse_x = x & ~7; | ||
| 225 | |||
| 226 | u32 i = MortonInterleave(x, y); | ||
| 227 | |||
| 228 | const unsigned int offset = coarse_x * block_height; | ||
| 229 | |||
| 230 | return (i + offset) * bytes_per_pixel; | ||
| 231 | } | ||
| 232 | |||
| 233 | static u32 MortonInterleave128(u32 x, u32 y) { | 194 | static u32 MortonInterleave128(u32 x, u32 y) { |
| 234 | // 128x128 Z-Order coordinate from 2D coordinates | 195 | // 128x128 Z-Order coordinate from 2D coordinates |
| 235 | static constexpr u32 xlut[] = { | 196 | static constexpr u32 xlut[] = { |