2018-02-20 15:09:23 -05:00
|
|
|
using Ryujinx.Graphics.Gal;
|
2018-04-08 15:17:35 -04:00
|
|
|
using System.Threading;
|
2018-02-20 15:09:23 -05:00
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gpu
|
|
|
|
{
|
|
|
|
public class NsGpu
|
|
|
|
{
|
|
|
|
public IGalRenderer Renderer { get; private set; }
|
|
|
|
|
|
|
|
internal NsGpuMemoryMgr MemoryMgr { get; private set; }
|
|
|
|
|
2018-04-13 14:12:58 -04:00
|
|
|
public NvGpuFifo Fifo { get; private set; }
|
2018-04-08 15:17:35 -04:00
|
|
|
|
2018-04-13 14:12:58 -04:00
|
|
|
public NvGpuEngine3d Engine3d { get; private set; }
|
2018-04-08 15:17:35 -04:00
|
|
|
|
|
|
|
private Thread FifoProcessing;
|
|
|
|
|
|
|
|
private bool KeepRunning;
|
2018-02-20 15:09:23 -05:00
|
|
|
|
|
|
|
public NsGpu(IGalRenderer Renderer)
|
|
|
|
{
|
|
|
|
this.Renderer = Renderer;
|
|
|
|
|
|
|
|
MemoryMgr = new NsGpuMemoryMgr();
|
|
|
|
|
2018-04-08 15:17:35 -04:00
|
|
|
Fifo = new NvGpuFifo(this);
|
|
|
|
|
|
|
|
Engine3d = new NvGpuEngine3d(this);
|
|
|
|
|
|
|
|
KeepRunning = true;
|
|
|
|
|
2018-04-13 14:12:58 -04:00
|
|
|
FifoProcessing = new Thread(ProcessFifo);
|
2018-04-08 15:17:35 -04:00
|
|
|
|
|
|
|
FifoProcessing.Start();
|
2018-02-20 15:09:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public long GetCpuAddr(long Position)
|
|
|
|
{
|
|
|
|
return MemoryMgr.GetCpuAddr(Position);
|
|
|
|
}
|
|
|
|
|
|
|
|
public long MapMemory(long CpuAddr, long Size)
|
|
|
|
{
|
|
|
|
return MemoryMgr.Map(CpuAddr, Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
public long MapMemory(long CpuAddr, long GpuAddr, long Size)
|
|
|
|
{
|
|
|
|
return MemoryMgr.Map(CpuAddr, GpuAddr, Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
public long ReserveMemory(long Size, long Align)
|
|
|
|
{
|
|
|
|
return MemoryMgr.Reserve(Size, Align);
|
|
|
|
}
|
|
|
|
|
|
|
|
public long ReserveMemory(long GpuAddr, long Size, long Align)
|
|
|
|
{
|
|
|
|
return MemoryMgr.Reserve(GpuAddr, Size, Align);
|
|
|
|
}
|
2018-04-08 15:17:35 -04:00
|
|
|
|
|
|
|
private void ProcessFifo()
|
|
|
|
{
|
|
|
|
while (KeepRunning)
|
|
|
|
{
|
|
|
|
Fifo.DispatchCalls();
|
|
|
|
|
|
|
|
Thread.Yield();
|
|
|
|
}
|
|
|
|
}
|
2018-02-20 15:09:23 -05:00
|
|
|
}
|
|
|
|
}
|