using Ryujinx.Graphics.Gpu.Engine.GPFifo; using Ryujinx.Graphics.Gpu.Image; using Ryujinx.Graphics.Gpu.Memory; using System; namespace Ryujinx.Graphics.Gpu { /// /// Represents a GPU channel. /// public class GpuChannel : IDisposable { private readonly GpuContext _context; private readonly GPFifoDevice _device; private readonly GPFifoProcessor _processor; /// /// Channel buffer bindings manager. /// internal BufferManager BufferManager { get; } /// /// Channel texture bindings manager. /// internal TextureManager TextureManager { get; } /// /// Creates a new instance of a GPU channel. /// /// GPU context that the channel belongs to internal GpuChannel(GpuContext context) { _context = context; _device = context.GPFifo; _processor = new GPFifoProcessor(context, this); BufferManager = new BufferManager(context); TextureManager = new TextureManager(context, this); } /// /// Push a GPFIFO entry in the form of a prefetched command buffer. /// It is intended to be used by nvservices to handle special cases. /// /// The command buffer containing the prefetched commands public void PushHostCommandBuffer(int[] commandBuffer) { _device.PushHostCommandBuffer(_processor, commandBuffer); } /// /// Pushes GPFIFO entries. /// /// GPFIFO entries public void PushEntries(ReadOnlySpan entries) { _device.PushEntries(_processor, entries); } /// /// Disposes the GPU channel. /// It's an error to use the GPU channel after disposal. /// public void Dispose() { _context.DisposedChannels.Enqueue(this); } /// /// Performs disposal of the host GPU resources used by this channel, that are not shared. /// This must only be called from the render thread. /// internal void Destroy() { BufferManager.Dispose(); TextureManager.Dispose(); } } }