1
0
mirror of synced 2024-11-14 11:07:39 +01:00

Fixup mipsizes in nutexb

This commit is contained in:
KillzXGaming 2020-07-10 21:29:29 -04:00
parent cca60173d4
commit 1e3f2eebb6
2 changed files with 3 additions and 19 deletions

View File

@ -264,7 +264,6 @@ namespace FirstPlugin
public override void Replace(string FileName) public override void Replace(string FileName)
{ {
var bntxFile = new BNTX();
var tex = new TextureData(); var tex = new TextureData();
tex.Replace(FileName, MipCount, 0, Format); tex.Replace(FileName, MipCount, 0, Format);
@ -428,6 +427,8 @@ namespace FirstPlugin
public void Write(FileWriter writer) public void Write(FileWriter writer)
{ {
TextureName = Text;
//MipSizes stores mip sizes for multile arrays //MipSizes stores mip sizes for multile arrays
int arrayCount = mipSizes.Count; int arrayCount = mipSizes.Count;

View File

@ -42,23 +42,7 @@ namespace Toolbox.Library
uint depth = (uint)Math.Max(1, Depth >> mipLevel); uint depth = (uint)Math.Max(1, Depth >> mipLevel);
uint size = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth) * TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight) * bpp; uint size = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth) * TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight) * bpp;
MipOffsets[mipLevel] = size;
if (TegraX1Swizzle.pow2_round_up(TegraX1Swizzle.DIV_ROUND_UP(height, blkWidth)) < linesPerBlockHeight)
blockHeightShift += 1;
uint width__ = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth);
uint height__ = TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight);
//Calculate the mip size instead
byte[] AlignedData = new byte[(TegraX1Swizzle.round_up(SurfaceSize, DataAlignment) - SurfaceSize)];
SurfaceSize += (uint)AlignedData.Length;
MipOffsets[mipLevel] = (SurfaceSize);
//Get the first mip offset and current one and the total image size
int msize = (int)((MipOffsets[0] + ImageSize - MipOffsets[mipLevel]) / ArrayCount);
Pitch = TegraX1Swizzle.round_up(width__ * bpp, 64);
SurfaceSize += Pitch * TegraX1Swizzle.round_up(height__, Math.Max(1, blockHeight >> blockHeightShift) * 8);
} }
ArrayOffset += (uint)(ImageSize / ArrayCount); ArrayOffset += (uint)(ImageSize / ArrayCount);
@ -119,7 +103,6 @@ namespace Toolbox.Library
if (TegraX1Swizzle.pow2_round_up(TegraX1Swizzle.DIV_ROUND_UP(height, blkWidth)) < linesPerBlockHeight) if (TegraX1Swizzle.pow2_round_up(TegraX1Swizzle.DIV_ROUND_UP(height, blkWidth)) < linesPerBlockHeight)
blockHeightShift += 1; blockHeightShift += 1;
uint width__ = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth); uint width__ = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth);
uint height__ = TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight); uint height__ = TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight);