1
0
mirror of synced 2024-11-12 10:10:50 +01:00

Rename GTX class to GX2

This commit is contained in:
KillzXGaming 2019-04-06 15:58:20 -04:00
parent fba66217d1
commit 4865ca1a8f
14 changed files with 126 additions and 126 deletions

Binary file not shown.

View File

@ -287,7 +287,7 @@ namespace Bfres.Structs
} }
//We reuse GX2 data as it's the same thing //We reuse GX2 data as it's the same thing
public Texture FromGx2Surface(GTX.GX2Surface surf, GTXImporterSettings settings) public Texture FromGx2Surface(GX2.GX2Surface surf, GTXImporterSettings settings)
{ {
Texture tex = new Texture(); Texture tex = new Texture();
tex.Name = settings.TexName; tex.Name = settings.TexName;
@ -364,9 +364,9 @@ namespace Bfres.Structs
format = (int)texture.Format; format = (int)texture.Format;
int swizzle = (int)texture.Swizzle; int swizzle = (int)texture.Swizzle;
int pitch = (int)texture.Pitch; int pitch = (int)texture.Pitch;
uint bpp = GTX.surfaceGetBitsPerPixel((uint)format) >> 3; uint bpp = GX2.surfaceGetBitsPerPixel((uint)format) >> 3;
GTX.GX2Surface surf = new GTX.GX2Surface(); GX2.GX2Surface surf = new GX2.GX2Surface();
surf.bpp = bpp; surf.bpp = bpp;
surf.height = texture.Height; surf.height = texture.Height;
surf.width = texture.Width; surf.width = texture.Width;
@ -428,7 +428,7 @@ namespace Bfres.Structs
if (surf.mipData == null) if (surf.mipData == null)
surf.numMips = 1; surf.numMips = 1;
var surfaces = GTX.Decode(surf); var surfaces = GX2.Decode(surf);
if (ArrayLevel >= surfaces.Count) if (ArrayLevel >= surfaces.Count)
throw new Exception("Invalid amount of surfaces decoded!"); throw new Exception("Invalid amount of surfaces decoded!");

View File

@ -633,68 +633,68 @@ namespace FirstPlugin
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0) public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
{ {
uint GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC5_UNORM; uint GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC5_UNORM;
switch (SurfFormat) switch (SurfFormat)
{ {
case SurfaceFormat.T_BC1_UNORM: case SurfaceFormat.T_BC1_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC1_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC1_UNORM;
Format = TEX_FORMAT.BC1_UNORM; Format = TEX_FORMAT.BC1_UNORM;
break; break;
case SurfaceFormat.T_BC1_SRGB: case SurfaceFormat.T_BC1_SRGB:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC1_SRGB; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC1_SRGB;
Format = TEX_FORMAT.BC1_UNORM_SRGB; Format = TEX_FORMAT.BC1_UNORM_SRGB;
break; break;
case SurfaceFormat.T_BC2_UNORM: case SurfaceFormat.T_BC2_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC2_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC2_UNORM;
Format = TEX_FORMAT.BC2_UNORM; Format = TEX_FORMAT.BC2_UNORM;
break; break;
case SurfaceFormat.T_BC2_SRGB: case SurfaceFormat.T_BC2_SRGB:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC2_SRGB; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC2_SRGB;
Format = TEX_FORMAT.BC2_UNORM_SRGB; Format = TEX_FORMAT.BC2_UNORM_SRGB;
break; break;
case SurfaceFormat.T_BC3_UNORM: case SurfaceFormat.T_BC3_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC3_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC3_UNORM;
Format = TEX_FORMAT.BC3_UNORM; Format = TEX_FORMAT.BC3_UNORM;
break; break;
case SurfaceFormat.T_BC3_SRGB: case SurfaceFormat.T_BC3_SRGB:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC3_SRGB; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC3_SRGB;
Format = TEX_FORMAT.BC3_UNORM_SRGB; Format = TEX_FORMAT.BC3_UNORM_SRGB;
break; break;
case SurfaceFormat.T_BC4_UNORM: case SurfaceFormat.T_BC4_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC4_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC4_UNORM;
Format = TEX_FORMAT.BC4_UNORM; Format = TEX_FORMAT.BC4_UNORM;
break; break;
case SurfaceFormat.T_BC4_SNORM: case SurfaceFormat.T_BC4_SNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC4_SNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC4_SNORM;
Format = TEX_FORMAT.BC4_SNORM; Format = TEX_FORMAT.BC4_SNORM;
break; break;
case SurfaceFormat.T_BC5_UNORM: case SurfaceFormat.T_BC5_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC5_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC5_UNORM;
Format = TEX_FORMAT.BC5_UNORM; Format = TEX_FORMAT.BC5_UNORM;
break; break;
case SurfaceFormat.T_BC5_SNORM: case SurfaceFormat.T_BC5_SNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC5_SNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC5_SNORM;
Format = TEX_FORMAT.BC5_SNORM; Format = TEX_FORMAT.BC5_SNORM;
break; break;
case SurfaceFormat.TC_R8_G8_UNORM: case SurfaceFormat.TC_R8_G8_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.TC_R8_G8_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TC_R8_G8_UNORM;
Format = TEX_FORMAT.R8G8_UNORM; Format = TEX_FORMAT.R8G8_UNORM;
break; break;
case SurfaceFormat.TCS_R8_G8_B8_A8_UNORM: case SurfaceFormat.TCS_R8_G8_B8_A8_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM;
Format = TEX_FORMAT.R8G8B8A8_UNORM; Format = TEX_FORMAT.R8G8B8A8_UNORM;
break; break;
case SurfaceFormat.TCS_R8_G8_B8_A8: case SurfaceFormat.TCS_R8_G8_B8_A8:
GX2Format = (uint)GTX.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM;
Format = TEX_FORMAT.R8G8B8A8_UNORM; Format = TEX_FORMAT.R8G8B8A8_UNORM;
break; break;
case SurfaceFormat.TC_R8_UNORM: case SurfaceFormat.TC_R8_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.TC_R8_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TC_R8_UNORM;
Format = TEX_FORMAT.R8_UNORM; Format = TEX_FORMAT.R8_UNORM;
break; break;
case SurfaceFormat.TCS_R5_G6_B5_UNORM: case SurfaceFormat.TCS_R5_G6_B5_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.TCS_R5_G6_B5_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TCS_R5_G6_B5_UNORM;
Format = TEX_FORMAT.B5G6R5_UNORM; Format = TEX_FORMAT.B5G6R5_UNORM;
break; break;
default: default:
@ -704,9 +704,9 @@ namespace FirstPlugin
int swizzle = (int)Swizzle; int swizzle = (int)Swizzle;
int pitch = (int)0; int pitch = (int)0;
uint bpp = GTX.surfaceGetBitsPerPixel(GX2Format) >> 3; uint bpp = GX2.surfaceGetBitsPerPixel(GX2Format) >> 3;
GTX.GX2Surface surf = new GTX.GX2Surface(); GX2.GX2Surface surf = new GX2.GX2Surface();
surf.bpp = bpp; surf.bpp = bpp;
surf.height = Height; surf.height = Height;
surf.width = Width; surf.width = Width;
@ -725,7 +725,7 @@ namespace FirstPlugin
surf.swizzle = Swizzle; surf.swizzle = Swizzle;
surf.imageSize = ImageSize; surf.imageSize = ImageSize;
var surfaces = GTX.Decode(surf); var surfaces = GX2.Decode(surf);
return surfaces[ArrayLevel][MipLevel]; return surfaces[ArrayLevel][MipLevel];
} }
@ -1273,68 +1273,68 @@ namespace FirstPlugin
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0) public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
{ {
uint GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC5_UNORM; uint GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC5_UNORM;
switch (SurfFormat) switch (SurfFormat)
{ {
case SurfaceFormat.T_BC1_UNORM: case SurfaceFormat.T_BC1_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC1_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC1_UNORM;
Format = TEX_FORMAT.BC1_UNORM; Format = TEX_FORMAT.BC1_UNORM;
break; break;
case SurfaceFormat.T_BC1_SRGB: case SurfaceFormat.T_BC1_SRGB:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC1_SRGB; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC1_SRGB;
Format = TEX_FORMAT.BC1_UNORM_SRGB; Format = TEX_FORMAT.BC1_UNORM_SRGB;
break; break;
case SurfaceFormat.T_BC2_UNORM: case SurfaceFormat.T_BC2_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC2_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC2_UNORM;
Format = TEX_FORMAT.BC2_UNORM; Format = TEX_FORMAT.BC2_UNORM;
break; break;
case SurfaceFormat.T_BC2_SRGB: case SurfaceFormat.T_BC2_SRGB:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC2_SRGB; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC2_SRGB;
Format = TEX_FORMAT.BC2_UNORM_SRGB; Format = TEX_FORMAT.BC2_UNORM_SRGB;
break; break;
case SurfaceFormat.T_BC3_UNORM: case SurfaceFormat.T_BC3_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC3_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC3_UNORM;
Format = TEX_FORMAT.BC3_UNORM; Format = TEX_FORMAT.BC3_UNORM;
break; break;
case SurfaceFormat.T_BC3_SRGB: case SurfaceFormat.T_BC3_SRGB:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC3_SRGB; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC3_SRGB;
Format = TEX_FORMAT.BC3_UNORM_SRGB; Format = TEX_FORMAT.BC3_UNORM_SRGB;
break; break;
case SurfaceFormat.T_BC4_UNORM: case SurfaceFormat.T_BC4_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC4_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC4_UNORM;
Format = TEX_FORMAT.BC4_UNORM; Format = TEX_FORMAT.BC4_UNORM;
break; break;
case SurfaceFormat.T_BC4_SNORM: case SurfaceFormat.T_BC4_SNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC4_SNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC4_SNORM;
Format = TEX_FORMAT.BC4_SNORM; Format = TEX_FORMAT.BC4_SNORM;
break; break;
case SurfaceFormat.T_BC5_UNORM: case SurfaceFormat.T_BC5_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC5_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC5_UNORM;
Format = TEX_FORMAT.BC5_UNORM; Format = TEX_FORMAT.BC5_UNORM;
break; break;
case SurfaceFormat.T_BC5_SNORM: case SurfaceFormat.T_BC5_SNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.T_BC5_SNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC5_SNORM;
Format = TEX_FORMAT.BC5_SNORM; Format = TEX_FORMAT.BC5_SNORM;
break; break;
case SurfaceFormat.TC_R8_G8_UNORM: case SurfaceFormat.TC_R8_G8_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.TC_R8_G8_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TC_R8_G8_UNORM;
Format = TEX_FORMAT.R8G8_UNORM; Format = TEX_FORMAT.R8G8_UNORM;
break; break;
case SurfaceFormat.TCS_R8_G8_B8_A8_UNORM: case SurfaceFormat.TCS_R8_G8_B8_A8_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM;
Format = TEX_FORMAT.R8G8B8A8_UNORM; Format = TEX_FORMAT.R8G8B8A8_UNORM;
break; break;
case SurfaceFormat.TCS_R8_G8_B8_A8: case SurfaceFormat.TCS_R8_G8_B8_A8:
GX2Format = (uint)GTX.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM;
Format = TEX_FORMAT.R8G8B8A8_UNORM; Format = TEX_FORMAT.R8G8B8A8_UNORM;
break; break;
case SurfaceFormat.TC_R8_UNORM: case SurfaceFormat.TC_R8_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.TC_R8_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TC_R8_UNORM;
Format = TEX_FORMAT.R8_UNORM; Format = TEX_FORMAT.R8_UNORM;
break; break;
case SurfaceFormat.TCS_R5_G6_B5_UNORM: case SurfaceFormat.TCS_R5_G6_B5_UNORM:
GX2Format = (uint)GTX.GX2SurfaceFormat.TCS_R5_G6_B5_UNORM; GX2Format = (uint)GX2.GX2SurfaceFormat.TCS_R5_G6_B5_UNORM;
Format = TEX_FORMAT.B5G6R5_UNORM; Format = TEX_FORMAT.B5G6R5_UNORM;
break; break;
default: default:
@ -1344,9 +1344,9 @@ namespace FirstPlugin
int swizzle = (int)Swizzle; int swizzle = (int)Swizzle;
int pitch = (int)0; int pitch = (int)0;
uint bpp = GTX.surfaceGetBitsPerPixel(GX2Format) >> 3; uint bpp = GX2.surfaceGetBitsPerPixel(GX2Format) >> 3;
GTX.GX2Surface surf = new GTX.GX2Surface(); GX2.GX2Surface surf = new GX2.GX2Surface();
surf.bpp = bpp; surf.bpp = bpp;
surf.height = Height; surf.height = Height;
surf.width = Width; surf.width = Width;
@ -1365,7 +1365,7 @@ namespace FirstPlugin
surf.swizzle = Swizzle; surf.swizzle = Swizzle;
surf.imageSize = ImageSize; surf.imageSize = ImageSize;
var surfaces = GTX.Decode(surf); var surfaces = GX2.Decode(surf);
return surfaces[ArrayLevel][MipLevel]; return surfaces[ArrayLevel][MipLevel];
} }

View File

@ -346,26 +346,26 @@ namespace FirstPlugin
{ {
uint bpp = GetBytesPerPixel(Format); uint bpp = GetBytesPerPixel(Format);
GTX.GX2Surface surf = new GTX.GX2Surface(); GX2.GX2Surface surf = new GX2.GX2Surface();
surf.bpp = bpp; surf.bpp = bpp;
surf.height = image.Height; surf.height = image.Height;
surf.width = image.Width; surf.width = image.Width;
surf.aa = (uint)GTX.GX2AAMode.GX2_AA_MODE_1X; surf.aa = (uint)GX2.GX2AAMode.GX2_AA_MODE_1X;
surf.alignment = image.Alignment; surf.alignment = image.Alignment;
surf.depth = 1; surf.depth = 1;
surf.dim = (uint)GTX.GX2SurfaceDimension.DIM_2D; surf.dim = (uint)GX2.GX2SurfaceDimension.DIM_2D;
surf.format = (uint)FTEX.ConvertToGx2Format(Format); surf.format = (uint)FTEX.ConvertToGx2Format(Format);
surf.use = (uint)GTX.GX2SurfaceUse.USE_COLOR_BUFFER; surf.use = (uint)GX2.GX2SurfaceUse.USE_COLOR_BUFFER;
surf.pitch = 0; surf.pitch = 0;
surf.data = ImageData; surf.data = ImageData;
surf.numMips = 1; surf.numMips = 1;
surf.mipOffset = new uint[0]; surf.mipOffset = new uint[0];
surf.mipData = ImageData; surf.mipData = ImageData;
surf.tileMode = (uint)GTX.GX2TileMode.MODE_2D_TILED_THIN1; surf.tileMode = (uint)GX2.GX2TileMode.MODE_2D_TILED_THIN1;
surf.swizzle = image.swizzle; surf.swizzle = image.swizzle;
surf.numArray = 1; surf.numArray = 1;
var surfaces = GTX.Decode(surf); var surfaces = GX2.Decode(surf);
return surfaces[ArrayLevel][MipLevel]; return surfaces[ArrayLevel][MipLevel];
} }

View File

@ -226,7 +226,7 @@ namespace FirstPlugin
TextureData tex = (TextureData)node; TextureData tex = (TextureData)node;
tex.surface.data = data[curTex]; tex.surface.data = data[curTex];
tex.surface.bpp = GTX.surfaceGetBitsPerPixel(tex.surface.format) >> 3; tex.surface.bpp = GX2.surfaceGetBitsPerPixel(tex.surface.format) >> 3;
tex.Format = FTEX.ConvertFromGx2Format((Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)tex.surface.format); tex.Format = FTEX.ConvertFromGx2Format((Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)tex.surface.format);
tex.Width = tex.surface.width; tex.Width = tex.surface.width;
tex.Height = tex.surface.height; tex.Height = tex.surface.height;
@ -408,7 +408,7 @@ namespace FirstPlugin
Console.WriteLine(" mip size = " + surface.mipData.Length); Console.WriteLine(" mip size = " + surface.mipData.Length);
Console.WriteLine(" realSize = " + surface.imageSize); Console.WriteLine(" realSize = " + surface.imageSize);
var surfaces = GTX.Decode(surface); var surfaces = GX2.Decode(surface);
return surfaces[ArrayLevel][MipLevel]; return surfaces[ArrayLevel][MipLevel];
} }
@ -495,7 +495,7 @@ namespace FirstPlugin
editor.AddCustomControl(userDataEditor, typeof(UserDataEditor)); editor.AddCustomControl(userDataEditor, typeof(UserDataEditor));
} }
} }
public class SurfaceInfoParse : GTX.GX2Surface public class SurfaceInfoParse : GX2.GX2Surface
{ {
public void Read(FileReader reader) public void Read(FileReader reader)

View File

@ -10,19 +10,19 @@ namespace FirstPlugin
{ {
public class GTXSwizzle public class GTXSwizzle
{ {
public static GTX.GX2Surface CreateGx2Texture(byte[] imageData, GTXImporterSettings setting, uint tileMode, uint AAMode) public static GX2.GX2Surface CreateGx2Texture(byte[] imageData, GTXImporterSettings setting, uint tileMode, uint AAMode)
{ {
var Format = (GTX.GX2SurfaceFormat)setting.Format; var Format = (GX2.GX2SurfaceFormat)setting.Format;
Console.WriteLine("Format " + Format + " " + setting.TexName); Console.WriteLine("Format " + Format + " " + setting.TexName);
var surfOut = GTX.getSurfaceInfo(Format, setting.TexWidth, setting.TexHeight, 1, 1, tileMode, 0, 0); var surfOut = GX2.getSurfaceInfo(Format, setting.TexWidth, setting.TexHeight, 1, 1, tileMode, 0, 0);
uint imageSize = (uint)surfOut.surfSize; uint imageSize = (uint)surfOut.surfSize;
uint alignment = surfOut.baseAlign; uint alignment = surfOut.baseAlign;
uint pitch = surfOut.pitch; uint pitch = surfOut.pitch;
uint mipSize = 0; uint mipSize = 0;
uint dataSize = (uint)imageData.Length; uint dataSize = (uint)imageData.Length;
uint bpp = GTX.surfaceGetBitsPerPixel((uint)setting.Format) >> 3; uint bpp = GX2.surfaceGetBitsPerPixel((uint)setting.Format) >> 3;
int DepthLevel = 1; int DepthLevel = 1;
if (dataSize <= 0) if (dataSize <= 0)
@ -34,7 +34,7 @@ namespace FirstPlugin
uint s = (uint)(setting.swizzle << 8); uint s = (uint)(setting.swizzle << 8);
uint blkWidth, blkHeight; uint blkWidth, blkHeight;
if (GTX.IsFormatBCN(Format)) if (GX2.IsFormatBCN(Format))
{ {
blkWidth = 4; blkWidth = 4;
blkHeight = 4; blkHeight = 4;
@ -46,7 +46,7 @@ namespace FirstPlugin
} }
if (tileMode == 0) if (tileMode == 0)
tileMode = GTX.getDefaultGX2TileMode(1, setting.TexWidth, setting.TexHeight, 1,(uint)setting.Format, 0, 1); tileMode = GX2.getDefaultGX2TileMode(1, setting.TexWidth, setting.TexHeight, 1,(uint)setting.Format, 0, 1);
int tiling1dLevel = 0; int tiling1dLevel = 0;
bool tiling1dLevelSet = false; bool tiling1dLevelSet = false;
@ -78,7 +78,7 @@ namespace FirstPlugin
if (mipLevel != 0) if (mipLevel != 0)
{ {
surfOut = GTX.getSurfaceInfo(Format, setting.TexWidth, setting.TexHeight, 1, 1, tileMode, 0, mipLevel); surfOut = GX2.getSurfaceInfo(Format, setting.TexWidth, setting.TexHeight, 1, 1, tileMode, 0, mipLevel);
if (mipLevel == 1) if (mipLevel == 1)
mipOffsets.Add(imageSize); mipOffsets.Add(imageSize);
@ -92,7 +92,7 @@ namespace FirstPlugin
if (mipLevel != 0) if (mipLevel != 0)
mipSize += (uint)(surfOut.surfSize + dataAlignBytes.Length); mipSize += (uint)(surfOut.surfSize + dataAlignBytes.Length);
byte[] SwizzledData = GTX.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, s,
surfOut.pitch, surfOut.bpp, data_, DepthLevel); surfOut.pitch, surfOut.bpp, data_, DepthLevel);
Swizzled.Add(dataAlignBytes.Concat(SwizzledData).ToArray()); Swizzled.Add(dataAlignBytes.Concat(SwizzledData).ToArray());
@ -112,7 +112,7 @@ namespace FirstPlugin
else else
s |= (uint)(13 << 16); s |= (uint)(13 << 16);
GTX.GX2Surface surf = new GTX.GX2Surface(); GX2.GX2Surface surf = new GX2.GX2Surface();
surf.depth = setting.Depth; surf.depth = setting.Depth;
surf.width = setting.TexWidth; surf.width = setting.TexWidth;
surf.height = setting.TexHeight; surf.height = setting.TexHeight;

View File

@ -21,7 +21,7 @@ namespace FirstPlugin
public uint arrayLength = 1; public uint arrayLength = 1;
public List<byte[]> DataBlockOutput = new List<byte[]>(); public List<byte[]> DataBlockOutput = new List<byte[]>();
public List<byte[]> DecompressedData = new List<byte[]>(); public List<byte[]> DecompressedData = new List<byte[]>();
public GTX.GX2SurfaceFormat Format; public GX2.GX2SurfaceFormat Format;
public bool GenerateMipmaps; public bool GenerateMipmaps;
public bool IsSRGB; public bool IsSRGB;
public uint tileMode = 4; public uint tileMode = 4;
@ -51,7 +51,7 @@ namespace FirstPlugin
} }
DataBlockOutput.Add(dds.bdata); DataBlockOutput.Add(dds.bdata);
Format = (GTX.GX2SurfaceFormat)FTEX.ConvertToGx2Format(dds.Format);; Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(dds.Format);;
} }
public void LoadBitMap(Image Image, string FileName) public void LoadBitMap(Image Image, string FileName)
@ -59,7 +59,7 @@ namespace FirstPlugin
DecompressedData.Clear(); DecompressedData.Clear();
TexName = Path.GetFileNameWithoutExtension(FileName); TexName = Path.GetFileNameWithoutExtension(FileName);
Format = (GTX.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat); Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat);
GenerateMipmaps = true; GenerateMipmaps = true;
LoadImage(new Bitmap(Image)); LoadImage(new Bitmap(Image));
@ -71,7 +71,7 @@ namespace FirstPlugin
TexName = Path.GetFileNameWithoutExtension(FileName); TexName = Path.GetFileNameWithoutExtension(FileName);
Format = (GTX.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat); Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat);
GenerateMipmaps = true; GenerateMipmaps = true;
//If a texture is .tga, we need to convert it //If a texture is .tga, we need to convert it
@ -159,17 +159,17 @@ namespace FirstPlugin
FTEX.ConvertFromGx2Format((GX2SurfaceFormat)Format), alphaRef)); FTEX.ConvertFromGx2Format((GX2SurfaceFormat)Format), alphaRef));
} }
} }
public GTX.GX2Surface CreateGx2Texture(byte[] imageData) public GX2.GX2Surface CreateGx2Texture(byte[] imageData)
{ {
Console.WriteLine("Format " + Format); Console.WriteLine("Format " + Format);
var surfOut = GTX.getSurfaceInfo(Format, TexWidth, TexHeight, 1, 1, tileMode, 0, 0); var surfOut = GX2.getSurfaceInfo(Format, TexWidth, TexHeight, 1, 1, tileMode, 0, 0);
uint imageSize = (uint)surfOut.surfSize; uint imageSize = (uint)surfOut.surfSize;
uint alignment = surfOut.baseAlign; uint alignment = surfOut.baseAlign;
uint pitch = surfOut.pitch; uint pitch = surfOut.pitch;
uint mipSize = 0; uint mipSize = 0;
uint dataSize = (uint)imageData.Length; uint dataSize = (uint)imageData.Length;
uint bpp = GTX.surfaceGetBitsPerPixel((uint)Format) >> 3; uint bpp = GX2.surfaceGetBitsPerPixel((uint)Format) >> 3;
if (dataSize <= 0) if (dataSize <= 0)
throw new Exception($"Image is empty!!"); throw new Exception($"Image is empty!!");
@ -191,7 +191,7 @@ namespace FirstPlugin
break; break;
} }
uint blkWidth, blkHeight; uint blkWidth, blkHeight;
if (GTX.IsFormatBCN(Format)) if (GX2.IsFormatBCN(Format))
{ {
blkWidth = 4; blkWidth = 4;
blkHeight = 4; blkHeight = 4;
@ -231,7 +231,7 @@ namespace FirstPlugin
if (mipLevel != 0) if (mipLevel != 0)
{ {
surfOut = GTX.getSurfaceInfo(Format, TexWidth, TexHeight, 1, 1, tileMode, 0, mipLevel); surfOut = GX2.getSurfaceInfo(Format, TexWidth, TexHeight, 1, 1, tileMode, 0, mipLevel);
if (mipLevel == 1) if (mipLevel == 1)
mipOffsets.Add(imageSize); mipOffsets.Add(imageSize);
@ -245,13 +245,13 @@ namespace FirstPlugin
if (mipLevel != 0) if (mipLevel != 0)
mipSize += (uint)(surfOut.surfSize + dataAlignBytes.Length); mipSize += (uint)(surfOut.surfSize + dataAlignBytes.Length);
byte[] SwizzledData = GTX.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, s,
surfOut.pitch, surfOut.bpp, data_, 1); surfOut.pitch, surfOut.bpp, data_, 1);
Swizzled.Add(dataAlignBytes.Concat(SwizzledData).ToArray()); Swizzled.Add(dataAlignBytes.Concat(SwizzledData).ToArray());
} }
GTX.GX2Surface surf = new GTX.GX2Surface(); GX2.GX2Surface surf = new GX2.GX2Surface();
surf.depth = Depth; surf.depth = Depth;
surf.width = TexWidth; surf.width = TexWidth;
surf.height = TexHeight; surf.height = TexHeight;

View File

@ -17,59 +17,59 @@ namespace FirstPlugin
{ {
InitializeComponent(); InitializeComponent();
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.TCS_R8_G8_B8_A8_SRGB); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.TCS_R8_G8_B8_A8_SRGB);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.TCS_R10_G10_B10_A2_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.TCS_R10_G10_B10_A2_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.TCS_R5_G6_B5_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.TCS_R5_G6_B5_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.TC_R5_G5_B5_A1_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.TC_R5_G5_B5_A1_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.TC_R4_G4_B4_A4_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.TC_R4_G4_B4_A4_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.TC_R8_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.TC_R8_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.TC_R8_G8_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.TC_R8_G8_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC1_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC1_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC1_SRGB); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC1_SRGB);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC2_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC2_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC2_SRGB); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC2_SRGB);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC3_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC3_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC3_SRGB); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC3_SRGB);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC4_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC4_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC4_SNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC4_SNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC5_UNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC5_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.T_BC5_SNORM); formatComboBox.Items.Add(GX2.GX2SurfaceFormat.T_BC5_SNORM);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_DEFAULT); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_DEFAULT);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_LINEAR_ALIGNED); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_LINEAR_ALIGNED);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_1D_TILED_THIN1); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_1D_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_1D_TILED_THICK); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_1D_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_2D_TILED_THIN1); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_2D_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_2D_TILED_THIN2); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_2D_TILED_THIN2);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_2D_TILED_THIN4); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_2D_TILED_THIN4);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_2D_TILED_THICK); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_2D_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_2B_TILED_THIN1); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_2B_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_2B_TILED_THIN2); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_2B_TILED_THIN2);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_2B_TILED_THIN4); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_2B_TILED_THIN4);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_2B_TILED_THICK); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_2B_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_3D_TILED_THIN1); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_3D_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_3D_TILED_THICK); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_3D_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_3B_TILED_THIN1); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_3B_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_3B_TILED_THICK); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_3B_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_LINEAR_SPECIAL); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_LINEAR_SPECIAL);
tileModeCB.Items.Add(GTX.GX2TileMode.MODE_DEFAULT_FIX2197); tileModeCB.Items.Add(GX2.GX2TileMode.MODE_DEFAULT_FIX2197);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_1D); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_1D);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_1D_ARRAY); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_1D_ARRAY);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_2D); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_2D);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_2D_ARRAY); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_2D_ARRAY);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_2D_MSAA); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_2D_MSAA);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_2D_MSAA_ARRAY); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_2D_MSAA_ARRAY);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_3D); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_3D);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_CUBE); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_CUBE);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_FIRST); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_FIRST);
ImgDimComb.Items.Add(GTX.GX2SurfaceDimension.DIM_LAST); ImgDimComb.Items.Add(GX2.GX2SurfaceDimension.DIM_LAST);
ImgDimComb.SelectedItem = GTX.GX2SurfaceDimension.DIM_2D; ImgDimComb.SelectedItem = GX2.GX2SurfaceDimension.DIM_2D;
tileModeCB.SelectedItem = GTX.GX2TileMode.MODE_2D_TILED_THIN1; tileModeCB.SelectedItem = GX2.GX2TileMode.MODE_2D_TILED_THIN1;
formatComboBox.SelectedItem = GTX.GX2SurfaceFormat.T_BC1_SRGB; formatComboBox.SelectedItem = GX2.GX2SurfaceFormat.T_BC1_SRGB;
} }
public void LoadSupportedFormats(TEX_FORMAT[] Formats) public void LoadSupportedFormats(TEX_FORMAT[] Formats)
@ -77,11 +77,11 @@ namespace FirstPlugin
formatComboBox.Items.Clear(); formatComboBox.Items.Clear();
foreach (TEX_FORMAT format in Formats) foreach (TEX_FORMAT format in Formats)
{ {
var Gx2Format = (GTX.GX2SurfaceFormat)FTEX.ConvertToGx2Format(format); var Gx2Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(format);
formatComboBox.Items.Add(Gx2Format); formatComboBox.Items.Add(Gx2Format);
} }
var Gx2DefaultFormat = (GTX.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat); var Gx2DefaultFormat = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat);
if (formatComboBox.Items.Contains(Gx2DefaultFormat)) if (formatComboBox.Items.Contains(Gx2DefaultFormat))
formatComboBox.SelectedItem = Gx2DefaultFormat; formatComboBox.SelectedItem = Gx2DefaultFormat;
@ -113,15 +113,15 @@ namespace FirstPlugin
private Thread Thread; private Thread Thread;
public void SetupSettings() public void SetupSettings()
{ {
if (SelectedTexSettings.Format == GTX.GX2SurfaceFormat.INVALID) if (SelectedTexSettings.Format == GX2.GX2SurfaceFormat.INVALID)
return; return;
if (Thread != null && Thread.IsAlive) if (Thread != null && Thread.IsAlive)
Thread.Abort(); Thread.Abort();
if (formatComboBox.SelectedItem is GTX.GX2SurfaceFormat) if (formatComboBox.SelectedItem is GX2.GX2SurfaceFormat)
{ {
SelectedTexSettings.Format = (GTX.GX2SurfaceFormat)formatComboBox.SelectedItem; SelectedTexSettings.Format = (GX2.GX2SurfaceFormat)formatComboBox.SelectedItem;
listViewCustom1.SelectedItems[0].SubItems[1].Text = SelectedTexSettings.Format.ToString(); listViewCustom1.SelectedItems[0].SubItems[1].Text = SelectedTexSettings.Format.ToString();
} }
HeightLabel.Text = $"Height: {SelectedTexSettings.TexHeight}"; HeightLabel.Text = $"Height: {SelectedTexSettings.TexHeight}";

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Switch_Toolbox.Library namespace Switch_Toolbox.Library
{ {
public class GTX public class GX2
{ {
//Some enums and parts from https://github.com/jam1garner/Smash-Forge/blob/master/Smash%20Forge/Filetypes/Textures/GTX.cs //Some enums and parts from https://github.com/jam1garner/Smash-Forge/blob/master/Smash%20Forge/Filetypes/Textures/GTX.cs
public class GX2Surface public class GX2Surface