2018-04-08 20:17:35 +01:00
|
|
|
using ChocolArm64.Memory;
|
|
|
|
using Ryujinx.Graphics.Gal;
|
|
|
|
using System;
|
|
|
|
|
2018-06-24 01:39:25 +01:00
|
|
|
namespace Ryujinx.HLE.Gpu.Texture
|
2018-04-08 20:17:35 +01:00
|
|
|
{
|
2018-06-09 01:15:56 +01:00
|
|
|
static class TextureReader
|
2018-04-08 20:17:35 +01:00
|
|
|
{
|
2018-06-24 01:39:25 +01:00
|
|
|
public static byte[] Read(IAMemory Memory, TextureInfo Texture)
|
2018-04-08 20:17:35 +01:00
|
|
|
{
|
|
|
|
switch (Texture.Format)
|
|
|
|
{
|
2018-07-13 01:27:59 +01:00
|
|
|
case GalTextureFormat.R32G32B32A32: return Read16Bpp (Memory, Texture);
|
|
|
|
case GalTextureFormat.R16G16B16A16: return Read8Bpp (Memory, Texture);
|
2018-08-27 15:18:21 +01:00
|
|
|
case GalTextureFormat.R32G32: return Read8Bpp (Memory, Texture);
|
2018-07-13 01:27:59 +01:00
|
|
|
case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture);
|
2018-07-29 05:41:02 +01:00
|
|
|
case GalTextureFormat.A2B10G10R10: return Read4Bpp (Memory, Texture);
|
2018-07-13 01:27:59 +01:00
|
|
|
case GalTextureFormat.R32: return Read4Bpp (Memory, Texture);
|
2018-07-19 00:26:28 +01:00
|
|
|
case GalTextureFormat.BF10GF11RF11: return Read4Bpp (Memory, Texture);
|
2018-07-19 00:19:37 +01:00
|
|
|
case GalTextureFormat.Z24S8: return Read4Bpp (Memory, Texture);
|
2018-07-13 01:27:59 +01:00
|
|
|
case GalTextureFormat.A1B5G5R5: return Read5551 (Memory, Texture);
|
|
|
|
case GalTextureFormat.B5G6R5: return Read565 (Memory, Texture);
|
2018-08-20 02:25:26 +01:00
|
|
|
case GalTextureFormat.A4B4G4R4: return Read2Bpp (Memory, Texture);
|
2018-07-13 01:27:59 +01:00
|
|
|
case GalTextureFormat.G8R8: return Read2Bpp (Memory, Texture);
|
|
|
|
case GalTextureFormat.R16: return Read2Bpp (Memory, Texture);
|
|
|
|
case GalTextureFormat.R8: return Read1Bpp (Memory, Texture);
|
2018-07-16 19:09:34 +01:00
|
|
|
case GalTextureFormat.BC6H_SF16: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
|
|
|
case GalTextureFormat.BC6H_UF16: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
2018-07-13 01:27:59 +01:00
|
|
|
case GalTextureFormat.BC7U: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
|
|
|
case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture);
|
|
|
|
case GalTextureFormat.BC2: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
|
|
|
case GalTextureFormat.BC3: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
|
|
|
case GalTextureFormat.BC4: return Read8Bpt4x4 (Memory, Texture);
|
|
|
|
case GalTextureFormat.BC5: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
|
|
|
case GalTextureFormat.ZF32: return Read4Bpp (Memory, Texture);
|
|
|
|
case GalTextureFormat.Astc2D4x4: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
|
|
|
case GalTextureFormat.Astc2D5x5: return Read16BptCompressedTexture(Memory, Texture, 5, 5);
|
|
|
|
case GalTextureFormat.Astc2D6x6: return Read16BptCompressedTexture(Memory, Texture, 6, 6);
|
|
|
|
case GalTextureFormat.Astc2D8x8: return Read16BptCompressedTexture(Memory, Texture, 8, 8);
|
2018-07-14 17:08:39 +01:00
|
|
|
case GalTextureFormat.Astc2D10x10: return Read16BptCompressedTexture(Memory, Texture, 10, 10);
|
2018-07-13 01:27:59 +01:00
|
|
|
case GalTextureFormat.Astc2D12x12: return Read16BptCompressedTexture(Memory, Texture, 12, 12);
|
|
|
|
case GalTextureFormat.Astc2D5x4: return Read16BptCompressedTexture(Memory, Texture, 5, 4);
|
|
|
|
case GalTextureFormat.Astc2D6x5: return Read16BptCompressedTexture(Memory, Texture, 6, 5);
|
|
|
|
case GalTextureFormat.Astc2D8x6: return Read16BptCompressedTexture(Memory, Texture, 8, 6);
|
|
|
|
case GalTextureFormat.Astc2D10x8: return Read16BptCompressedTexture(Memory, Texture, 10, 8);
|
|
|
|
case GalTextureFormat.Astc2D12x10: return Read16BptCompressedTexture(Memory, Texture, 12, 10);
|
|
|
|
case GalTextureFormat.Astc2D8x5: return Read16BptCompressedTexture(Memory, Texture, 8, 5);
|
|
|
|
case GalTextureFormat.Astc2D10x5: return Read16BptCompressedTexture(Memory, Texture, 10, 5);
|
|
|
|
case GalTextureFormat.Astc2D10x6: return Read16BptCompressedTexture(Memory, Texture, 10, 6);
|
2018-07-19 00:19:37 +01:00
|
|
|
}
|
2018-04-08 20:17:35 +01:00
|
|
|
|
2018-08-17 00:47:36 +01:00
|
|
|
throw new NotImplementedException("0x" + Texture.Format.ToString("x2"));
|
2018-04-08 20:17:35 +01:00
|
|
|
}
|
|
|
|
|
2018-06-24 01:39:25 +01:00
|
|
|
private unsafe static byte[] Read1Bpp(IAMemory Memory, TextureInfo Texture)
|
2018-05-30 00:37:10 +01:00
|
|
|
{
|
|
|
|
int Width = Texture.Width;
|
|
|
|
int Height = Texture.Height;
|
|
|
|
|
|
|
|
byte[] Output = new byte[Width * Height];
|
|
|
|
|
2018-07-19 06:30:21 +01:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 1);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
|
|
|
fixed (byte* BuffPtr = Output)
|
|
|
|
{
|
|
|
|
long OutOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
2018-08-15 19:59:51 +01:00
|
|
|
byte Pixel = CpuMem.ReadByte(Position + Offset);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
*(BuffPtr + OutOffs) = Pixel;
|
|
|
|
|
|
|
|
OutOffs++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Output;
|
|
|
|
}
|
|
|
|
|
2018-06-24 01:39:25 +01:00
|
|
|
private unsafe static byte[] Read5551(IAMemory Memory, TextureInfo Texture)
|
2018-05-30 00:37:10 +01:00
|
|
|
{
|
|
|
|
int Width = Texture.Width;
|
|
|
|
int Height = Texture.Height;
|
|
|
|
|
|
|
|
byte[] Output = new byte[Width * Height * 2];
|
|
|
|
|
2018-07-19 06:30:21 +01:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
|
|
|
fixed (byte* BuffPtr = Output)
|
|
|
|
{
|
|
|
|
long OutOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
2018-08-15 19:59:51 +01:00
|
|
|
uint Pixel = (uint)CpuMem.ReadInt16(Position + Offset);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
Pixel = (Pixel & 0x001f) << 11 |
|
|
|
|
(Pixel & 0x03e0) << 1 |
|
|
|
|
(Pixel & 0x7c00) >> 9 |
|
|
|
|
(Pixel & 0x8000) >> 15;
|
|
|
|
|
|
|
|
*(short*)(BuffPtr + OutOffs) = (short)Pixel;
|
|
|
|
|
|
|
|
OutOffs += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Output;
|
|
|
|
}
|
|
|
|
|
2018-06-24 01:39:25 +01:00
|
|
|
private unsafe static byte[] Read565(IAMemory Memory, TextureInfo Texture)
|
2018-05-30 00:37:10 +01:00
|
|
|
{
|
|
|
|
int Width = Texture.Width;
|
|
|
|
int Height = Texture.Height;
|
|
|
|
|
|
|
|
byte[] Output = new byte[Width * Height * 2];
|
|
|
|
|
2018-07-19 06:30:21 +01:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
|
|
|
fixed (byte* BuffPtr = Output)
|
|
|
|
{
|
|
|
|
long OutOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
2018-08-15 19:59:51 +01:00
|
|
|
uint Pixel = (uint)CpuMem.ReadInt16(Position + Offset);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
Pixel = (Pixel & 0x001f) << 11 |
|
|
|
|
(Pixel & 0x07e0) |
|
|
|
|
(Pixel & 0xf800) >> 11;
|
|
|
|
|
|
|
|
*(short*)(BuffPtr + OutOffs) = (short)Pixel;
|
|
|
|
|
|
|
|
OutOffs += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Output;
|
|
|
|
}
|
|
|
|
|
2018-06-24 01:39:25 +01:00
|
|
|
private unsafe static byte[] Read2Bpp(IAMemory Memory, TextureInfo Texture)
|
2018-04-08 20:17:35 +01:00
|
|
|
{
|
|
|
|
int Width = Texture.Width;
|
|
|
|
int Height = Texture.Height;
|
|
|
|
|
2018-04-10 20:50:32 +01:00
|
|
|
byte[] Output = new byte[Width * Height * 2];
|
2018-04-08 20:17:35 +01:00
|
|
|
|
2018-07-19 06:30:21 +01:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);
|
2018-04-08 20:17:35 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 19:53:23 +01:00
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
2018-04-08 20:17:35 +01:00
|
|
|
fixed (byte* BuffPtr = Output)
|
|
|
|
{
|
|
|
|
long OutOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
2018-08-15 19:59:51 +01:00
|
|
|
short Pixel = CpuMem.ReadInt16(Position + Offset);
|
2018-04-08 20:17:35 +01:00
|
|
|
|
2018-04-10 20:50:32 +01:00
|
|
|
*(short*)(BuffPtr + OutOffs) = Pixel;
|
2018-04-08 20:17:35 +01:00
|
|
|
|
2018-04-10 20:50:32 +01:00
|
|
|
OutOffs += 2;
|
2018-04-08 20:17:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Output;
|
|
|
|
}
|
|
|
|
|
2018-06-24 01:39:25 +01:00
|
|
|
private unsafe static byte[] Read4Bpp(IAMemory Memory, TextureInfo Texture)
|
2018-04-08 22:08:36 +01:00
|
|
|
{
|
|
|
|
int Width = Texture.Width;
|
|
|
|
int Height = Texture.Height;
|
|
|
|
|
2018-04-10 20:50:32 +01:00
|
|
|
byte[] Output = new byte[Width * Height * 4];
|
2018-04-08 22:08:36 +01:00
|
|
|
|
2018-07-19 06:30:21 +01:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 4);
|
2018-04-08 22:08:36 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 19:53:23 +01:00
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
2018-04-08 22:08:36 +01:00
|
|
|
fixed (byte* BuffPtr = Output)
|
|
|
|
{
|
|
|
|
long OutOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
2018-08-15 19:59:51 +01:00
|
|
|
int Pixel = CpuMem.ReadInt32(Position + Offset);
|
2018-04-08 22:08:36 +01:00
|
|
|
|
2018-04-10 20:50:32 +01:00
|
|
|
*(int*)(BuffPtr + OutOffs) = Pixel;
|
2018-04-08 22:08:36 +01:00
|
|
|
|
2018-04-10 20:50:32 +01:00
|
|
|
OutOffs += 4;
|
2018-04-08 22:08:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Output;
|
|
|
|
}
|
|
|
|
|
2018-06-24 01:39:25 +01:00
|
|
|
private unsafe static byte[] Read8Bpp(IAMemory Memory, TextureInfo Texture)
|
2018-05-30 00:37:10 +01:00
|
|
|
{
|
|
|
|
int Width = Texture.Width;
|
|
|
|
int Height = Texture.Height;
|
|
|
|
|
|
|
|
byte[] Output = new byte[Width * Height * 8];
|
|
|
|
|
2018-07-19 06:30:21 +01:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 8);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
|
|
|
fixed (byte* BuffPtr = Output)
|
|
|
|
{
|
|
|
|
long OutOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
2018-08-15 19:59:51 +01:00
|
|
|
long Pixel = CpuMem.ReadInt64(Position + Offset);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
*(long*)(BuffPtr + OutOffs) = Pixel;
|
|
|
|
|
|
|
|
OutOffs += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Output;
|
|
|
|
}
|
|
|
|
|
2018-06-24 01:39:25 +01:00
|
|
|
private unsafe static byte[] Read16Bpp(IAMemory Memory, TextureInfo Texture)
|
2018-05-30 00:37:10 +01:00
|
|
|
{
|
|
|
|
int Width = Texture.Width;
|
|
|
|
int Height = Texture.Height;
|
|
|
|
|
|
|
|
byte[] Output = new byte[Width * Height * 16];
|
|
|
|
|
2018-07-19 06:30:21 +01:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 16);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
|
|
|
fixed (byte* BuffPtr = Output)
|
|
|
|
{
|
|
|
|
long OutOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
2018-08-15 19:59:51 +01:00
|
|
|
long PxLow = CpuMem.ReadInt64(Position + Offset + 0);
|
|
|
|
long PxHigh = CpuMem.ReadInt64(Position + Offset + 8);
|
2018-05-30 00:37:10 +01:00
|
|
|
|
|
|
|
*(long*)(BuffPtr + OutOffs + 0) = PxLow;
|
|
|
|
*(long*)(BuffPtr + OutOffs + 8) = PxHigh;
|
|
|
|
|
|
|
|
OutOffs += 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Output;
|
|
|
|
}
|
|
|
|
|
2018-06-24 01:39:25 +01:00
|
|
|
private unsafe static byte[] Read8Bpt4x4(IAMemory Memory, TextureInfo Texture)
|
2018-04-08 20:17:35 +01:00
|
|
|
{
|
|
|
|
int Width = (Texture.Width + 3) / 4;
|
|
|
|
int Height = (Texture.Height + 3) / 4;
|
|
|
|
|
|
|
|
byte[] Output = new byte[Width * Height * 8];
|
|
|
|
|
2018-07-19 06:30:21 +01:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 4, 8);
|
2018-04-08 20:17:35 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 19:53:23 +01:00
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
2018-04-08 20:17:35 +01:00
|
|
|
fixed (byte* BuffPtr = Output)
|
|
|
|
{
|
|
|
|
long OutOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
2018-08-15 19:59:51 +01:00
|
|
|
long Tile = CpuMem.ReadInt64(Position + Offset);
|
2018-04-08 20:17:35 +01:00
|
|
|
|
|
|
|
*(long*)(BuffPtr + OutOffs) = Tile;
|
|
|
|
|
|
|
|
OutOffs += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Output;
|
|
|
|
}
|
|
|
|
|
2018-07-13 01:27:59 +01:00
|
|
|
private unsafe static byte[] Read16BptCompressedTexture(IAMemory Memory, TextureInfo Texture, int BlockWidth, int BlockHeight)
|
2018-04-08 20:17:35 +01:00
|
|
|
{
|
2018-07-13 01:27:59 +01:00
|
|
|
int Width = (Texture.Width + (BlockWidth - 1)) / BlockWidth;
|
|
|
|
int Height = (Texture.Height + (BlockHeight - 1)) / BlockHeight;
|
2018-04-08 20:17:35 +01:00
|
|
|
|
|
|
|
byte[] Output = new byte[Width * Height * 16];
|
|
|
|
|
2018-07-19 06:30:21 +01:00
|
|
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, BlockWidth, 16);
|
2018-04-08 20:17:35 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 19:53:23 +01:00
|
|
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
|
|
|
Memory,
|
|
|
|
Texture.Position);
|
|
|
|
|
2018-04-08 20:17:35 +01:00
|
|
|
fixed (byte* BuffPtr = Output)
|
|
|
|
{
|
|
|
|
long OutOffs = 0;
|
|
|
|
|
|
|
|
for (int Y = 0; Y < Height; Y++)
|
|
|
|
for (int X = 0; X < Width; X++)
|
|
|
|
{
|
|
|
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
|
|
|
|
2018-08-15 19:59:51 +01:00
|
|
|
long Tile0 = CpuMem.ReadInt64(Position + Offset + 0);
|
|
|
|
long Tile1 = CpuMem.ReadInt64(Position + Offset + 8);
|
2018-04-08 20:17:35 +01:00
|
|
|
|
|
|
|
*(long*)(BuffPtr + OutOffs + 0) = Tile0;
|
|
|
|
*(long*)(BuffPtr + OutOffs + 8) = Tile1;
|
|
|
|
|
|
|
|
OutOffs += 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Output;
|
|
|
|
}
|
|
|
|
}
|
2018-04-08 22:08:36 +01:00
|
|
|
}
|