More gx2 reg fixes
This commit is contained in:
parent
f84753aa11
commit
ddcf80a6d7
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -593,7 +593,7 @@ namespace FirstPlugin
|
|||||||
surface.tileMode = NewSurface.tileMode;
|
surface.tileMode = NewSurface.tileMode;
|
||||||
surface.use = NewSurface.use;
|
surface.use = NewSurface.use;
|
||||||
surface.width = NewSurface.width;
|
surface.width = NewSurface.width;
|
||||||
surface.texRegs = GX2.CreateRegisters(NewSurface);
|
surface.texRegs = NewSurface.texRegs;
|
||||||
|
|
||||||
SetChannelComponents();
|
SetChannelComponents();
|
||||||
}
|
}
|
||||||
@ -637,33 +637,26 @@ namespace FirstPlugin
|
|||||||
surface.numMips = MipCount;
|
surface.numMips = MipCount;
|
||||||
surface.mipOffset = new uint[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
|
//Swizzle and create surface
|
||||||
var NewSurface = GX2.CreateGx2Texture(data, Text,
|
var NewSurface = GX2.CreateGx2Texture(data, Text,
|
||||||
(uint)surface.tileMode,
|
(uint)surface.tileMode,
|
||||||
(uint)surface.aa,
|
(uint)surface.aa,
|
||||||
(uint)surface.width,
|
(uint)surface.width,
|
||||||
(uint)surface.height,
|
(uint)surface.height,
|
||||||
(uint)surface.depth,
|
(uint)surface.depth,
|
||||||
(uint)surface.format,
|
(uint)surface.format,
|
||||||
(uint)surface.swizzle,
|
(uint)surface.swizzle,
|
||||||
(uint)surface.dim,
|
(uint)surface.dim,
|
||||||
(uint)surface.numMips
|
(uint)surface.numMips
|
||||||
);
|
);
|
||||||
|
|
||||||
ApplySurface(NewSurface);
|
ApplySurface(NewSurface);
|
||||||
IsEdited = true;
|
IsEdited = true;
|
||||||
LoadOpenGLTexture();
|
LoadOpenGLTexture();
|
||||||
LibraryGUI.UpdateViewport();
|
LibraryGUI.UpdateViewport();
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
|
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -710,6 +710,8 @@ namespace Switch_Toolbox.Library.Forms
|
|||||||
|
|
||||||
private void UpdateEdit(Image image)
|
private void UpdateEdit(Image image)
|
||||||
{
|
{
|
||||||
|
if (ActiveTexture.ArrayCount == 0) ActiveTexture.ArrayCount = 1;
|
||||||
|
|
||||||
ActiveTexture.EditedImages = new EditedBitmap[ActiveTexture.ArrayCount];
|
ActiveTexture.EditedImages = new EditedBitmap[ActiveTexture.ArrayCount];
|
||||||
ActiveTexture.EditedImages[CurArrayDisplayLevel] = new EditedBitmap()
|
ActiveTexture.EditedImages[CurArrayDisplayLevel] = new EditedBitmap()
|
||||||
{
|
{
|
||||||
@ -751,7 +753,8 @@ namespace Switch_Toolbox.Library.Forms
|
|||||||
|
|
||||||
if (ActiveTexture.EditedImages != null && ActiveTexture.EditedImages[CurArrayDisplayLevel] != null)
|
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;
|
ActiveTexture.EditedImages[CurArrayDisplayLevel] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,6 +1034,9 @@ namespace Switch_Toolbox.Library.Forms
|
|||||||
|
|
||||||
public void SaveAndApplyImage(Bitmap image, bool DecodeBack)
|
public void SaveAndApplyImage(Bitmap image, bool DecodeBack)
|
||||||
{
|
{
|
||||||
|
if (image == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (saveBtn.InvokeRequired)
|
if (saveBtn.InvokeRequired)
|
||||||
{
|
{
|
||||||
saveBtn.Invoke(new MethodInvoker(
|
saveBtn.Invoke(new MethodInvoker(
|
||||||
|
@ -612,6 +612,8 @@ namespace Switch_Toolbox.Library.Old
|
|||||||
surf.alignment = alignment;
|
surf.alignment = alignment;
|
||||||
surf.imageSize = imageSize;
|
surf.imageSize = imageSize;
|
||||||
surf.data = Swizzled[0];
|
surf.data = Swizzled[0];
|
||||||
|
surf.compSel = new byte[4] { 0, 1, 2, 3 };
|
||||||
|
surf.texRegs = CreateRegisters(surf);
|
||||||
|
|
||||||
List<byte[]> mips = new List<byte[]>();
|
List<byte[]> mips = new List<byte[]>();
|
||||||
for (int mipLevel = 1; mipLevel < Swizzled.Count; mipLevel++)
|
for (int mipLevel = 1; mipLevel < Swizzled.Count; mipLevel++)
|
||||||
|
@ -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)
|
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);
|
pitch = Math.Max(pitch, 8);
|
||||||
var register0 = _register0((int)width - 1, (int)(pitch / 8) - 1, 0, (int)tileMode, 1);
|
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[] reg3 = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(register3));
|
||||||
byte[] reg4 = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(register4));*/
|
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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -557,6 +557,7 @@ namespace Switch_Toolbox.Library
|
|||||||
surf.alignment = alignment;
|
surf.alignment = alignment;
|
||||||
surf.imageSize = imageSize;
|
surf.imageSize = imageSize;
|
||||||
surf.data = Swizzled[0];
|
surf.data = Swizzled[0];
|
||||||
|
surf.texRegs = CreateRegisters(surf);
|
||||||
|
|
||||||
List<byte[]> mips = new List<byte[]>();
|
List<byte[]> mips = new List<byte[]>();
|
||||||
for (int mipLevel = 1; mipLevel < Swizzled.Count; mipLevel++)
|
for (int mipLevel = 1; mipLevel < Swizzled.Count; mipLevel++)
|
||||||
|
Loading…
Reference in New Issue
Block a user