aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.GAL
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-05-23 06:46:09 -0300
committerGitHub <noreply@github.com>2020-05-23 11:46:09 +0200
commit5011640b3086b86b0f0b39b60fdb2aa946d4f5c8 (patch)
tree1bd60b7714886dfe282ca1e52cfa6fca97912cdf /Ryujinx.Graphics.GAL
parentcc8dbdd3fb58a02e1c3fc3b9d0b1c35bc7b9d00f (diff)
Spanify Graphics Abstraction Layer (#1226)
* Spanify Graphics Abstraction Layer * Be explicit about BufferHandle size
Diffstat (limited to 'Ryujinx.Graphics.GAL')
-rw-r--r--Ryujinx.Graphics.GAL/BufferHandle.cs22
-rw-r--r--Ryujinx.Graphics.GAL/BufferRange.cs8
-rw-r--r--Ryujinx.Graphics.GAL/IBuffer.cs15
-rw-r--r--Ryujinx.Graphics.GAL/IPipeline.cs11
-rw-r--r--Ryujinx.Graphics.GAL/IRenderer.cs8
5 files changed, 40 insertions, 24 deletions
diff --git a/Ryujinx.Graphics.GAL/BufferHandle.cs b/Ryujinx.Graphics.GAL/BufferHandle.cs
new file mode 100644
index 00000000..49f83442
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/BufferHandle.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+
+namespace Ryujinx.Graphics.GAL
+{
+ [StructLayout(LayoutKind.Sequential, Size = 8)]
+ public struct BufferHandle : IEquatable<BufferHandle>
+ {
+ private readonly ulong _value;
+
+ public static BufferHandle Null => new BufferHandle(0);
+
+ private BufferHandle(ulong value) => _value = value;
+
+ public override bool Equals(object obj) => obj is BufferHandle handle && Equals(handle);
+ public bool Equals([AllowNull] BufferHandle other) => other._value == _value;
+ public override int GetHashCode() => _value.GetHashCode();
+ public static bool operator ==(BufferHandle left, BufferHandle right) => left.Equals(right);
+ public static bool operator !=(BufferHandle left, BufferHandle right) => !(left == right);
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/BufferRange.cs b/Ryujinx.Graphics.GAL/BufferRange.cs
index a35636aa..34d523f9 100644
--- a/Ryujinx.Graphics.GAL/BufferRange.cs
+++ b/Ryujinx.Graphics.GAL/BufferRange.cs
@@ -2,18 +2,18 @@ namespace Ryujinx.Graphics.GAL
{
public struct BufferRange
{
- private static BufferRange _empty = new BufferRange(null, 0, 0);
+ private static readonly BufferRange _empty = new BufferRange(BufferHandle.Null, 0, 0);
public BufferRange Empty => _empty;
- public IBuffer Buffer { get; }
+ public BufferHandle Handle { get; }
public int Offset { get; }
public int Size { get; }
- public BufferRange(IBuffer buffer, int offset, int size)
+ public BufferRange(BufferHandle handle, int offset, int size)
{
- Buffer = buffer;
+ Handle = handle;
Offset = offset;
Size = size;
}
diff --git a/Ryujinx.Graphics.GAL/IBuffer.cs b/Ryujinx.Graphics.GAL/IBuffer.cs
deleted file mode 100644
index 43e37691..00000000
--- a/Ryujinx.Graphics.GAL/IBuffer.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace Ryujinx.Graphics.GAL
-{
- public interface IBuffer : IDisposable
- {
- void CopyTo(IBuffer destination, int srcOffset, int dstOffset, int size);
-
- byte[] GetData(int offset, int size);
-
- void SetData(ReadOnlySpan<byte> data);
-
- void SetData(int offset, ReadOnlySpan<byte> data);
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/IPipeline.cs b/Ryujinx.Graphics.GAL/IPipeline.cs
index 3bf7ab93..22e4e9e2 100644
--- a/Ryujinx.Graphics.GAL/IPipeline.cs
+++ b/Ryujinx.Graphics.GAL/IPipeline.cs
@@ -1,4 +1,5 @@
using Ryujinx.Graphics.Shader;
+using System;
namespace Ryujinx.Graphics.GAL
{
@@ -14,6 +15,8 @@ namespace Ryujinx.Graphics.GAL
int stencilValue,
int stencilMask);
+ void CopyBuffer(BufferHandle source, BufferHandle destination, int srcOffset, int dstOffset, int size);
+
void DispatchCompute(int groupsX, int groupsY, int groupsZ);
void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance);
@@ -49,7 +52,7 @@ namespace Ryujinx.Graphics.GAL
void SetRasterizerDiscard(bool discard);
- void SetRenderTargetColorMasks(uint[] componentMask);
+ void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask);
void SetRenderTargets(ITexture[] colors, ITexture depthStencil);
@@ -68,10 +71,10 @@ namespace Ryujinx.Graphics.GAL
void SetUserClipDistance(int index, bool enableClip);
- void SetVertexAttribs(VertexAttribDescriptor[] vertexAttribs);
- void SetVertexBuffers(VertexBufferDescriptor[] vertexBuffers);
+ void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs);
+ void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers);
- void SetViewports(int first, Viewport[] viewports);
+ void SetViewports(int first, ReadOnlySpan<Viewport> viewports);
void TextureBarrier();
void TextureBarrierTiled();
diff --git a/Ryujinx.Graphics.GAL/IRenderer.cs b/Ryujinx.Graphics.GAL/IRenderer.cs
index 4a45f5cb..c41b19fe 100644
--- a/Ryujinx.Graphics.GAL/IRenderer.cs
+++ b/Ryujinx.Graphics.GAL/IRenderer.cs
@@ -11,15 +11,21 @@ namespace Ryujinx.Graphics.GAL
IShader CompileShader(ShaderProgram shader);
- IBuffer CreateBuffer(int size);
+ BufferHandle CreateBuffer(int size);
IProgram CreateProgram(IShader[] shaders);
ISampler CreateSampler(SamplerCreateInfo info);
ITexture CreateTexture(TextureCreateInfo info);
+ void DeleteBuffer(BufferHandle buffer);
+
+ byte[] GetBufferData(BufferHandle buffer, int offset, int size);
+
Capabilities GetCapabilities();
+ void SetBufferData(BufferHandle buffer, int offset, ReadOnlySpan<byte> data);
+
void UpdateCounters();
ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler);