NsGpu.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. internal NsGpuMemoryMgr MemoryMgr { get; private set; }
  9. public NvGpuFifo Fifo;
  10. internal NvGpuEngine3d Engine3d;
  11. private Thread FifoProcessing;
  12. private bool KeepRunning;
  13. public NsGpu(IGalRenderer Renderer)
  14. {
  15. this.Renderer = Renderer;
  16. MemoryMgr = new NsGpuMemoryMgr();
  17. Fifo = new NvGpuFifo(this);
  18. Engine3d = new NvGpuEngine3d(this);
  19. KeepRunning = true;
  20. FifoProcessing = new Thread(ProcessFifo);
  21. FifoProcessing.Start();
  22. }
  23. public long GetCpuAddr(long Position)
  24. {
  25. return MemoryMgr.GetCpuAddr(Position);
  26. }
  27. public long MapMemory(long CpuAddr, long Size)
  28. {
  29. return MemoryMgr.Map(CpuAddr, Size);
  30. }
  31. public long MapMemory(long CpuAddr, long GpuAddr, long Size)
  32. {
  33. return MemoryMgr.Map(CpuAddr, GpuAddr, Size);
  34. }
  35. public long ReserveMemory(long Size, long Align)
  36. {
  37. return MemoryMgr.Reserve(Size, Align);
  38. }
  39. public long ReserveMemory(long GpuAddr, long Size, long Align)
  40. {
  41. return MemoryMgr.Reserve(GpuAddr, Size, Align);
  42. }
  43. private void ProcessFifo()
  44. {
  45. while (KeepRunning)
  46. {
  47. Fifo.DispatchCalls();
  48. Thread.Yield();
  49. }
  50. }
  51. }
  52. }