diff options
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index b7d53ced1..5a2a0b84d 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -39,8 +39,9 @@ struct alignas(64) SwizzleTable { | |||
| 39 | constexpr auto legacy_swizzle_table = SwizzleTable<8, 64, 1>(); | 39 | constexpr auto legacy_swizzle_table = SwizzleTable<8, 64, 1>(); |
| 40 | constexpr auto fast_swizzle_table = SwizzleTable<8, 4, 16>(); | 40 | constexpr auto fast_swizzle_table = SwizzleTable<8, 4, 16>(); |
| 41 | 41 | ||
| 42 | void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, | 42 | static void LegacySwizzleData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, |
| 43 | u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height) { | 43 | u8* swizzled_data, u8* unswizzled_data, bool unswizzle, |
| 44 | u32 block_height) { | ||
| 44 | std::array<u8*, 2> data_ptrs; | 45 | std::array<u8*, 2> data_ptrs; |
| 45 | const std::size_t stride = width * bytes_per_pixel; | 46 | const std::size_t stride = width * bytes_per_pixel; |
| 46 | const std::size_t gobs_in_x = 64; | 47 | const std::size_t gobs_in_x = 64; |
| @@ -67,8 +68,9 @@ void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_ | |||
| 67 | } | 68 | } |
| 68 | } | 69 | } |
| 69 | 70 | ||
| 70 | void FastSwizzleData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, | 71 | static void FastSwizzleData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, |
| 71 | u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height) { | 72 | u8* swizzled_data, u8* unswizzled_data, bool unswizzle, |
| 73 | u32 block_height) { | ||
| 72 | std::array<u8*, 2> data_ptrs; | 74 | std::array<u8*, 2> data_ptrs; |
| 73 | const std::size_t stride{width * bytes_per_pixel}; | 75 | const std::size_t stride{width * bytes_per_pixel}; |
| 74 | const std::size_t gobs_in_x = 64; | 76 | const std::size_t gobs_in_x = 64; |
| @@ -96,6 +98,17 @@ void FastSwizzleData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_p | |||
| 96 | } | 98 | } |
| 97 | } | 99 | } |
| 98 | 100 | ||
| 101 | void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, | ||
| 102 | u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height) { | ||
| 103 | if (bytes_per_pixel % 3 != 0) { | ||
| 104 | FastSwizzleData(width, height, bytes_per_pixel, out_bytes_per_pixel, swizzled_data, | ||
| 105 | unswizzled_data, unswizzle, block_height); | ||
| 106 | } else { | ||
| 107 | LegacySwizzleData(width, height, bytes_per_pixel, out_bytes_per_pixel, swizzled_data, | ||
| 108 | unswizzled_data, unswizzle, block_height); | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 99 | u32 BytesPerPixel(TextureFormat format) { | 112 | u32 BytesPerPixel(TextureFormat format) { |
| 100 | switch (format) { | 113 | switch (format) { |
| 101 | case TextureFormat::DXT1: | 114 | case TextureFormat::DXT1: |
| @@ -142,13 +155,8 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 142 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width, | 155 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width, |
| 143 | u32 height, u32 block_height) { | 156 | u32 height, u32 block_height) { |
| 144 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); | 157 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); |
| 145 | if (bytes_per_pixel % 3 != 0) { | 158 | CopySwizzledData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, |
| 146 | FastSwizzleData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, | 159 | Memory::GetPointer(address), unswizzled_data.data(), true, block_height); |
| 147 | Memory::GetPointer(address), unswizzled_data.data(), true, block_height); | ||
| 148 | } else { | ||
| 149 | CopySwizzledData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, | ||
| 150 | Memory::GetPointer(address), unswizzled_data.data(), true, block_height); | ||
| 151 | } | ||
| 152 | return unswizzled_data; | 160 | return unswizzled_data; |
| 153 | } | 161 | } |
| 154 | 162 | ||