1
0
mirror of synced 2024-12-01 02:27:22 +01:00

More swizzle adjustments

This commit is contained in:
KillzXGaming 2019-07-14 18:59:52 -04:00
parent df1ec92e92
commit 7e89e63fe3
9 changed files with 43 additions and 12 deletions

Binary file not shown.

View File

@ -648,7 +648,7 @@ namespace FirstPlugin
(uint)surface.height,
(uint)surface.depth,
(uint)surface.format,
(uint)surface.swizzle,
(uint)0,
(uint)surface.dim,
(uint)surface.numMips
);

View File

@ -508,7 +508,17 @@ namespace Switch_Toolbox.Library.Old
Console.WriteLine("swizzle pattern " + swizzle);
uint s = (swizzle << 8);
//Since people still have swizzle issues, lets use this older swizzle method and see if it works better
uint s = 0;
if (TileMode == 1 || TileMode == 2 ||
TileMode == 3 || TileMode == 16)
{
s = swizzle << 8;
}
else
s = 0xd0000 | swizzle << 8;
Console.WriteLine("swizzle pattern s " + s);
uint blkWidth, blkHeight;
if (GX2.IsFormatBCN((GX2SurfaceFormat)Format))
@ -586,10 +596,10 @@ namespace Switch_Toolbox.Library.Old
tiling1dLevel += 1;
}
if (tiling1dLevelSet)
s |= tiling1dLevel << 16;
else
s |= 13 << 16;
// if (tiling1dLevelSet)
// s |= tiling1dLevel << 16;
// else
// s |= 13 << 16;
GX2.GX2Surface surf = new GX2.GX2Surface();
surf.depth = Depth;
@ -613,6 +623,10 @@ namespace Switch_Toolbox.Library.Old
surf.imageSize = imageSize;
surf.data = Swizzled[0];
surf.compSel = new byte[4] { 0, 1, 2, 3 };
if (surf.format == 1)
surf.compSel = new byte[4] { 0, 5, 5, 5 };
surf.texRegs = CreateRegisters(surf);
List<byte[]> mips = new List<byte[]>();

View File

@ -9,6 +9,9 @@ namespace Switch_Toolbox.Library
public class GX2TexRegisters
{
//From https://github.com/aboood40091/GTX-Extractor/blob/master/texRegisters.py
/*
Copyright © 2018 AboodXD
Licensed under GNU GPLv3*/
public static int _register0(int width, int pitch, int tileType, int tileMode, int dim)
{
return (
@ -71,8 +74,13 @@ namespace Switch_Toolbox.Library
public static uint[] CreateTexRegs(uint width, uint height, uint numMips, uint format_, uint tileMode, uint pitch, byte[] compSel)
{
if (compSel == null || compSel.Length != 4)
{
compSel = new byte[4] { 0, 1, 2, 3 };
if (format_ == 8)
compSel = new byte[4] { 0, 1, 2, 5 };
}
pitch = Math.Max(pitch, 8);
var register0 = _register0((int)width - 1, (int)(pitch / 8) - 1, 0, (int)tileMode, 1);

View File

@ -4,7 +4,6 @@ using System.Collections.Generic;
namespace Switch_Toolbox.Library
{
//Todo fix swizzle issues with this one
public class GX2
{
public const uint SwizzleMask = 0xFF00FF;
@ -451,7 +450,14 @@ namespace Switch_Toolbox.Library
Console.WriteLine("swizzle pattern " + swizzle);
uint s = (swizzle << 8);
uint s = 0;
if (TileMode == 1 || TileMode == 2 ||
TileMode == 3 || TileMode == 16)
{
s = swizzle << 8;
}
else
s = 0xd0000 | swizzle << 8;
uint blkWidth, blkHeight;
if (GX2.IsFormatBCN((GX2SurfaceFormat)Format))
@ -531,10 +537,10 @@ namespace Switch_Toolbox.Library
tiling1dLevel += 1;
}
if (tiling1dLevelSet)
s |= (uint)(tiling1dLevel << 16);
else
s |= (uint)(13 << 16);
// if (tiling1dLevelSet)
// s |= (uint)(tiling1dLevel << 16);
// else
// s |= (uint)(13 << 16);
GX2.GX2Surface surf = new GX2.GX2Surface();
surf.depth = Depth;
@ -841,6 +847,9 @@ namespace Switch_Toolbox.Library
/*---------------------------------------
*
* Code ported from AboodXD's GTX Extractor:
A Python Address Library for Wii U textures.
Copyright © 2018 AboodXD
Licensed under GNU GPLv3
* https://github.com/aboood40091/GTX-Extractor/blob/cf1a15c41630745d9a0d370bafe5760c1e5f8cbe/addrlib/addrlib_cy.pyx
*
*---------------------------------------*/