Some encoding fixes to GTX
This commit is contained in:
parent
3bccc3ca5e
commit
fba66217d1
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -31,19 +31,8 @@ namespace FirstPlugin
|
||||
if (surfOut.depth != 1)
|
||||
throw new Exception($"Unsupported Depth {surfOut.depth}!");
|
||||
|
||||
uint s = 0;
|
||||
switch (tileMode)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 16:
|
||||
s = 0;
|
||||
break;
|
||||
default:
|
||||
s = 0xd0000 | setting.swizzle << 8;
|
||||
break;
|
||||
}
|
||||
uint s = (uint)(setting.swizzle << 8);
|
||||
|
||||
uint blkWidth, blkHeight;
|
||||
if (GTX.IsFormatBCN(Format))
|
||||
{
|
||||
@ -55,6 +44,13 @@ namespace FirstPlugin
|
||||
blkWidth = 1;
|
||||
blkHeight = 1;
|
||||
}
|
||||
|
||||
if (tileMode == 0)
|
||||
tileMode = GTX.getDefaultGX2TileMode(1, setting.TexWidth, setting.TexHeight, 1,(uint)setting.Format, 0, 1);
|
||||
|
||||
int tiling1dLevel = 0;
|
||||
bool tiling1dLevelSet = false;
|
||||
|
||||
List<uint> mipOffsets = new List<uint>();
|
||||
List<byte[]> Swizzled = new List<byte[]>();
|
||||
|
||||
@ -100,8 +96,22 @@ namespace FirstPlugin
|
||||
surfOut.pitch, surfOut.bpp, data_, DepthLevel);
|
||||
|
||||
Swizzled.Add(dataAlignBytes.Concat(SwizzledData).ToArray());
|
||||
|
||||
if (surfOut.tileMode == 1 || surfOut.tileMode == 2 ||
|
||||
surfOut.tileMode == 3 || surfOut.tileMode == 16)
|
||||
{
|
||||
tiling1dLevelSet = true;
|
||||
}
|
||||
|
||||
if (tiling1dLevelSet == false)
|
||||
tiling1dLevel += 1;
|
||||
}
|
||||
|
||||
if (tiling1dLevelSet)
|
||||
s |= (uint)(tiling1dLevel << 16);
|
||||
else
|
||||
s |= (uint)(13 << 16);
|
||||
|
||||
GTX.GX2Surface surf = new GTX.GX2Surface();
|
||||
surf.depth = setting.Depth;
|
||||
surf.width = setting.TexWidth;
|
||||
|
Binary file not shown.
@ -500,13 +500,6 @@ namespace Switch_Toolbox.Library
|
||||
int dataOffset = 0;
|
||||
int mipDataOffset = 0;
|
||||
int TotalImageSize = tex.data.Length;
|
||||
int _swizzle = (int)tex.swizzle << 8;
|
||||
|
||||
if (tex.tileMode == 0)
|
||||
tex.tileMode = getDefaultGX2TileMode(1, tex.width, tex.height, 1, tex.format, 0, 1);
|
||||
|
||||
int tiling1dLevel = 0;
|
||||
bool tiling1dLevelSet = false;
|
||||
|
||||
List<List<byte[]>> result = new List<List<byte[]>>();
|
||||
for (int arrayLevel = 0; arrayLevel < tex.depth; arrayLevel++)
|
||||
@ -549,26 +542,10 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
result.Add(mips);
|
||||
|
||||
if (surfInfo.tileMode == 1 || surfInfo.tileMode == 2 ||
|
||||
surfInfo.tileMode == 3 || surfInfo.tileMode == 16)
|
||||
{
|
||||
tiling1dLevelSet = true;
|
||||
}
|
||||
|
||||
if (tiling1dLevelSet == false)
|
||||
{
|
||||
tiling1dLevel += 1;
|
||||
}
|
||||
|
||||
dataOffset += ArrayImageize;
|
||||
mipDataOffset += ArrayMipImageize;
|
||||
}
|
||||
|
||||
if (tiling1dLevelSet)
|
||||
_swizzle |= tiling1dLevel << 16;
|
||||
else
|
||||
_swizzle |= 13 << 16;
|
||||
|
||||
return result;
|
||||
}
|
||||
private static byte[] SubArray(byte[] data, int offset, int length)
|
||||
@ -740,7 +717,7 @@ namespace Switch_Toolbox.Library
|
||||
return newDim;
|
||||
}
|
||||
|
||||
private static uint getDefaultGX2TileMode(uint dim, uint width, uint height, uint depth, uint format_, uint aa, uint use)
|
||||
public static uint getDefaultGX2TileMode(uint dim, uint width, uint height, uint depth, uint format_, uint aa, uint use)
|
||||
{
|
||||
uint tileMode = 1;
|
||||
bool IsDepthBuffer = (use & 4) != 0;
|
||||
@ -767,6 +744,9 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
private static uint GX2TileModeToAddrTileMode(uint tileMode)
|
||||
{
|
||||
if (tileMode == 0)
|
||||
throw new Exception("Use tileMode from getDefaultGX2TileMode().");
|
||||
|
||||
if (tileMode == 16)
|
||||
return 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user