aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.GAL/Multithreading
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.GAL/Multithreading')
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs8
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/CommandType.cs3
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/Commands/SetSamplerCommand.cs23
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/Commands/SetScissorCommand.cs28
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/Commands/SetScissorsCommand.cs22
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/Commands/SetTextureAndSamplerCommand.cs28
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/Commands/SetTextureCommand.cs23
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/Commands/SetViewportsCommand.cs6
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs19
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs9
-rw-r--r--Ryujinx.Graphics.GAL/Multithreading/ThreadedWindow.cs8
11 files changed, 75 insertions, 102 deletions
diff --git a/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs b/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs
index 95b33bc6..ea4d049f 100644
--- a/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs
+++ b/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs
@@ -201,14 +201,12 @@ namespace Ryujinx.Graphics.GAL.Multithreading
SetRenderTargetScaleCommand.Run(ref GetCommand<SetRenderTargetScaleCommand>(memory), threaded, renderer);
_lookup[(int)CommandType.SetRenderTargets] = (Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer) =>
SetRenderTargetsCommand.Run(ref GetCommand<SetRenderTargetsCommand>(memory), threaded, renderer);
- _lookup[(int)CommandType.SetSampler] = (Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer) =>
- SetSamplerCommand.Run(ref GetCommand<SetSamplerCommand>(memory), threaded, renderer);
_lookup[(int)CommandType.SetScissor] = (Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer) =>
- SetScissorCommand.Run(ref GetCommand<SetScissorCommand>(memory), threaded, renderer);
+ SetScissorsCommand.Run(ref GetCommand<SetScissorsCommand>(memory), threaded, renderer);
_lookup[(int)CommandType.SetStencilTest] = (Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer) =>
SetStencilTestCommand.Run(ref GetCommand<SetStencilTestCommand>(memory), threaded, renderer);
- _lookup[(int)CommandType.SetTexture] = (Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer) =>
- SetTextureCommand.Run(ref GetCommand<SetTextureCommand>(memory), threaded, renderer);
+ _lookup[(int)CommandType.SetTextureAndSampler] = (Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer) =>
+ SetTextureAndSamplerCommand.Run(ref GetCommand<SetTextureAndSamplerCommand>(memory), threaded, renderer);
_lookup[(int)CommandType.SetUserClipDistance] = (Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer) =>
SetUserClipDistanceCommand.Run(ref GetCommand<SetUserClipDistanceCommand>(memory), threaded, renderer);
_lookup[(int)CommandType.SetVertexAttribs] = (Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer) =>
diff --git a/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs b/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs
index 8f0a0095..8c3ad844 100644
--- a/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs
+++ b/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs
@@ -82,10 +82,9 @@
SetRenderTargetColorMasks,
SetRenderTargetScale,
SetRenderTargets,
- SetSampler,
SetScissor,
SetStencilTest,
- SetTexture,
+ SetTextureAndSampler,
SetUserClipDistance,
SetVertexAttribs,
SetVertexBuffers,
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetSamplerCommand.cs b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetSamplerCommand.cs
deleted file mode 100644
index f3be24db..00000000
--- a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetSamplerCommand.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Ryujinx.Graphics.GAL.Multithreading.Model;
-using Ryujinx.Graphics.GAL.Multithreading.Resources;
-
-namespace Ryujinx.Graphics.GAL.Multithreading.Commands
-{
- struct SetSamplerCommand : IGALCommand
- {
- public CommandType CommandType => CommandType.SetSampler;
- private int _index;
- private TableRef<ISampler> _sampler;
-
- public void Set(int index, TableRef<ISampler> sampler)
- {
- _index = index;
- _sampler = sampler;
- }
-
- public static void Run(ref SetSamplerCommand command, ThreadedRenderer threaded, IRenderer renderer)
- {
- renderer.Pipeline.SetSampler(command._index, command._sampler.GetAs<ThreadedSampler>(threaded)?.Base);
- }
- }
-}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetScissorCommand.cs b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetScissorCommand.cs
deleted file mode 100644
index 6c95d096..00000000
--- a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetScissorCommand.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-namespace Ryujinx.Graphics.GAL.Multithreading.Commands
-{
- struct SetScissorCommand : IGALCommand
- {
- public CommandType CommandType => CommandType.SetScissor;
- private int _index;
- private bool _enable;
- private int _x;
- private int _y;
- private int _width;
- private int _height;
-
- public void Set(int index, bool enable, int x, int y, int width, int height)
- {
- _index = index;
- _enable = enable;
- _x = x;
- _y = y;
- _width = width;
- _height = height;
- }
-
- public static void Run(ref SetScissorCommand command, ThreadedRenderer threaded, IRenderer renderer)
- {
- renderer.Pipeline.SetScissor(command._index, command._enable, command._x, command._y, command._width, command._height);
- }
- }
-}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetScissorsCommand.cs b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetScissorsCommand.cs
new file mode 100644
index 00000000..6966df6d
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetScissorsCommand.cs
@@ -0,0 +1,22 @@
+using Ryujinx.Graphics.GAL.Multithreading.Model;
+
+namespace Ryujinx.Graphics.GAL.Multithreading.Commands
+{
+ struct SetScissorsCommand : IGALCommand
+ {
+ public CommandType CommandType => CommandType.SetScissor;
+ private SpanRef<Rectangle<int>> _scissors;
+
+ public void Set(SpanRef<Rectangle<int>> scissors)
+ {
+ _scissors = scissors;
+ }
+
+ public static void Run(ref SetScissorsCommand command, ThreadedRenderer threaded, IRenderer renderer)
+ {
+ renderer.Pipeline.SetScissors(command._scissors.Get(threaded));
+
+ command._scissors.Dispose(threaded);
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetTextureAndSamplerCommand.cs b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetTextureAndSamplerCommand.cs
new file mode 100644
index 00000000..7ef58c3d
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetTextureAndSamplerCommand.cs
@@ -0,0 +1,28 @@
+using Ryujinx.Graphics.GAL.Multithreading.Model;
+using Ryujinx.Graphics.GAL.Multithreading.Resources;
+using Ryujinx.Graphics.Shader;
+
+namespace Ryujinx.Graphics.GAL.Multithreading.Commands
+{
+ struct SetTextureAndSamplerCommand : IGALCommand
+ {
+ public CommandType CommandType => CommandType.SetTextureAndSampler;
+ private ShaderStage _stage;
+ private int _binding;
+ private TableRef<ITexture> _texture;
+ private TableRef<ISampler> _sampler;
+
+ public void Set(ShaderStage stage, int binding, TableRef<ITexture> texture, TableRef<ISampler> sampler)
+ {
+ _stage = stage;
+ _binding = binding;
+ _texture = texture;
+ _sampler = sampler;
+ }
+
+ public static void Run(ref SetTextureAndSamplerCommand command, ThreadedRenderer threaded, IRenderer renderer)
+ {
+ renderer.Pipeline.SetTextureAndSampler(command._stage, command._binding, command._texture.GetAs<ThreadedTexture>(threaded)?.Base, command._sampler.GetAs<ThreadedSampler>(threaded)?.Base);
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetTextureCommand.cs b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetTextureCommand.cs
deleted file mode 100644
index e86f512b..00000000
--- a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetTextureCommand.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Ryujinx.Graphics.GAL.Multithreading.Model;
-using Ryujinx.Graphics.GAL.Multithreading.Resources;
-
-namespace Ryujinx.Graphics.GAL.Multithreading.Commands
-{
- struct SetTextureCommand : IGALCommand
- {
- public CommandType CommandType => CommandType.SetTexture;
- private int _binding;
- private TableRef<ITexture> _texture;
-
- public void Set(int binding, TableRef<ITexture> texture)
- {
- _binding = binding;
- _texture = texture;
- }
-
- public static void Run(ref SetTextureCommand command, ThreadedRenderer threaded, IRenderer renderer)
- {
- renderer.Pipeline.SetTexture(command._binding, command._texture.GetAs<ThreadedTexture>(threaded)?.Base);
- }
- }
-}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetViewportsCommand.cs b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetViewportsCommand.cs
index b208d9fe..61861f4d 100644
--- a/Ryujinx.Graphics.GAL/Multithreading/Commands/SetViewportsCommand.cs
+++ b/Ryujinx.Graphics.GAL/Multithreading/Commands/SetViewportsCommand.cs
@@ -7,13 +7,11 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands
struct SetViewportsCommand : IGALCommand
{
public CommandType CommandType => CommandType.SetViewports;
- private int _first;
private SpanRef<Viewport> _viewports;
private bool _disableTransform;
- public void Set(int first, SpanRef<Viewport> viewports, bool disableTransform)
+ public void Set(SpanRef<Viewport> viewports, bool disableTransform)
{
- _first = first;
_viewports = viewports;
_disableTransform = disableTransform;
}
@@ -21,7 +19,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands
public static void Run(ref SetViewportsCommand command, ThreadedRenderer threaded, IRenderer renderer)
{
ReadOnlySpan<Viewport> viewports = command._viewports.Get(threaded);
- renderer.Pipeline.SetViewports(command._first, viewports, command._disableTransform);
+ renderer.Pipeline.SetViewports(viewports, command._disableTransform);
command._viewports.Dispose(threaded);
}
}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs b/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs
index aebf210d..c462c559 100644
--- a/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs
+++ b/Ryujinx.Graphics.GAL/Multithreading/ThreadedPipeline.cs
@@ -1,6 +1,7 @@
using Ryujinx.Graphics.GAL.Multithreading.Commands;
using Ryujinx.Graphics.GAL.Multithreading.Model;
using Ryujinx.Graphics.GAL.Multithreading.Resources;
+using Ryujinx.Graphics.Shader;
using System;
using System.Linq;
@@ -250,15 +251,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading
_renderer.QueueCommand();
}
- public void SetSampler(int binding, ISampler sampler)
+ public void SetScissors(ReadOnlySpan<Rectangle<int>> scissors)
{
- _renderer.New<SetSamplerCommand>().Set(binding, Ref(sampler));
- _renderer.QueueCommand();
- }
-
- public void SetScissor(int index, bool enable, int x, int y, int width, int height)
- {
- _renderer.New<SetScissorCommand>().Set(index, enable, x, y, width, height);
+ _renderer.New<SetScissorsCommand>().Set(_renderer.CopySpan(scissors));
_renderer.QueueCommand();
}
@@ -274,9 +269,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading
_renderer.QueueCommand();
}
- public void SetTexture(int binding, ITexture texture)
+ public void SetTextureAndSampler(ShaderStage stage, int binding, ITexture texture, ISampler sampler)
{
- _renderer.New<SetTextureCommand>().Set(binding, Ref(texture));
+ _renderer.New<SetTextureAndSamplerCommand>().Set(stage, binding, Ref(texture), Ref(sampler));
_renderer.QueueCommand();
}
@@ -310,9 +305,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading
_renderer.QueueCommand();
}
- public void SetViewports(int first, ReadOnlySpan<Viewport> viewports, bool disableTransform)
+ public void SetViewports(ReadOnlySpan<Viewport> viewports, bool disableTransform)
{
- _renderer.New<SetViewportsCommand>().Set(first, _renderer.CopySpan(viewports), disableTransform);
+ _renderer.New<SetViewportsCommand>().Set(_renderer.CopySpan(viewports), disableTransform);
_renderer.QueueCommand();
}
diff --git a/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs b/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs
index 63b668ba..f05f37c9 100644
--- a/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs
+++ b/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs
@@ -76,7 +76,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
renderer.ScreenCaptured += (object sender, ScreenCaptureImageInfo info) => ScreenCaptured?.Invoke(this, info);
Pipeline = new ThreadedPipeline(this, renderer.Pipeline);
- Window = new ThreadedWindow(this, renderer.Window);
+ Window = new ThreadedWindow(this, renderer);
Buffers = new BufferMap();
Sync = new SyncMap();
Programs = new ProgramQueue(renderer);
@@ -262,7 +262,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading
public IProgram CreateProgram(ShaderSource[] shaders, ShaderInfo info)
{
var program = new ThreadedProgram(this);
+
SourceProgramRequest request = new SourceProgramRequest(program, shaders, info);
+
Programs.Add(request);
New<CreateProgramCommand>().Set(Ref((IProgramRequest)request));
@@ -337,6 +339,11 @@ namespace Ryujinx.Graphics.GAL.Multithreading
return box.Result;
}
+ public HardwareInfo GetHardwareInfo()
+ {
+ return _baseRenderer.GetHardwareInfo();
+ }
+
/// <summary>
/// Initialize the base renderer. Must be called on the render thread.
/// </summary>
diff --git a/Ryujinx.Graphics.GAL/Multithreading/ThreadedWindow.cs b/Ryujinx.Graphics.GAL/Multithreading/ThreadedWindow.cs
index dc0b4dc5..c8045502 100644
--- a/Ryujinx.Graphics.GAL/Multithreading/ThreadedWindow.cs
+++ b/Ryujinx.Graphics.GAL/Multithreading/ThreadedWindow.cs
@@ -8,12 +8,12 @@ namespace Ryujinx.Graphics.GAL.Multithreading
public class ThreadedWindow : IWindow
{
private ThreadedRenderer _renderer;
- private IWindow _impl;
+ private IRenderer _impl;
- public ThreadedWindow(ThreadedRenderer renderer, IWindow window)
+ public ThreadedWindow(ThreadedRenderer renderer, IRenderer impl)
{
_renderer = renderer;
- _impl = window;
+ _impl = impl;
}
public void Present(ITexture texture, ImageCrop crop, Action<object> swapBuffersCallback)
@@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
public void SetSize(int width, int height)
{
- _impl.SetSize(width, height);
+ _impl.Window.SetSize(width, height);
}
}
}