From 8820b019785e1658ac47376011f893cc0b5de906 Mon Sep 17 00:00:00 2001 From: AboodXD Date: Thu, 11 Apr 2019 19:53:55 +0400 Subject: [PATCH] Clean up and fix for format 0x35 (with tileMode 16) Also update README.md --- README.md | 2 +- Switch_Toolbox_Library/Swizzling/GX2.cs | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7743dae9..f5408312 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ In the event that the tool cannot compile, check references. All the libraries a - Exelix for Byaml, Sarc and KCL library - Syroot for helpful IO extensions and libraries - GDK Chan for some DDS decode methods -- AboodXD for some foundation stuff with exelix's SARC library, GTX and BNTX texture swizzling and documentation +- AboodXD for some foundation stuff with exelix's SARC library, Wii U (GPU7) and Switch (Tegra X1) textures swizzling, and documentation for GTX and BNTX - MelonSpeedruns for logo. Resources diff --git a/Switch_Toolbox_Library/Swizzling/GX2.cs b/Switch_Toolbox_Library/Swizzling/GX2.cs index 82c4f541..b7a99309 100644 --- a/Switch_Toolbox_Library/Swizzling/GX2.cs +++ b/Switch_Toolbox_Library/Swizzling/GX2.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; @@ -2346,10 +2346,7 @@ namespace Switch_Toolbox.Library else blockSize = 4; - width = (uint)(~(blockSize - 1) & ((surfaceWidth >> level) + blockSize - 1)); - - if (hwFormat == 0x35) - return pSurfOut; + width = (uint)(~(blockSize - 1) & (Math.Max(1, surfaceWidth >> level) + blockSize - 1)); pSurfOut.bpp = formatHwInfo[hwFormat * 4]; pSurfOut.size = 96; @@ -2392,13 +2389,9 @@ namespace Switch_Toolbox.Library pSurfOut.depth = surfaceDepth; } - pSurfOut.height = (uint)(~(blockSize - 1) & (pSurfOut.height + blockSize - 1)) / blockSize; - pSurfOut.pixelPitch = (uint)(~(blockSize - 1) & ((surfaceWidth >> level) + blockSize - 1)); - pSurfOut.pixelPitch = Math.Max(blockSize, pSurfOut.pixelPitch); - pSurfOut.pixelHeight = (uint)(~(blockSize - 1) & ((surfaceHeight >> level) + blockSize - 1)); - pSurfOut.pixelHeight = Math.Max(blockSize, pSurfOut.pixelHeight); - pSurfOut.pitch = Math.Max(1, pSurfOut.pitch); - pSurfOut.height = Math.Max(1, pSurfOut.height); + pSurfOut.pixelPitch = width; + pSurfOut.pixelHeight = (uint)(~(blockSize - 1) & (Math.Max(1, surfaceHeight >> level) + blockSize - 1)); + pSurfOut.height = (uint)(pSurfOut.pixelHeight / blockSize); pSurfOut.surfSize = pSurfOut.bpp * numSamples * pSurfOut.depth * pSurfOut.height * pSurfOut.pitch >> 3; if (surfaceDim == 2)