diff options
author | FernandoS27 <fsahmkow27@gmail.com> | 2018-09-21 17:10:44 +0200 |
---|---|---|
committer | FernandoS27 <fsahmkow27@gmail.com> | 2018-09-21 17:10:44 +0200 |
commit | f020319a45dcac183ec50d12593658670717fd59 (patch) | |
tree | d321796cf90386346fba0af49f1a26ad95140f4c /src/video_core/textures/decoders.cpp | |
parent | Improved Legacy Swizzler to be better documented and work better (diff) | |
download | yuzu-f020319a45dcac183ec50d12593658670717fd59.tar yuzu-f020319a45dcac183ec50d12593658670717fd59.tar.gz yuzu-f020319a45dcac183ec50d12593658670717fd59.tar.bz2 yuzu-f020319a45dcac183ec50d12593658670717fd59.tar.lz yuzu-f020319a45dcac183ec50d12593658670717fd59.tar.xz yuzu-f020319a45dcac183ec50d12593658670717fd59.tar.zst yuzu-f020319a45dcac183ec50d12593658670717fd59.zip |
Diffstat (limited to '')
-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 { constexpr auto swizzle_table = SwizzleTable<8, 4>(); -void FastSwizzleData(u32 width, u32 height, u32 bytes_per_pixel, u8* swizzled_data, +void FastSwizzleData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height) { std::array<u8*, 2> data_ptrs; 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 const std::size_t initial_gob = (y / (gobs_in_y * block_height)) * gobs_size * block_height * image_width_in_gobs + (y % (gobs_in_y * block_height) / gobs_in_y) * gobs_size; - const std::size_t pixel_base{y * width * bytes_per_pixel}; + const std::size_t pixel_base{y * width * out_bytes_per_pixel}; const auto& table = swizzle_table[y % gobs_in_y]; for (std::size_t xb = 0; xb < stride; xb += copy_size) { const std::size_t truncated_copy = std::min(copy_size, stride - xb); const std::size_t gob_address{initial_gob + (xb / gobs_in_x) * gobs_size * block_height}; const std::size_t swizzle_offset{gob_address + table[(xb / 16) % 4]}; - const std::size_t pixel_index{xb + pixel_base}; + const std::size_t out_x = xb*out_bytes_per_pixel / bytes_per_pixel; + const std::size_t pixel_index{out_x + pixel_base}; data_ptrs[unswizzle] = swizzled_data + swizzle_offset; data_ptrs[!unswizzle] = unswizzled_data + pixel_index; 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 u32 height, u32 block_height) { std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); if (bytes_per_pixel % 3 != 0) { - FastSwizzleData(width / tile_size, height / tile_size, bytes_per_pixel, + FastSwizzleData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, Memory::GetPointer(address), unswizzled_data.data(), true, block_height); } else { CopySwizzledData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, |