summaryrefslogtreecommitdiffstats
path: root/src/video_core/textures/decoders.cpp
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-04-16 03:06:04 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-04-16 03:22:16 +0200
commitbec28d692d21a42f17ae26f0ab6271aca1c233cd (patch)
treec776ad716389b6113b76cd058e0c236c6697f7a2 /src/video_core/textures/decoders.cpp
parentCorrect Kepler Memory on Linear Pushes. (diff)
downloadyuzu-bec28d692d21a42f17ae26f0ab6271aca1c233cd.tar
yuzu-bec28d692d21a42f17ae26f0ab6271aca1c233cd.tar.gz
yuzu-bec28d692d21a42f17ae26f0ab6271aca1c233cd.tar.bz2
yuzu-bec28d692d21a42f17ae26f0ab6271aca1c233cd.tar.lz
yuzu-bec28d692d21a42f17ae26f0ab6271aca1c233cd.tar.xz
yuzu-bec28d692d21a42f17ae26f0ab6271aca1c233cd.tar.zst
yuzu-bec28d692d21a42f17ae26f0ab6271aca1c233cd.zip
Diffstat (limited to 'src/video_core/textures/decoders.cpp')
-rw-r--r--src/video_core/textures/decoders.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 995d0e068..6e02a6407 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -288,6 +288,27 @@ void UnswizzleSubrect(u32 subrect_width, u32 subrect_height, u32 dest_pitch, u32
}
}
+void SwizzleKepler(u32 width, u32 height, u32 dst_x, u32 dst_y, u32 block_height,
+ std::size_t copy_size, u8* source_data, u8* swizzle_data) {
+ const u32 image_width_in_gobs{(width + gob_size_x - 1) / gob_size_x};
+ std::size_t count = 0;
+ for (u32 y = dst_y; y < height && count < copy_size; ++y) {
+ const u32 gob_address_y =
+ (y / (gob_size_y * block_height)) * gob_size * block_height * image_width_in_gobs +
+ ((y % (gob_size_y * block_height)) / gob_size_y) * gob_size;
+ const auto& table = legacy_swizzle_table[y % gob_size_y];
+ for (u32 x = dst_x; x < width && count < copy_size; ++x) {
+ const u32 gob_address = gob_address_y + (x / gob_size_x) * gob_size * block_height;
+ const u32 swizzled_offset = gob_address + table[x % gob_size_x];
+ const u8* source_line = source_data + count;
+ u8* dest_addr = swizzle_data + swizzled_offset;
+ count++;
+
+ std::memcpy(dest_addr, source_line, 1);
+ }
+ }
+}
+
std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat format, u32 width,
u32 height) {
std::vector<u8> rgba_data;