mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 12:33:12 +00:00
Revert "Revert "Revert "Quick fix for switch textures with strange resolutions."""
This reverts commit 2866344409
.
This commit is contained in:
parent
2866344409
commit
b673b3ee60
2 changed files with 4 additions and 34 deletions
|
@ -350,19 +350,6 @@ namespace FirstPlugin
|
|||
Console.WriteLine("MipOffsets " + SurfaceSize);
|
||||
Console.WriteLine("size " + size);
|
||||
|
||||
int powBlockShift = 0;
|
||||
if (STGenericTexture.IsCompressed(TexFormat) && mipLevel == 0)
|
||||
{
|
||||
if (width_ > 32 && height_ <= 40)
|
||||
powBlockShift += 1;
|
||||
if (width_ > 64 && height_ <= 84)
|
||||
powBlockShift += 1;
|
||||
if (width_ > 128 && height_ <= 168)
|
||||
powBlockShift += 1;
|
||||
if (width_ > 256 && height_ <= 340)
|
||||
powBlockShift += 1;
|
||||
}
|
||||
|
||||
tex.MipOffsets[mipLevel] = SurfaceSize;
|
||||
if (tex.TileMode == TileMode.LinearAligned)
|
||||
{
|
||||
|
@ -379,12 +366,10 @@ namespace FirstPlugin
|
|||
blockHeightShift += 1;
|
||||
|
||||
Pitch = TegraX1Swizzle.round_up(width__ * bpp, 64);
|
||||
SurfaceSize += Pitch * TegraX1Swizzle.round_up(height__, Math.Max(1, blockHeight >> (blockHeightShift + powBlockShift)) * 8);
|
||||
SurfaceSize += Pitch * TegraX1Swizzle.round_up(height__, Math.Max(1, blockHeight >> blockHeightShift) * 8);
|
||||
}
|
||||
|
||||
int blockShift = blockHeightShift + powBlockShift;
|
||||
|
||||
byte[] SwizzledData = TegraX1Swizzle.swizzle(width_, height_, depth_, blkWidth, blkHeight, blkDepth, target, bpp, (uint)tex.TileMode, (int)Math.Max(0, tex.BlockHeightLog2 - blockShift), data_);
|
||||
byte[] SwizzledData = TegraX1Swizzle.swizzle(width_, height_, depth_, blkWidth, blkHeight, blkDepth, target, bpp, (uint)tex.TileMode, (int)Math.Max(0, tex.BlockHeightLog2 - blockHeightShift), data_);
|
||||
mipmaps.Add(AlignedData.Concat(SwizzledData).ToArray());
|
||||
}
|
||||
tex.ImageSize = SurfaceSize;
|
||||
|
|
|
@ -103,21 +103,6 @@ namespace Toolbox.Library
|
|||
if (TegraX1Swizzle.pow2_round_up(TegraX1Swizzle.DIV_ROUND_UP(height, blkWidth)) < linesPerBlockHeight)
|
||||
blockHeightShift += 1;
|
||||
|
||||
int powBlockShift = 0;
|
||||
if (STGenericTexture.IsCompressed(texture.Format) && mipLevel == 0)
|
||||
{
|
||||
if (width > 32 && height <= 40)
|
||||
powBlockShift += 1;
|
||||
if (width > 64 && height <= 84)
|
||||
powBlockShift += 1;
|
||||
if (width > 128 && height <= 168)
|
||||
powBlockShift += 1;
|
||||
if (width > 256 && height <= 340)
|
||||
powBlockShift += 1;
|
||||
}
|
||||
|
||||
int blockShift = blockHeightShift + powBlockShift;
|
||||
|
||||
uint width__ = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth);
|
||||
uint height__ = TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight);
|
||||
|
||||
|
@ -134,9 +119,9 @@ namespace Toolbox.Library
|
|||
try
|
||||
{
|
||||
Pitch = TegraX1Swizzle.round_up(width__ * bpp, 64);
|
||||
SurfaceSize += Pitch * TegraX1Swizzle.round_up(height__, Math.Max(1, blockHeight >> blockShift) * 8);
|
||||
SurfaceSize += Pitch * TegraX1Swizzle.round_up(height__, Math.Max(1, blockHeight >> blockHeightShift) * 8);
|
||||
|
||||
byte[] result = TegraX1Swizzle.deswizzle(width, height, depth, blkWidth, blkHeight, blkDepth, target, bpp, TileMode, (int)Math.Max(0, BlockHeightLog2 - blockShift), data_);
|
||||
byte[] result = TegraX1Swizzle.deswizzle(width, height, depth, blkWidth, blkHeight, blkDepth, target, bpp, TileMode, (int)Math.Max(0, BlockHeightLog2 - blockHeightShift), data_);
|
||||
//Create a copy and use that to remove uneeded data
|
||||
byte[] result_ = new byte[size];
|
||||
Array.Copy(result, 0, result_, 0, size);
|
||||
|
|
Loading…
Reference in a new issue