using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Engine; using Ryujinx.Graphics.Gpu.Memory; using System; namespace Ryujinx.Graphics.Gpu { /// /// GPU emulation context. /// public class GpuContext { /// /// Host renderer. /// public IRenderer Renderer { get; } /// /// Physical memory access (it actually accesses the process memory, not actual physical memory). /// internal PhysicalMemory PhysicalMemory { get; private set; } /// /// GPU memory manager. /// public MemoryManager MemoryManager { get; } /// /// GPU memory accessor. /// internal MemoryAccessor MemoryAccessor { get; } /// /// GPU engine methods processing. /// internal Methods Methods { get; } /// /// GPU commands FIFO. /// internal NvGpuFifo Fifo { get; } /// /// DMA pusher. /// public DmaPusher DmaPusher { get; } /// /// Presentation window. /// public Window Window { get; } /// /// Internal sequence number, used to avoid needless resource data updates /// in the middle of a command buffer before synchronizations. /// internal int SequenceNumber { get; private set; } private readonly Lazy _caps; /// /// Host hardware capabilities. /// internal Capabilities Capabilities => _caps.Value; /// /// Creates a new instance of the GPU emulation context. /// /// Host renderer public GpuContext(IRenderer renderer) { Renderer = renderer; MemoryManager = new MemoryManager(); MemoryAccessor = new MemoryAccessor(this); Methods = new Methods(this); Fifo = new NvGpuFifo(this); DmaPusher = new DmaPusher(this); Window = new Window(this); _caps = new Lazy(Renderer.GetCapabilities); } /// /// Advances internal sequence number. /// This forces the update of any modified GPU resource. /// internal void AdvanceSequence() { SequenceNumber++; } /// /// Sets the process memory manager, after the application process is initialized. /// This is required for any GPU memory access. /// /// CPU memory manager public void SetVmm(ARMeilleure.Memory.MemoryManager cpuMemory) { PhysicalMemory = new PhysicalMemory(cpuMemory); } } }