diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 89d218bc7..c61195969 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -71,7 +71,7 @@ struct alignas(64) SwizzleTable { | |||
| 71 | 71 | ||
| 72 | constexpr auto swizzle_table = SwizzleTable<8, 4>(); | 72 | constexpr auto swizzle_table = SwizzleTable<8, 4>(); |
| 73 | 73 | ||
| 74 | void FastSwizzleData(u32 width, u32 height, u32 bytes_per_pixel, u8* swizzled_data, | 74 | void FastSwizzleData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, u8* swizzled_data, |
| 75 | u8* unswizzled_data, bool unswizzle, u32 block_height) { | 75 | u8* unswizzled_data, bool unswizzle, u32 block_height) { |
| 76 | std::array<u8*, 2> data_ptrs; | 76 | std::array<u8*, 2> data_ptrs; |
| 77 | const std::size_t stride{width * bytes_per_pixel}; | 77 | const std::size_t stride{width * bytes_per_pixel}; |
| @@ -84,14 +84,15 @@ void FastSwizzleData(u32 width, u32 height, u32 bytes_per_pixel, u8* swizzled_da | |||
| 84 | const std::size_t initial_gob = | 84 | const std::size_t initial_gob = |
| 85 | (y / (gobs_in_y * block_height)) * gobs_size * block_height * image_width_in_gobs + | 85 | (y / (gobs_in_y * block_height)) * gobs_size * block_height * image_width_in_gobs + |
| 86 | (y % (gobs_in_y * block_height) / gobs_in_y) * gobs_size; | 86 | (y % (gobs_in_y * block_height) / gobs_in_y) * gobs_size; |
| 87 | const std::size_t pixel_base{y * width * bytes_per_pixel}; | 87 | const std::size_t pixel_base{y * width * out_bytes_per_pixel}; |
| 88 | const auto& table = swizzle_table[y % gobs_in_y]; | 88 | const auto& table = swizzle_table[y % gobs_in_y]; |
| 89 | for (std::size_t xb = 0; xb < stride; xb += copy_size) { | 89 | for (std::size_t xb = 0; xb < stride; xb += copy_size) { |
| 90 | const std::size_t truncated_copy = std::min(copy_size, stride - xb); | 90 | const std::size_t truncated_copy = std::min(copy_size, stride - xb); |
| 91 | const std::size_t gob_address{initial_gob + | 91 | const std::size_t gob_address{initial_gob + |
| 92 | (xb / gobs_in_x) * gobs_size * block_height}; | 92 | (xb / gobs_in_x) * gobs_size * block_height}; |
| 93 | const std::size_t swizzle_offset{gob_address + table[(xb / 16) % 4]}; | 93 | const std::size_t swizzle_offset{gob_address + table[(xb / 16) % 4]}; |
| 94 | const std::size_t pixel_index{xb + pixel_base}; | 94 | const std::size_t out_x = xb*out_bytes_per_pixel / bytes_per_pixel; |
| 95 | const std::size_t pixel_index{out_x + pixel_base}; | ||
| 95 | data_ptrs[unswizzle] = swizzled_data + swizzle_offset; | 96 | data_ptrs[unswizzle] = swizzled_data + swizzle_offset; |
| 96 | data_ptrs[!unswizzle] = unswizzled_data + pixel_index; | 97 | data_ptrs[!unswizzle] = unswizzled_data + pixel_index; |
| 97 | std::memcpy(data_ptrs[0], data_ptrs[1], truncated_copy); | 98 | std::memcpy(data_ptrs[0], data_ptrs[1], truncated_copy); |
| @@ -146,7 +147,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pix | |||
| 146 | u32 height, u32 block_height) { | 147 | u32 height, u32 block_height) { |
| 147 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); | 148 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); |
| 148 | if (bytes_per_pixel % 3 != 0) { | 149 | if (bytes_per_pixel % 3 != 0) { |
| 149 | FastSwizzleData(width / tile_size, height / tile_size, bytes_per_pixel, | 150 | FastSwizzleData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, |
| 150 | Memory::GetPointer(address), unswizzled_data.data(), true, block_height); | 151 | Memory::GetPointer(address), unswizzled_data.data(), true, block_height); |
| 151 | } else { | 152 | } else { |
| 152 | CopySwizzledData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, | 153 | CopySwizzledData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, |