Improve dma copies on the gpu
This commit is contained in:
parent
17f54b5d78
commit
6e4f43446b
3 changed files with 33 additions and 5 deletions
|
@ -691,6 +691,19 @@ namespace ChocolArm64.Memory
|
|||
Marshal.Copy(Data, 0, (IntPtr)(RamPtr + (uint)Position), Data.Length);
|
||||
}
|
||||
|
||||
public void CopyBytes(long Src, long Dst, long Size)
|
||||
{
|
||||
EnsureRangeIsValid(Src, Size, AMemoryPerm.Read);
|
||||
EnsureRangeIsValid(Dst, Size, AMemoryPerm.Write);
|
||||
|
||||
Buffer.MemoryCopy(
|
||||
RamPtr + (uint)Src,
|
||||
RamPtr + (uint)Dst,
|
||||
Size,
|
||||
Size);
|
||||
}
|
||||
|
||||
|
||||
private void EnsureRangeIsValid(long Position, long Size, AMemoryPerm Perm)
|
||||
{
|
||||
long EndPos = Position + Size;
|
||||
|
|
|
@ -58,6 +58,9 @@ namespace Ryujinx.HLE.Gpu.Engines
|
|||
int SrcPitch = ReadRegister(NvGpuEngineDmaReg.SrcPitch);
|
||||
int DstPitch = ReadRegister(NvGpuEngineDmaReg.DstPitch);
|
||||
|
||||
int XCount = ReadRegister(NvGpuEngineDmaReg.XCount);
|
||||
int YCount = ReadRegister(NvGpuEngineDmaReg.YCount);
|
||||
|
||||
int DstBlkDim = ReadRegister(NvGpuEngineDmaReg.DstBlkDim);
|
||||
int DstSizeX = ReadRegister(NvGpuEngineDmaReg.DstSizeX);
|
||||
int DstSizeY = ReadRegister(NvGpuEngineDmaReg.DstSizeY);
|
||||
|
@ -103,8 +106,17 @@ namespace Ryujinx.HLE.Gpu.Engines
|
|||
DstSwizzle = new BlockLinearSwizzle(DstSizeX, 1, DstBlockHeight);
|
||||
}
|
||||
|
||||
for (int Y = 0; Y < DstSizeY; Y++)
|
||||
for (int X = 0; X < DstSizeX; X++)
|
||||
if (SrcLinear == DstLinear)
|
||||
{
|
||||
long Src = Vmm.GetPhysicalAddress(SrcAddress);
|
||||
long Dst = Vmm.GetPhysicalAddress(DstAddress);
|
||||
|
||||
Vmm.Memory.CopyBytes(Src, Dst, XCount * YCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int Y = 0; Y < YCount; Y++)
|
||||
for (int X = 0; X < XCount; X++)
|
||||
{
|
||||
long SrcOffset = SrcAddress + (uint)SrcSwizzle.GetSwizzleOffset(X, Y);
|
||||
long DstOffset = DstAddress + (uint)DstSwizzle.GetSwizzleOffset(X, Y);
|
||||
|
@ -112,6 +124,7 @@ namespace Ryujinx.HLE.Gpu.Engines
|
|||
Vmm.WriteByte(DstOffset, Vmm.ReadByte(SrcOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long MakeInt64From2xInt32(NvGpuEngineDmaReg Reg)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace Ryujinx.HLE.Gpu.Engines
|
|||
DstAddress = 0x102,
|
||||
SrcPitch = 0x104,
|
||||
DstPitch = 0x105,
|
||||
XCount = 0x106,
|
||||
YCount = 0x107,
|
||||
DstBlkDim = 0x1c3,
|
||||
DstSizeX = 0x1c4,
|
||||
DstSizeY = 0x1c5,
|
||||
|
|
Loading…
Reference in a new issue