mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-29 17:56:05 +00:00
Do not read or write macros to main memory, use a separate memory instead (as this apparently what the real thing does)
This commit is contained in:
parent
b747b23607
commit
46f18af6be
|
@ -56,7 +56,7 @@ namespace Ryujinx.HLE.Gpu
|
||||||
|
|
||||||
private int PipeOp;
|
private int PipeOp;
|
||||||
|
|
||||||
private long Pc;
|
private int Pc;
|
||||||
|
|
||||||
public MacroInterpreter(NvGpuFifo PFifo, INvGpuEngine Engine)
|
public MacroInterpreter(NvGpuFifo PFifo, INvGpuEngine Engine)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ namespace Ryujinx.HLE.Gpu
|
||||||
Gprs = new int[8];
|
Gprs = new int[8];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(NvGpuVmm Vmm, long Position, int Param)
|
public void Execute(NvGpuVmm Vmm, int[] Mme, int Position, int Param)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
|
@ -76,13 +76,13 @@ namespace Ryujinx.HLE.Gpu
|
||||||
|
|
||||||
Pc = Position;
|
Pc = Position;
|
||||||
|
|
||||||
FetchOpCode(Vmm);
|
FetchOpCode(Mme);
|
||||||
|
|
||||||
while (Step(Vmm));
|
while (Step(Vmm, Mme));
|
||||||
|
|
||||||
//Due to the delay slot, we still need to execute
|
//Due to the delay slot, we still need to execute
|
||||||
//one more instruction before we actually exit.
|
//one more instruction before we actually exit.
|
||||||
Step(Vmm);
|
Step(Vmm, Mme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Reset()
|
private void Reset()
|
||||||
|
@ -98,11 +98,11 @@ namespace Ryujinx.HLE.Gpu
|
||||||
Carry = false;
|
Carry = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Step(NvGpuVmm Vmm)
|
private bool Step(NvGpuVmm Vmm, int[] Mme)
|
||||||
{
|
{
|
||||||
long BaseAddr = Pc - 4;
|
int BaseAddr = Pc - 1;
|
||||||
|
|
||||||
FetchOpCode(Vmm);
|
FetchOpCode(Mme);
|
||||||
|
|
||||||
if ((OpCode & 7) < 7)
|
if ((OpCode & 7) < 7)
|
||||||
{
|
{
|
||||||
|
@ -205,13 +205,13 @@ namespace Ryujinx.HLE.Gpu
|
||||||
|
|
||||||
if (Taken)
|
if (Taken)
|
||||||
{
|
{
|
||||||
Pc = BaseAddr + (GetImm() << 2);
|
Pc = BaseAddr + GetImm();
|
||||||
|
|
||||||
bool NoDelays = (OpCode & 0x20) != 0;
|
bool NoDelays = (OpCode & 0x20) != 0;
|
||||||
|
|
||||||
if (NoDelays)
|
if (NoDelays)
|
||||||
{
|
{
|
||||||
FetchOpCode(Vmm);
|
FetchOpCode(Mme);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -223,13 +223,11 @@ namespace Ryujinx.HLE.Gpu
|
||||||
return !Exit;
|
return !Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FetchOpCode(NvGpuVmm Vmm)
|
private void FetchOpCode(int[] Mme)
|
||||||
{
|
{
|
||||||
OpCode = PipeOp;
|
OpCode = PipeOp;
|
||||||
|
|
||||||
PipeOp = Vmm.ReadInt32(Pc);
|
PipeOp = Mme[Pc++];
|
||||||
|
|
||||||
Pc += 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetAluResult()
|
private int GetAluResult()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using Ryujinx.Graphics.Gal;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.Gpu
|
namespace Ryujinx.HLE.Gpu
|
||||||
|
|
|
@ -7,6 +7,10 @@ namespace Ryujinx.HLE.Gpu
|
||||||
private const int MacrosCount = 0x80;
|
private const int MacrosCount = 0x80;
|
||||||
private const int MacroIndexMask = MacrosCount - 1;
|
private const int MacroIndexMask = MacrosCount - 1;
|
||||||
|
|
||||||
|
//Note: The size of the macro memory is unknown, we just make
|
||||||
|
//a guess here and use 256kb as the size. Increase if needed.
|
||||||
|
private const int MmeWords = 256 * 256;
|
||||||
|
|
||||||
private NvGpu Gpu;
|
private NvGpu Gpu;
|
||||||
|
|
||||||
private ConcurrentQueue<(NvGpuVmm, NvGpuPBEntry)> BufferQueue;
|
private ConcurrentQueue<(NvGpuVmm, NvGpuPBEntry)> BufferQueue;
|
||||||
|
@ -15,11 +19,11 @@ namespace Ryujinx.HLE.Gpu
|
||||||
|
|
||||||
private struct CachedMacro
|
private struct CachedMacro
|
||||||
{
|
{
|
||||||
public long Position { get; private set; }
|
public int Position { get; private set; }
|
||||||
|
|
||||||
private MacroInterpreter Interpreter;
|
private MacroInterpreter Interpreter;
|
||||||
|
|
||||||
public CachedMacro(NvGpuFifo PFifo, INvGpuEngine Engine, long Position)
|
public CachedMacro(NvGpuFifo PFifo, INvGpuEngine Engine, int Position)
|
||||||
{
|
{
|
||||||
this.Position = Position;
|
this.Position = Position;
|
||||||
|
|
||||||
|
@ -31,17 +35,19 @@ namespace Ryujinx.HLE.Gpu
|
||||||
Interpreter?.Fifo.Enqueue(Param);
|
Interpreter?.Fifo.Enqueue(Param);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(NvGpuVmm Vmm, int Param)
|
public void Execute(NvGpuVmm Vmm, int[] Mme, int Param)
|
||||||
{
|
{
|
||||||
Interpreter?.Execute(Vmm, Position, Param);
|
Interpreter?.Execute(Vmm, Mme, Position, Param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long CurrMacroPosition;
|
private int CurrMacroPosition;
|
||||||
private int CurrMacroBindIndex;
|
private int CurrMacroBindIndex;
|
||||||
|
|
||||||
private CachedMacro[] Macros;
|
private CachedMacro[] Macros;
|
||||||
|
|
||||||
|
private int[] Mme;
|
||||||
|
|
||||||
public NvGpuFifo(NvGpu Gpu)
|
public NvGpuFifo(NvGpu Gpu)
|
||||||
{
|
{
|
||||||
this.Gpu = Gpu;
|
this.Gpu = Gpu;
|
||||||
|
@ -51,6 +57,8 @@ namespace Ryujinx.HLE.Gpu
|
||||||
SubChannels = new NvGpuEngine[8];
|
SubChannels = new NvGpuEngine[8];
|
||||||
|
|
||||||
Macros = new CachedMacro[MacrosCount];
|
Macros = new CachedMacro[MacrosCount];
|
||||||
|
|
||||||
|
Mme = new int[MmeWords];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PushBuffer(NvGpuVmm Vmm, NvGpuPBEntry[] Buffer)
|
public void PushBuffer(NvGpuVmm Vmm, NvGpuPBEntry[] Buffer)
|
||||||
|
@ -95,22 +103,16 @@ namespace Ryujinx.HLE.Gpu
|
||||||
|
|
||||||
case NvGpuFifoMeth.SetMacroUploadAddress:
|
case NvGpuFifoMeth.SetMacroUploadAddress:
|
||||||
{
|
{
|
||||||
CurrMacroPosition = (long)((ulong)PBEntry.Arguments[0] << 2);
|
CurrMacroPosition = PBEntry.Arguments[0];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NvGpuFifoMeth.SendMacroCodeData:
|
case NvGpuFifoMeth.SendMacroCodeData:
|
||||||
{
|
{
|
||||||
long Position = CurrMacroPosition;
|
|
||||||
|
|
||||||
foreach (int Arg in PBEntry.Arguments)
|
foreach (int Arg in PBEntry.Arguments)
|
||||||
{
|
{
|
||||||
Vmm.WriteInt32(Position, Arg);
|
Mme[CurrMacroPosition++] = Arg;
|
||||||
|
|
||||||
CurrMacroPosition += 4;
|
|
||||||
|
|
||||||
Position += 4;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +126,7 @@ namespace Ryujinx.HLE.Gpu
|
||||||
|
|
||||||
case NvGpuFifoMeth.BindMacro:
|
case NvGpuFifoMeth.BindMacro:
|
||||||
{
|
{
|
||||||
long Position = (long)((ulong)PBEntry.Arguments[0] << 2);
|
int Position = PBEntry.Arguments[0];
|
||||||
|
|
||||||
Macros[CurrMacroBindIndex] = new CachedMacro(this, Gpu.Engine3d, Position);
|
Macros[CurrMacroBindIndex] = new CachedMacro(this, Gpu.Engine3d, Position);
|
||||||
|
|
||||||
|
@ -167,7 +169,7 @@ namespace Ryujinx.HLE.Gpu
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Macros[MacroIndex].Execute(Vmm, PBEntry.Arguments[0]);
|
Macros[MacroIndex].Execute(Vmm, Mme, PBEntry.Arguments[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue