aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/GpuChannel.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-06-23 20:51:41 -0300
committerGitHub <noreply@github.com>2021-06-24 01:51:41 +0200
commita10b2c5ff26886e9ffc6f19e3f0fe9505a503b2f (patch)
tree006d013c300fb56c94c5563c2c1409a189f794b2 /Ryujinx.Graphics.Gpu/GpuChannel.cs
parent12a7a2ead812d46deb9d978b6758731157be1cbc (diff)
Initial support for GPU channels (#2372)
* Ground work for separate GPU channels * Rename TextureManager to TextureCache * Decouple texture bindings management from the texture cache * Rename BufferManager to BufferCache * Decouple buffer bindings management from the buffer cache * More comments and proper disposal * PR feedback * Force host state update on channel switch * Typo * PR feedback * Missing using
Diffstat (limited to 'Ryujinx.Graphics.Gpu/GpuChannel.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/GpuChannel.cs78
1 files changed, 78 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/GpuChannel.cs b/Ryujinx.Graphics.Gpu/GpuChannel.cs
new file mode 100644
index 00000000..79143449
--- /dev/null
+++ b/Ryujinx.Graphics.Gpu/GpuChannel.cs
@@ -0,0 +1,78 @@
+using Ryujinx.Graphics.Gpu.Engine.GPFifo;
+using Ryujinx.Graphics.Gpu.Image;
+using Ryujinx.Graphics.Gpu.Memory;
+using System;
+
+namespace Ryujinx.Graphics.Gpu
+{
+ /// <summary>
+ /// Represents a GPU channel.
+ /// </summary>
+ public class GpuChannel : IDisposable
+ {
+ private readonly GpuContext _context;
+ private readonly GPFifoDevice _device;
+ private readonly GPFifoProcessor _processor;
+
+ /// <summary>
+ /// Channel buffer bindings manager.
+ /// </summary>
+ internal BufferManager BufferManager { get; }
+
+ /// <summary>
+ /// Channel texture bindings manager.
+ /// </summary>
+ internal TextureManager TextureManager { get; }
+
+ /// <summary>
+ /// Creates a new instance of a GPU channel.
+ /// </summary>
+ /// <param name="context">GPU context that the channel belongs to</param>
+ internal GpuChannel(GpuContext context)
+ {
+ _context = context;
+ _device = context.GPFifo;
+ _processor = new GPFifoProcessor(context, this);
+ BufferManager = new BufferManager(context);
+ TextureManager = new TextureManager(context, this);
+ }
+
+ /// <summary>
+ /// Push a GPFIFO entry in the form of a prefetched command buffer.
+ /// It is intended to be used by nvservices to handle special cases.
+ /// </summary>
+ /// <param name="commandBuffer">The command buffer containing the prefetched commands</param>
+ public void PushHostCommandBuffer(int[] commandBuffer)
+ {
+ _device.PushHostCommandBuffer(_processor, commandBuffer);
+ }
+
+ /// <summary>
+ /// Pushes GPFIFO entries.
+ /// </summary>
+ /// <param name="entries">GPFIFO entries</param>
+ public void PushEntries(ReadOnlySpan<ulong> entries)
+ {
+ _device.PushEntries(_processor, entries);
+ }
+
+ /// <summary>
+ /// Disposes the GPU channel.
+ /// It's an error to use the GPU channel after disposal.
+ /// </summary>
+ public void Dispose()
+ {
+ _context.DisposedChannels.Enqueue(this);
+ }
+
+ /// <summary>
+ /// Performs disposal of the host GPU resources used by this channel, that are not shared.
+ /// This must only be called from the render thread.
+ /// </summary>
+ internal void Destroy()
+ {
+ BufferManager.Dispose();
+ TextureManager.Dispose();
+ }
+ }
+}