aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.GAL
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Graphics.GAL')
-rw-r--r--src/Ryujinx.Graphics.GAL/BufferAccess.cs10
-rw-r--r--src/Ryujinx.Graphics.GAL/Capabilities.cs3
-rw-r--r--src/Ryujinx.Graphics.GAL/IRenderer.cs9
-rw-r--r--src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs1
-rw-r--r--src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs1
-rw-r--r--src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferCommand.cs6
-rw-r--r--src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferSparseCommand.cs25
-rw-r--r--src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs17
8 files changed, 57 insertions, 15 deletions
diff --git a/src/Ryujinx.Graphics.GAL/BufferAccess.cs b/src/Ryujinx.Graphics.GAL/BufferAccess.cs
index e7d7ceb0..faefa518 100644
--- a/src/Ryujinx.Graphics.GAL/BufferAccess.cs
+++ b/src/Ryujinx.Graphics.GAL/BufferAccess.cs
@@ -1,9 +1,13 @@
+using System;
+
namespace Ryujinx.Graphics.GAL
{
+ [Flags]
public enum BufferAccess
{
- Default,
- FlushPersistent,
- Stream
+ Default = 0,
+ FlushPersistent = 1 << 0,
+ Stream = 1 << 1,
+ SparseCompatible = 1 << 2,
}
}
diff --git a/src/Ryujinx.Graphics.GAL/Capabilities.cs b/src/Ryujinx.Graphics.GAL/Capabilities.cs
index 8959bf93..dc927eab 100644
--- a/src/Ryujinx.Graphics.GAL/Capabilities.cs
+++ b/src/Ryujinx.Graphics.GAL/Capabilities.cs
@@ -23,6 +23,7 @@ namespace Ryujinx.Graphics.GAL
public readonly bool SupportsR4G4B4A4Format;
public readonly bool SupportsScaledVertexFormats;
public readonly bool SupportsSnormBufferTextureFormat;
+ public readonly bool SupportsSparseBuffer;
public readonly bool Supports5BitComponentFormat;
public readonly bool SupportsBlendEquationAdvanced;
public readonly bool SupportsFragmentShaderInterlock;
@@ -79,6 +80,7 @@ namespace Ryujinx.Graphics.GAL
bool supportsScaledVertexFormats,
bool supportsSnormBufferTextureFormat,
bool supports5BitComponentFormat,
+ bool supportsSparseBuffer,
bool supportsBlendEquationAdvanced,
bool supportsFragmentShaderInterlock,
bool supportsFragmentShaderOrderingIntel,
@@ -130,6 +132,7 @@ namespace Ryujinx.Graphics.GAL
SupportsScaledVertexFormats = supportsScaledVertexFormats;
SupportsSnormBufferTextureFormat = supportsSnormBufferTextureFormat;
Supports5BitComponentFormat = supports5BitComponentFormat;
+ SupportsSparseBuffer = supportsSparseBuffer;
SupportsBlendEquationAdvanced = supportsBlendEquationAdvanced;
SupportsFragmentShaderInterlock = supportsFragmentShaderInterlock;
SupportsFragmentShaderOrderingIntel = supportsFragmentShaderOrderingIntel;
diff --git a/src/Ryujinx.Graphics.GAL/IRenderer.cs b/src/Ryujinx.Graphics.GAL/IRenderer.cs
index 1dabbdae..3bf56465 100644
--- a/src/Ryujinx.Graphics.GAL/IRenderer.cs
+++ b/src/Ryujinx.Graphics.GAL/IRenderer.cs
@@ -16,13 +16,10 @@ namespace Ryujinx.Graphics.GAL
void BackgroundContextAction(Action action, bool alwaysBackground = false);
- BufferHandle CreateBuffer(int size, BufferHandle storageHint);
- BufferHandle CreateBuffer(int size)
- {
- return CreateBuffer(size, BufferHandle.Null);
- }
+ BufferHandle CreateBuffer(int size, BufferAccess access = BufferAccess.Default);
+ BufferHandle CreateBuffer(int size, BufferAccess access, BufferHandle storageHint);
BufferHandle CreateBuffer(nint pointer, int size);
- BufferHandle CreateBuffer(int size, BufferAccess access);
+ BufferHandle CreateBufferSparse(ReadOnlySpan<BufferRange> storageBuffers);
IProgram CreateProgram(ShaderSource[] shaders, ShaderInfo info);
diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs b/src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs
index 8feeacf4..5bf3d328 100644
--- a/src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs
@@ -44,6 +44,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
Register<ActionCommand>(CommandType.Action);
Register<CreateBufferCommand>(CommandType.CreateBuffer);
Register<CreateBufferAccessCommand>(CommandType.CreateBufferAccess);
+ Register<CreateBufferSparseCommand>(CommandType.CreateBufferSparse);
Register<CreateHostBufferCommand>(CommandType.CreateHostBuffer);
Register<CreateProgramCommand>(CommandType.CreateProgram);
Register<CreateSamplerCommand>(CommandType.CreateSampler);
diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs b/src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs
index 55a04573..6be63925 100644
--- a/src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs
@@ -5,6 +5,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
Action,
CreateBuffer,
CreateBufferAccess,
+ CreateBufferSparse,
CreateHostBuffer,
CreateProgram,
CreateSampler,
diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferCommand.cs
index 353227b6..60a6e4bf 100644
--- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferCommand.cs
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferCommand.cs
@@ -5,12 +5,14 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
public readonly CommandType CommandType => CommandType.CreateBuffer;
private BufferHandle _threadedHandle;
private int _size;
+ private BufferAccess _access;
private BufferHandle _storageHint;
- public void Set(BufferHandle threadedHandle, int size, BufferHandle storageHint)
+ public void Set(BufferHandle threadedHandle, int size, BufferAccess access, BufferHandle storageHint)
{
_threadedHandle = threadedHandle;
_size = size;
+ _access = access;
_storageHint = storageHint;
}
@@ -23,7 +25,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
hint = threaded.Buffers.MapBuffer(command._storageHint);
}
- threaded.Buffers.AssignBuffer(command._threadedHandle, renderer.CreateBuffer(command._size, hint));
+ threaded.Buffers.AssignBuffer(command._threadedHandle, renderer.CreateBuffer(command._size, command._access, hint));
}
}
}
diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferSparseCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferSparseCommand.cs
new file mode 100644
index 00000000..965529ad
--- /dev/null
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferSparseCommand.cs
@@ -0,0 +1,25 @@
+using Ryujinx.Graphics.GAL.Multithreading.Model;
+using System;
+
+namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
+{
+ struct CreateBufferSparseCommand : IGALCommand, IGALCommand<CreateBufferSparseCommand>
+ {
+ public readonly CommandType CommandType => CommandType.CreateBufferSparse;
+ private BufferHandle _threadedHandle;
+ private SpanRef<BufferRange> _buffers;
+
+ public void Set(BufferHandle threadedHandle, SpanRef<BufferRange> buffers)
+ {
+ _threadedHandle = threadedHandle;
+ _buffers = buffers;
+ }
+
+ public static void Run(ref CreateBufferSparseCommand command, ThreadedRenderer threaded, IRenderer renderer)
+ {
+ Span<BufferRange> buffers = command._buffers.Get(threaded);
+ threaded.Buffers.AssignBuffer(command._threadedHandle, renderer.CreateBufferSparse(threaded.Buffers.MapBufferRanges(buffers)));
+ command._buffers.Dispose(threaded);
+ }
+ }
+}
diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs
index 0e0031b0..830fbf2d 100644
--- a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs
@@ -263,10 +263,19 @@ namespace Ryujinx.Graphics.GAL.Multithreading
}
}
- public BufferHandle CreateBuffer(int size, BufferHandle storageHint)
+ public BufferHandle CreateBuffer(int size, BufferAccess access)
{
BufferHandle handle = Buffers.CreateBufferHandle();
- New<CreateBufferCommand>().Set(handle, size, storageHint);
+ New<CreateBufferAccessCommand>().Set(handle, size, access);
+ QueueCommand();
+
+ return handle;
+ }
+
+ public BufferHandle CreateBuffer(int size, BufferAccess access, BufferHandle storageHint)
+ {
+ BufferHandle handle = Buffers.CreateBufferHandle();
+ New<CreateBufferCommand>().Set(handle, size, access, storageHint);
QueueCommand();
return handle;
@@ -281,10 +290,10 @@ namespace Ryujinx.Graphics.GAL.Multithreading
return handle;
}
- public BufferHandle CreateBuffer(int size, BufferAccess access)
+ public BufferHandle CreateBufferSparse(ReadOnlySpan<BufferRange> storageBuffers)
{
BufferHandle handle = Buffers.CreateBufferHandle();
- New<CreateBufferAccessCommand>().Set(handle, size, access);
+ New<CreateBufferSparseCommand>().Set(handle, CopySpan(storageBuffers));
QueueCommand();
return handle;