Host1xContext.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Ryujinx.Graphics.Gpu.Memory;
  2. using Ryujinx.Graphics.Host1x;
  3. using Ryujinx.Graphics.Nvdec;
  4. using Ryujinx.Graphics.Vic;
  5. using System;
  6. using GpuContext = Ryujinx.Graphics.Gpu.GpuContext;
  7. namespace Ryujinx.HLE.HOS.Services.Nv
  8. {
  9. class Host1xContext : IDisposable
  10. {
  11. public MemoryManager Smmu { get; }
  12. public NvMemoryAllocator MemoryAllocator { get; }
  13. public Host1xDevice Host1x { get;}
  14. public Host1xContext(GpuContext gpu, long pid)
  15. {
  16. MemoryAllocator = new NvMemoryAllocator();
  17. Host1x = new Host1xDevice(gpu.Synchronization);
  18. Smmu = gpu.CreateMemoryManager(pid);
  19. var nvdec = new NvdecDevice(Smmu);
  20. var vic = new VicDevice(Smmu);
  21. Host1x.RegisterDevice(ClassId.Nvdec, nvdec);
  22. Host1x.RegisterDevice(ClassId.Vic, vic);
  23. nvdec.FrameDecoded += (FrameDecodedEventArgs e) =>
  24. {
  25. // FIXME:
  26. // Figure out what is causing frame ordering issues on H264.
  27. // For now this is needed as workaround.
  28. if (e.CodecId == CodecId.H264)
  29. {
  30. vic.SetSurfaceOverride(e.LumaOffset, e.ChromaOffset, 0);
  31. }
  32. else
  33. {
  34. vic.DisableSurfaceOverride();
  35. }
  36. };
  37. }
  38. public void Dispose()
  39. {
  40. Host1x.Dispose();
  41. }
  42. }
  43. }