Some more fixes.
Revert the GX2 one more time since swizzling is a bit bugged, but add a more up to date code as a backup. Fix the swizzle pattern settings
This commit is contained in:
parent
67f713bf22
commit
ae25f2989b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -132,11 +132,11 @@ namespace Bfres.Structs
|
||||
public void ReplaceImage(Image image, string FileName)
|
||||
{
|
||||
GTXImporterSettings setting = SetImporterSettings(image, FileName);
|
||||
setting.MipSwizzle = Tex2Swizzle;
|
||||
|
||||
GTXTextureImporter importer = new GTXTextureImporter();
|
||||
|
||||
if (Tex2Swizzle != 0)
|
||||
setting.swizzle = Tex2SwizzleValue;
|
||||
|
||||
setting.MipSwizzle = Tex2Swizzle;
|
||||
importer.LoadSetting(setting);
|
||||
|
||||
if (importer.ShowDialog() == DialogResult.OK)
|
||||
@ -193,14 +193,13 @@ namespace Bfres.Structs
|
||||
}
|
||||
|
||||
GTXImporterSettings setting = SetImporterSettings(FileName);
|
||||
setting.MipSwizzle = Tex2Swizzle;
|
||||
|
||||
GTXTextureImporter importer = new GTXTextureImporter();
|
||||
|
||||
setting.swizzle = 0;
|
||||
importer.ReadOnlySwizzle = IsSwizzleReadOnly;
|
||||
importer.ReadOnlyTileMode = IsSwizzleReadOnly;
|
||||
|
||||
if (Tex2Swizzle != 0)
|
||||
setting.swizzle = Tex2Swizzle;
|
||||
if (MipMapCount != 0)
|
||||
{
|
||||
setting.MipCount = MipMapCount;
|
||||
|
@ -208,7 +208,10 @@ namespace FirstPlugin
|
||||
|
||||
private void MipmapNum_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
SelectedTexSettings.MipCount = (uint)MipmapNum.Value;
|
||||
if (MipmapNum.Value > 0)
|
||||
SelectedTexSettings.MipCount = (uint)MipmapNum.Value;
|
||||
else
|
||||
SelectedTexSettings.MipCount = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ namespace FirstPlugin
|
||||
setting.TexHeight,
|
||||
setting.Depth,
|
||||
(uint)setting.Format,
|
||||
setting.swizzle,
|
||||
setting.SwizzlePattern,
|
||||
setting.MipSwizzle,
|
||||
(uint)setting.SurfaceDim,
|
||||
setting.MipCount);
|
||||
}
|
||||
|
@ -25,7 +25,10 @@ namespace FirstPlugin
|
||||
public bool GenerateMipmaps;
|
||||
public bool IsSRGB;
|
||||
public uint tileMode = 4;
|
||||
public uint swizzle = 4;
|
||||
|
||||
public uint SwizzlePattern = 0;
|
||||
public uint MipSwizzle = 0;
|
||||
|
||||
public GX2CompSel[] compSel = new GX2CompSel[4];
|
||||
public GX2SurfaceDim SurfaceDim = GX2SurfaceDim.Dim2D;
|
||||
public GX2AAMode AAMode = GX2AAMode.Mode1X;
|
||||
|
@ -205,17 +205,14 @@ namespace FirstPlugin
|
||||
|
||||
MipmapNum.Value = SelectedTexSettings.MipCount;
|
||||
|
||||
SwizzleNum.Value = (SelectedTexSettings.swizzle >> 8) & 7;
|
||||
SwizzleNum.Value = SelectedTexSettings.SwizzlePattern;
|
||||
}
|
||||
}
|
||||
|
||||
private void SwizzleNum_ValueChanged(object sender, EventArgs e) {
|
||||
// SelectedTexSettings.swizzle &= GX2.SwizzleMask;
|
||||
// SelectedTexSettings.swizzle |= (uint)SwizzleNum.Value << 8;
|
||||
SelectedTexSettings.SwizzlePattern = (uint)SwizzleNum.Value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
@ -517,7 +514,12 @@ namespace FirstPlugin
|
||||
|
||||
private void MipmapNum_ValueChanged(object sender, EventArgs e) {
|
||||
if (SelectedTexSettings != null)
|
||||
SelectedTexSettings.MipCount = (uint)MipmapNum.Value;
|
||||
{
|
||||
if (MipmapNum.Value > 0)
|
||||
SelectedTexSettings.MipCount = (uint)MipmapNum.Value;
|
||||
else
|
||||
SelectedTexSettings.MipCount = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
@ -47,6 +47,8 @@ namespace Switch_Toolbox.Library
|
||||
public uint[] texRegs;
|
||||
};
|
||||
|
||||
public static int m_configFlags = 4;
|
||||
|
||||
public static uint expPitch = 0;
|
||||
public static uint expHeight = 0;
|
||||
public static uint expNumSlices = 0;
|
||||
@ -430,7 +432,7 @@ namespace Switch_Toolbox.Library
|
||||
static bool DebugSurface = false;
|
||||
|
||||
public static GX2Surface CreateGx2Texture(byte[] imageData, string Name, uint TileMode, uint AAMode,
|
||||
uint Width, uint Height, uint Depth, uint Format, uint swizzle, uint SurfaceDim, uint MipCount)
|
||||
uint Width, uint Height, uint Depth, uint Format, uint swizzle, uint mipSwizzle, uint SurfaceDim, uint MipCount)
|
||||
{
|
||||
var surfOut = getSurfaceInfo((GX2SurfaceFormat)Format, Width, Height, 1, 1, TileMode, 0, 0);
|
||||
uint imageSize = (uint)surfOut.surfSize;
|
||||
@ -472,6 +474,8 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
|
||||
{
|
||||
uint swizzleValue = s;
|
||||
|
||||
var result = TextureHelper.GetCurrentMipSize(Width, Height, blkWidth, blkHeight, bpp, mipLevel);
|
||||
|
||||
uint offset = result.Item1;
|
||||
@ -485,6 +489,9 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
if (mipLevel != 0)
|
||||
{
|
||||
if (mipSwizzle != 0)
|
||||
swizzleValue = mipSwizzle;
|
||||
|
||||
surfOut = GX2.getSurfaceInfo((GX2SurfaceFormat)Format, Width, Height, 1, 1, TileMode, 0, mipLevel);
|
||||
|
||||
if (mipLevel == 1)
|
||||
@ -499,7 +506,7 @@ namespace Switch_Toolbox.Library
|
||||
if (mipLevel != 0)
|
||||
mipSize += (uint)(surfOut.surfSize + dataAlignBytes.Length);
|
||||
|
||||
byte[] SwizzledData = GX2.swizzle(width_, height_, surfOut.depth, surfOut.height, (uint)Format, surfOut.tileMode, s,
|
||||
byte[] SwizzledData = GX2.swizzle(width_, height_, surfOut.depth, surfOut.height, (uint)Format, surfOut.tileMode, swizzleValue,
|
||||
surfOut.pitch, surfOut.bpp, data_, DepthLevel);
|
||||
|
||||
Swizzled.Add(dataAlignBytes.Concat(SwizzledData).ToArray());
|
||||
@ -715,6 +722,11 @@ namespace Switch_Toolbox.Library
|
||||
return (n + d - 1) / d;
|
||||
}
|
||||
|
||||
private static uint powTwoAlign_0(uint x, uint align)
|
||||
{
|
||||
return (x + align - 1) & ~(align - 1);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------
|
||||
*
|
||||
@ -746,15 +758,15 @@ namespace Switch_Toolbox.Library
|
||||
public static byte[] deswizzle(uint width, uint height, uint depth, uint height_, uint format_, uint tileMode, uint swizzle_,
|
||||
uint pitch, uint bpp, byte[] data, int depthLevel)
|
||||
{
|
||||
return swizzleSurf(width, height, depth, format_, tileMode, swizzle_, pitch, bpp, data, depthLevel, 0);
|
||||
return swizzleSurf(width, height, depth, height_, format_, tileMode, swizzle_, pitch, bpp, data, depthLevel, 0);
|
||||
}
|
||||
public static byte[] swizzle(uint width, uint height, uint depth, uint height_, uint format_, uint tileMode, uint swizzle_,
|
||||
uint pitch, uint bpp, byte[] data, int depthLevel)
|
||||
{
|
||||
return swizzleSurf(width, height, depth, format_, tileMode, swizzle_, pitch, bpp, data, depthLevel, 1);
|
||||
return swizzleSurf(width, height, depth, height_, format_, tileMode, swizzle_, pitch, bpp, data, depthLevel, 1);
|
||||
}
|
||||
|
||||
private static byte[] swizzleSurf(uint width, uint height, uint depth, uint format, uint tileMode, uint swizzle_,
|
||||
private static byte[] swizzleSurf(uint width, uint height, uint depth, uint height_, uint format, uint tileMode, uint swizzle_,
|
||||
uint pitch, uint bitsPerPixel, byte[] data, int depthLevel, int swizzle)
|
||||
{
|
||||
uint bytesPerPixel = bitsPerPixel / 8;
|
||||
@ -791,7 +803,7 @@ namespace Switch_Toolbox.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = computeSurfaceAddrFromCoordMacroTiled((uint)x, (uint)y, bitsPerPixel, pitch, height, (AddrTileMode)tileMode, pipeSwizzle, bankSwizzle);
|
||||
pos = computeSurfaceAddrFromCoordMacroTiled((uint)x, (uint)y, bitsPerPixel, pitch, height_, (AddrTileMode)tileMode, pipeSwizzle, bankSwizzle);
|
||||
}
|
||||
|
||||
|
||||
@ -1019,7 +1031,7 @@ namespace Switch_Toolbox.Library
|
||||
}
|
||||
}
|
||||
|
||||
private static uint computeSurfaceBankSwappedWidth(AddrTileMode tileMode, uint bpp, uint numSamples, uint pitch)
|
||||
private static uint computeSurfaceBankSwappedWidth(AddrTileMode tileMode, uint bpp, uint pitch, uint numSamples)
|
||||
{
|
||||
if (isBankSwappedTileMode(tileMode) == 0)
|
||||
return 0;
|
||||
@ -1154,15 +1166,24 @@ namespace Switch_Toolbox.Library
|
||||
uint macroTileIndexY = y / macroTileHeight;
|
||||
ulong macroTileOffset = (macroTileIndexX + macroTilesPerRow * macroTileIndexY) * macroTileBytes;
|
||||
|
||||
if (isBankSwappedTileMode(tileMode) != 0)
|
||||
switch (tileMode)
|
||||
{
|
||||
bankSwapWidth = computeSurfaceBankSwappedWidth(tileMode, bpp, 1, pitch);
|
||||
swapIndex = macroTilePitch * macroTileIndexX / bankSwapWidth;
|
||||
bank ^= bankSwapOrder[swapIndex & 3];
|
||||
case AddrTileMode.ADDR_TM_2B_TILED_THIN1:
|
||||
case AddrTileMode.ADDR_TM_2B_TILED_THIN2:
|
||||
case AddrTileMode.ADDR_TM_2B_TILED_THIN4:
|
||||
case AddrTileMode.ADDR_TM_2B_TILED_THICK:
|
||||
case AddrTileMode.ADDR_TM_3B_TILED_THIN1:
|
||||
case AddrTileMode.ADDR_TM_3B_TILED_THICK:
|
||||
{
|
||||
bankSwapWidth = computeSurfaceBankSwappedWidth(tileMode, bpp, pitch, 1);
|
||||
swapIndex = macroTilePitch * macroTileIndexX / bankSwapWidth;
|
||||
bank ^= bankSwapOrder[swapIndex & 3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ulong totalOffset = elemOffset + ((macroTileOffset + sliceOffset) >> 3);
|
||||
return bank << 9 | pipe << 8 | totalOffset & 255 | (ulong)((int)totalOffset & -256) << 3;
|
||||
return bank << 9 | pipe << 8 | 255 & totalOffset | (ulong)((int)totalOffset & -256) << 3;
|
||||
}
|
||||
|
||||
public static uint computeSurfaceMipLevelTileMode(uint baseTileMode, uint bpp, uint level, uint width, uint height,
|
||||
@ -1210,79 +1231,83 @@ namespace Switch_Toolbox.Library
|
||||
if (DebugSurface)
|
||||
Console.WriteLine("computeSurfaceMipLevelTileMode expTileMode " + expTileMode);
|
||||
|
||||
if (noRecursive != 0 || level == 0)
|
||||
return expTileMode;
|
||||
|
||||
switch (bpp)
|
||||
if (noRecursive == 0)
|
||||
{
|
||||
case 24:
|
||||
case 48:
|
||||
case 96:
|
||||
bpp /= 3;
|
||||
break;
|
||||
switch (bpp)
|
||||
{
|
||||
case 24:
|
||||
case 48:
|
||||
case 96:
|
||||
bpp /= 3;
|
||||
break;
|
||||
}
|
||||
|
||||
widtha = nextPow2(width);
|
||||
heighta = nextPow2(height);
|
||||
numSlicesa = nextPow2(numSlices);
|
||||
|
||||
if (level != 0)
|
||||
{
|
||||
expTileMode = convertToNonBankSwappedMode((AddrTileMode)expTileMode);
|
||||
thickness = computeSurfaceThickness((AddrTileMode)expTileMode);
|
||||
microTileBytes = (numSamples * bpp * (thickness << 6) + 7) >> 3;
|
||||
|
||||
if (microTileBytes < 256)
|
||||
{
|
||||
widthAlignFactor = Math.Max(1, 256 / microTileBytes);
|
||||
}
|
||||
if (expTileMode == 4 || expTileMode == 12)
|
||||
{
|
||||
if ((widtha < widthAlignFactor * macroTileWidth) || heighta < macroTileHeight)
|
||||
expTileMode = 2;
|
||||
}
|
||||
else if (expTileMode == 5)
|
||||
{
|
||||
macroTileWidth = 16;
|
||||
macroTileHeight = 32;
|
||||
|
||||
if ((widtha < widthAlignFactor * macroTileWidth) || heighta < macroTileHeight)
|
||||
expTileMode = 2;
|
||||
}
|
||||
else if (expTileMode == 6)
|
||||
{
|
||||
macroTileWidth = 8;
|
||||
macroTileHeight = 64;
|
||||
|
||||
if ((widtha < widthAlignFactor * macroTileWidth) || heighta < macroTileHeight)
|
||||
expTileMode = 2;
|
||||
}
|
||||
else if (expTileMode == 7 || expTileMode == 13)
|
||||
{
|
||||
if ((widtha < widthAlignFactor * macroTileWidth) || heighta < macroTileHeight)
|
||||
expTileMode = 3;
|
||||
}
|
||||
|
||||
if (numSlicesa < 4)
|
||||
{
|
||||
if (expTileMode == 3)
|
||||
expTileMode = 2;
|
||||
else if (expTileMode == 7)
|
||||
expTileMode = 4;
|
||||
else if (expTileMode == 13)
|
||||
expTileMode = 12;
|
||||
}
|
||||
|
||||
return computeSurfaceMipLevelTileMode(
|
||||
expTileMode,
|
||||
bpp,
|
||||
level,
|
||||
widtha,
|
||||
heighta,
|
||||
numSlicesa,
|
||||
numSamples,
|
||||
isDepth,
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
widtha = nextPow2(width);
|
||||
heighta = nextPow2(height);
|
||||
numSlicesa = nextPow2(numSlices);
|
||||
|
||||
expTileMode = convertToNonBankSwappedMode((AddrTileMode)expTileMode);
|
||||
thickness = computeSurfaceThickness((AddrTileMode)expTileMode);
|
||||
microTileBytes = (numSamples * bpp * (thickness << 6) + 7) >> 3;
|
||||
|
||||
if (microTileBytes < 256)
|
||||
{
|
||||
widthAlignFactor = Math.Max(1, 256 / microTileBytes);
|
||||
}
|
||||
if (expTileMode == 4 || expTileMode == 12)
|
||||
{
|
||||
if ((widtha < widthAlignFactor * macroTileWidth) || heighta < macroTileHeight)
|
||||
expTileMode = 2;
|
||||
}
|
||||
else if (expTileMode == 5)
|
||||
{
|
||||
macroTileWidth = 16;
|
||||
macroTileHeight = 32;
|
||||
|
||||
if ((widtha < widthAlignFactor * macroTileWidth) || heighta < macroTileHeight)
|
||||
expTileMode = 2;
|
||||
}
|
||||
else if (expTileMode == 6)
|
||||
{
|
||||
macroTileWidth = 8;
|
||||
macroTileHeight = 64;
|
||||
|
||||
if ((widtha < widthAlignFactor * macroTileWidth) || heighta < macroTileHeight)
|
||||
expTileMode = 2;
|
||||
}
|
||||
else if (expTileMode == 7 || expTileMode == 13)
|
||||
{
|
||||
if ((widtha < widthAlignFactor * macroTileWidth) || heighta < macroTileHeight)
|
||||
expTileMode = 3;
|
||||
}
|
||||
|
||||
if (numSlicesa < 4)
|
||||
{
|
||||
if (expTileMode == 3)
|
||||
expTileMode = 2;
|
||||
else if (expTileMode == 7)
|
||||
expTileMode = 4;
|
||||
else if (expTileMode == 13)
|
||||
expTileMode = 12;
|
||||
}
|
||||
|
||||
return computeSurfaceMipLevelTileMode(
|
||||
expTileMode,
|
||||
bpp,
|
||||
level,
|
||||
widtha,
|
||||
heighta,
|
||||
numSlicesa,
|
||||
numSamples,
|
||||
isDepth,
|
||||
1);
|
||||
return expTileMode;
|
||||
}
|
||||
|
||||
private static uint computeSurfaceTileSlices(uint tileMode, uint bpp, uint numSamples)
|
||||
{
|
||||
uint bytePerSample = ((bpp << 6) + 7) >> 3;
|
||||
@ -1302,6 +1327,11 @@ namespace Switch_Toolbox.Library
|
||||
return tileSlices;
|
||||
}
|
||||
|
||||
private static int getFillSizeFieldsFlags()
|
||||
{
|
||||
return (m_configFlags >> 6) & 1;
|
||||
}
|
||||
|
||||
private static uint ComputeSurfaceInfoEx()
|
||||
{
|
||||
uint tileMode = pIn.tileMode;
|
||||
@ -1551,6 +1581,7 @@ namespace Switch_Toolbox.Library
|
||||
tileMode,
|
||||
padDims,
|
||||
(flags.value >> 4) & 1,
|
||||
(flags.value >> 7) & 1,
|
||||
pitchAlign,
|
||||
heightAlign,
|
||||
microTileThickness);
|
||||
@ -1789,6 +1820,7 @@ namespace Switch_Toolbox.Library
|
||||
expTileMode,
|
||||
padDims,
|
||||
(flags.value >> 4) & 1,
|
||||
(flags.value >> 7) & 1,
|
||||
pitchAlign,
|
||||
heightAlign,
|
||||
microTileThickness);
|
||||
@ -1816,7 +1848,14 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
return new uint[] { valid, pPitchOut, pHeightOut, pNumSlicesOut, pSurfSize, pTileModeOut, pBaseAlign, pPitchAlign, pHeightAlign, pDepthAlign };
|
||||
}
|
||||
private static Tuple<uint, uint, uint> padDimensions(uint tileMode, uint padDims, uint isCube, uint pitchAlign, uint heightAlign, uint sliceAlign)
|
||||
private static uint IsPow2(uint dim)
|
||||
{
|
||||
if ((dim & (dim - 1)) == 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
private static Tuple<uint, uint, uint> padDimensions(uint tileMode, uint padDims, uint isCube, uint cubeAsArray, uint pitchAlign, uint heightAlign, uint sliceAlign)
|
||||
{
|
||||
uint thickness = computeSurfaceThickness((AddrTileMode)tileMode);
|
||||
if (padDims == 0)
|
||||
@ -1826,7 +1865,7 @@ namespace Switch_Toolbox.Library
|
||||
expPitch = powTwoAlign(expPitch, pitchAlign);
|
||||
else
|
||||
{
|
||||
expPitch += pitchAlign - 1;
|
||||
expPitch = pitchAlign + expPitch - 1;
|
||||
expPitch /= pitchAlign;
|
||||
expPitch *= pitchAlign;
|
||||
}
|
||||
@ -1836,7 +1875,7 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
if (padDims > 2 || thickness > 1)
|
||||
{
|
||||
if (isCube != 0)
|
||||
if (isCube != 0 || cubeAsArray != 0)
|
||||
expNumSlices = nextPow2(expNumSlices);
|
||||
|
||||
if (thickness > 1)
|
||||
@ -1901,7 +1940,7 @@ namespace Switch_Toolbox.Library
|
||||
macroWidth = tup.Item4;
|
||||
macroHeight = tup.Item5;
|
||||
|
||||
bankSwappedWidth = computeSurfaceBankSwappedWidth((AddrTileMode)tileMode, bpp, numSamples, pitch);
|
||||
bankSwappedWidth = computeSurfaceBankSwappedWidth((AddrTileMode)tileMode, bpp, pitch, numSamples);
|
||||
|
||||
if (bankSwappedWidth > pitchAlign)
|
||||
pitchAlign = bankSwappedWidth;
|
||||
@ -1910,6 +1949,7 @@ namespace Switch_Toolbox.Library
|
||||
tileMode,
|
||||
padDims,
|
||||
(flags.value >> 4) & 1,
|
||||
(flags.value >> 7) & 1,
|
||||
pitchAlign,
|
||||
heightAlign,
|
||||
microTileThickness);
|
||||
@ -1987,7 +2027,7 @@ namespace Switch_Toolbox.Library
|
||||
macroWidth = tup.Item4;
|
||||
macroHeight = tup.Item5;
|
||||
|
||||
bankSwappedWidth = computeSurfaceBankSwappedWidth((AddrTileMode)tileMode, bpp, numSamples, pitch);
|
||||
bankSwappedWidth = computeSurfaceBankSwappedWidth((AddrTileMode)tileMode, bpp, pitch, numSamples);
|
||||
if (bankSwappedWidth > pitchAlign)
|
||||
pitchAlign = bankSwappedWidth;
|
||||
|
||||
@ -1995,6 +2035,7 @@ namespace Switch_Toolbox.Library
|
||||
tileMode,
|
||||
padDims,
|
||||
(flags.value >> 4) & 1,
|
||||
(flags.value >> 7) & 1,
|
||||
pitchAlign,
|
||||
heightAlign,
|
||||
microTileThickness);
|
||||
@ -2082,7 +2123,7 @@ namespace Switch_Toolbox.Library
|
||||
private static uint adjustPitchAlignment(Flags flags, uint pitchAlign)
|
||||
{
|
||||
if (((flags.value >> 13) & 1) != 0)
|
||||
pitchAlign = powTwoAlign(pitchAlign, 0x20);
|
||||
pitchAlign = powTwoAlign_0(pitchAlign, 0x20);
|
||||
|
||||
return pitchAlign;
|
||||
}
|
||||
@ -2163,6 +2204,10 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
return 0;
|
||||
}
|
||||
private static uint useTileIndex(int index)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
private static void computeMipLevel()
|
||||
{
|
||||
uint slices = 0;
|
||||
@ -2346,7 +2391,10 @@ namespace Switch_Toolbox.Library
|
||||
else
|
||||
blockSize = 4;
|
||||
|
||||
width = (uint)(~(blockSize - 1) & (Math.Max(1, surfaceWidth >> level) + blockSize - 1));
|
||||
width = (uint)(~(blockSize - 1) & ((surfaceWidth >> level) + blockSize - 1));
|
||||
|
||||
if (hwFormat == 0x35)
|
||||
return pSurfOut;
|
||||
|
||||
pSurfOut.bpp = formatHwInfo[hwFormat * 4];
|
||||
pSurfOut.size = 96;
|
||||
@ -2363,7 +2411,7 @@ namespace Switch_Toolbox.Library
|
||||
pSurfOut.height = 1;
|
||||
pSurfOut.depth = 1;
|
||||
}
|
||||
else if (dim == 1 || dim == 6)
|
||||
else if (dim == 1)
|
||||
{
|
||||
pSurfOut.height = Math.Max(1, surfaceHeight >> level);
|
||||
pSurfOut.depth = 1;
|
||||
@ -2383,15 +2431,19 @@ namespace Switch_Toolbox.Library
|
||||
pSurfOut.height = 1;
|
||||
pSurfOut.depth = surfaceDepth;
|
||||
}
|
||||
else if (dim == 5 || dim == 7)
|
||||
else if (dim == 5)
|
||||
{
|
||||
pSurfOut.height = Math.Max(1, surfaceHeight >> level);
|
||||
pSurfOut.depth = surfaceDepth;
|
||||
}
|
||||
|
||||
pSurfOut.pixelPitch = width;
|
||||
pSurfOut.pixelHeight = (uint)(~(blockSize - 1) & (pSurfOut.height + blockSize - 1));
|
||||
pSurfOut.height = (uint)(pSurfOut.pixelHeight / blockSize);
|
||||
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.surfSize = pSurfOut.bpp * numSamples * pSurfOut.depth * pSurfOut.height * pSurfOut.pitch >> 3;
|
||||
|
||||
if (surfaceDim == 2)
|
||||
@ -2419,7 +2471,7 @@ namespace Switch_Toolbox.Library
|
||||
aSurfIn.height = 1;
|
||||
aSurfIn.numSlices = 1;
|
||||
}
|
||||
else if (dim == 1 || dim == 6)
|
||||
else if (dim == 1)
|
||||
{
|
||||
aSurfIn.height = (uint)Math.Max(1, surfaceHeight >> level);
|
||||
aSurfIn.numSlices = 1;
|
||||
@ -2440,7 +2492,17 @@ namespace Switch_Toolbox.Library
|
||||
aSurfIn.height = 1;
|
||||
aSurfIn.numSlices = (uint)surfaceDepth;
|
||||
}
|
||||
else if (dim == 5 || dim == 7)
|
||||
else if (dim == 5)
|
||||
{
|
||||
aSurfIn.height = (uint)Math.Max(1, surfaceHeight >> level);
|
||||
aSurfIn.numSlices = (uint)surfaceDepth;
|
||||
}
|
||||
else if (dim == 6)
|
||||
{
|
||||
aSurfIn.height = (uint)Math.Max(1, surfaceHeight >> level);
|
||||
aSurfIn.numSlices = 1;
|
||||
}
|
||||
else if (dim == 7)
|
||||
{
|
||||
aSurfIn.height = (uint)Math.Max(1, surfaceHeight >> level);
|
||||
aSurfIn.numSlices = (uint)surfaceDepth;
|
||||
@ -2462,9 +2524,6 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
pSurfOut = pOut;
|
||||
}
|
||||
if (pSurfOut.tileMode == 0)
|
||||
pSurfOut.tileMode = 16;
|
||||
|
||||
return pSurfOut;
|
||||
}
|
||||
}
|
||||
|
2595
Switch_Toolbox_Library/Swizzling/NewSwizzleCodeBackup.cs
Normal file
2595
Switch_Toolbox_Library/Swizzling/NewSwizzleCodeBackup.cs
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user