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

More gx2 reg fixes

This commit is contained in:
KillzXGaming 2019-07-14 18:13:00 -04:00
parent f84753aa11
commit ddcf80a6d7
10 changed files with 33 additions and 28 deletions

Binary file not shown.

View File

@ -593,7 +593,7 @@ namespace FirstPlugin
surface.tileMode = NewSurface.tileMode;
surface.use = NewSurface.use;
surface.width = NewSurface.width;
surface.texRegs = GX2.CreateRegisters(NewSurface);
surface.texRegs = NewSurface.texRegs;
SetChannelComponents();
}
@ -637,33 +637,26 @@ namespace FirstPlugin
surface.numMips = MipCount;
surface.mipOffset = new uint[MipCount];
try
{
//Create image block from bitmap first
var data = GenerateMipsAndCompress(bitmap, MipCount, Format);
//Create image block from bitmap first
var data = GenerateMipsAndCompress(bitmap, MipCount, Format);
//Swizzle and create surface
var NewSurface = GX2.CreateGx2Texture(data, Text,
(uint)surface.tileMode,
(uint)surface.aa,
(uint)surface.width,
(uint)surface.height,
(uint)surface.depth,
(uint)surface.format,
(uint)surface.swizzle,
(uint)surface.dim,
(uint)surface.numMips
);
//Swizzle and create surface
var NewSurface = GX2.CreateGx2Texture(data, Text,
(uint)surface.tileMode,
(uint)surface.aa,
(uint)surface.width,
(uint)surface.height,
(uint)surface.depth,
(uint)surface.format,
(uint)surface.swizzle,
(uint)surface.dim,
(uint)surface.numMips
);
ApplySurface(NewSurface);
IsEdited = true;
LoadOpenGLTexture();
LibraryGUI.UpdateViewport();
}
catch (Exception ex)
{
STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString());
}
ApplySurface(NewSurface);
IsEdited = true;
LoadOpenGLTexture();
LibraryGUI.UpdateViewport();
}
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)

View File

@ -710,6 +710,8 @@ namespace Switch_Toolbox.Library.Forms
private void UpdateEdit(Image image)
{
if (ActiveTexture.ArrayCount == 0) ActiveTexture.ArrayCount = 1;
ActiveTexture.EditedImages = new EditedBitmap[ActiveTexture.ArrayCount];
ActiveTexture.EditedImages[CurArrayDisplayLevel] = new EditedBitmap()
{
@ -751,7 +753,8 @@ namespace Switch_Toolbox.Library.Forms
if (ActiveTexture.EditedImages != null && ActiveTexture.EditedImages[CurArrayDisplayLevel] != null)
{
ActiveTexture.EditedImages[CurArrayDisplayLevel].bitmap.Dispose();
if (ActiveTexture.EditedImages[CurArrayDisplayLevel].bitmap != null)
ActiveTexture.EditedImages[CurArrayDisplayLevel].bitmap.Dispose();
ActiveTexture.EditedImages[CurArrayDisplayLevel] = null;
}
@ -1031,6 +1034,9 @@ namespace Switch_Toolbox.Library.Forms
public void SaveAndApplyImage(Bitmap image, bool DecodeBack)
{
if (image == null)
return;
if (saveBtn.InvokeRequired)
{
saveBtn.Invoke(new MethodInvoker(

View File

@ -612,6 +612,8 @@ namespace Switch_Toolbox.Library.Old
surf.alignment = alignment;
surf.imageSize = imageSize;
surf.data = Swizzled[0];
surf.compSel = new byte[4] { 0, 1, 2, 3 };
surf.texRegs = CreateRegisters(surf);
List<byte[]> mips = new List<byte[]>();
for (int mipLevel = 1; mipLevel < Swizzled.Count; mipLevel++)

View File

@ -70,6 +70,9 @@ 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 };
pitch = Math.Max(pitch, 8);
var register0 = _register0((int)width - 1, (int)(pitch / 8) - 1, 0, (int)tileMode, 1);
@ -106,7 +109,7 @@ namespace Switch_Toolbox.Library
byte[] reg3 = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(register3));
byte[] reg4 = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(register4));*/
return new uint[] { (uint)register0, (uint)register1, (uint)register2, (uint)register3, (uint)register4 };
return new uint[5] { (uint)register0, (uint)register1, (uint)register2, (uint)register3, (uint)register4 };
}
}

View File

@ -557,6 +557,7 @@ namespace Switch_Toolbox.Library
surf.alignment = alignment;
surf.imageSize = imageSize;
surf.data = Swizzled[0];
surf.texRegs = CreateRegisters(surf);
List<byte[]> mips = new List<byte[]>();
for (int mipLevel = 1; mipLevel < Swizzled.Count; mipLevel++)