summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2018-09-21 17:42:34 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2018-09-21 17:42:34 +0200
commitd2dd1289bda29fba164bdd45854324e45a80e4c7 (patch)
tree8d4febbd532dddde5df65c6dd6258d77ef3fb2dd
parentStandarized Legacy Swizzle to look alike FastSwizzle and use a Swizzling Table instead (diff)
downloadyuzu-d2dd1289bda29fba164bdd45854324e45a80e4c7.tar
yuzu-d2dd1289bda29fba164bdd45854324e45a80e4c7.tar.gz
yuzu-d2dd1289bda29fba164bdd45854324e45a80e4c7.tar.bz2
yuzu-d2dd1289bda29fba164bdd45854324e45a80e4c7.tar.lz
yuzu-d2dd1289bda29fba164bdd45854324e45a80e4c7.tar.xz
yuzu-d2dd1289bda29fba164bdd45854324e45a80e4c7.tar.zst
yuzu-d2dd1289bda29fba164bdd45854324e45a80e4c7.zip
-rw-r--r--src/video_core/textures/decoders.cpp30
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 {
constexpr auto legacy_swizzle_table = SwizzleTable<8, 64, 1>();
constexpr auto fast_swizzle_table = SwizzleTable<8, 4, 16>();
-void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel,
- u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height) {
+static void LegacySwizzleData(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;
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_
}
}
-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) {
+static 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};
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
}
}
+void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel,
+ u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height) {
+ if (bytes_per_pixel % 3 != 0) {
+ FastSwizzleData(width, height, bytes_per_pixel, out_bytes_per_pixel, swizzled_data,
+ unswizzled_data, unswizzle, block_height);
+ } else {
+ LegacySwizzleData(width, height, bytes_per_pixel, out_bytes_per_pixel, swizzled_data,
+ unswizzled_data, unswizzle, block_height);
+ }
+}
+
u32 BytesPerPixel(TextureFormat format) {
switch (format) {
case TextureFormat::DXT1:
@@ -142,13 +155,8 @@ u32 BytesPerPixel(TextureFormat format) {
std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width,
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, 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,
- Memory::GetPointer(address), unswizzled_data.data(), true, block_height);
- }
+ CopySwizzledData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel,
+ Memory::GetPointer(address), unswizzled_data.data(), true, block_height);
return unswizzled_data;
}