NsGpu.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Ryujinx.Graphics.Gal;
  2. using System.Threading;
  3. namespace Ryujinx.Graphics.Gpu
  4. {
  5. public class NsGpu
  6. {
  7. public IGalRenderer Renderer { get; private set; }
  8. public NsGpuMemoryMgr MemoryMgr { get; private set; }
  9. public NvGpuFifo Fifo { get; private set; }
  10. public NvGpuEngine2d Engine2d { get; private set; }
  11. public NvGpuEngine3d Engine3d { get; private set; }
  12. private Thread FifoProcessing;
  13. private bool KeepRunning;
  14. public NsGpu(IGalRenderer Renderer)
  15. {
  16. this.Renderer = Renderer;
  17. MemoryMgr = new NsGpuMemoryMgr();
  18. Fifo = new NvGpuFifo(this);
  19. Engine2d = new NvGpuEngine2d(this);
  20. Engine3d = new NvGpuEngine3d(this);
  21. KeepRunning = true;
  22. FifoProcessing = new Thread(ProcessFifo);
  23. FifoProcessing.Start();
  24. }
  25. public long GetCpuAddr(long Position)
  26. {
  27. return MemoryMgr.GetCpuAddr(Position);
  28. }
  29. public long MapMemory(long CpuAddr, long Size)
  30. {
  31. return MemoryMgr.Map(CpuAddr, Size);
  32. }
  33. public long MapMemory(long CpuAddr, long GpuAddr, long Size)
  34. {
  35. return MemoryMgr.Map(CpuAddr, GpuAddr, Size);
  36. }
  37. public long ReserveMemory(long Size, long Align)
  38. {
  39. return MemoryMgr.Reserve(Size, Align);
  40. }
  41. public long ReserveMemory(long GpuAddr, long Size, long Align)
  42. {
  43. return MemoryMgr.Reserve(GpuAddr, Size, Align);
  44. }
  45. private void ProcessFifo()
  46. {
  47. while (KeepRunning)
  48. {
  49. Fifo.DispatchCalls();
  50. Thread.Yield();
  51. }
  52. }
  53. }
  54. }