aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.OpenGL/Buffer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Buffer.cs')
-rw-r--r--Ryujinx.Graphics.OpenGL/Buffer.cs43
1 files changed, 15 insertions, 28 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Buffer.cs b/Ryujinx.Graphics.OpenGL/Buffer.cs
index db3e94ba..e8fd9a6b 100644
--- a/Ryujinx.Graphics.OpenGL/Buffer.cs
+++ b/Ryujinx.Graphics.OpenGL/Buffer.cs
@@ -4,22 +4,22 @@ using System;
namespace Ryujinx.Graphics.OpenGL
{
- class Buffer : IBuffer
+ static class Buffer
{
- public int Handle { get; }
-
- public Buffer(int size)
+ public static BufferHandle Create(int size)
{
- Handle = GL.GenBuffer();
+ int handle = GL.GenBuffer();
- GL.BindBuffer(BufferTarget.CopyWriteBuffer, Handle);
+ GL.BindBuffer(BufferTarget.CopyWriteBuffer, handle);
GL.BufferData(BufferTarget.CopyWriteBuffer, size, IntPtr.Zero, BufferUsageHint.DynamicDraw);
+
+ return Handle.FromInt32<BufferHandle>(handle);
}
- public void CopyTo(IBuffer destination, int srcOffset, int dstOffset, int size)
+ public static void Copy(BufferHandle source, BufferHandle destination, int srcOffset, int dstOffset, int size)
{
- GL.BindBuffer(BufferTarget.CopyReadBuffer, Handle);
- GL.BindBuffer(BufferTarget.CopyWriteBuffer, ((Buffer)destination).Handle);
+ GL.BindBuffer(BufferTarget.CopyReadBuffer, source.ToInt32());
+ GL.BindBuffer(BufferTarget.CopyWriteBuffer, destination.ToInt32());
GL.CopyBufferSubData(
BufferTarget.CopyReadBuffer,
@@ -29,9 +29,9 @@ namespace Ryujinx.Graphics.OpenGL
(IntPtr)size);
}
- public byte[] GetData(int offset, int size)
+ public static byte[] GetData(BufferHandle buffer, int offset, int size)
{
- GL.BindBuffer(BufferTarget.CopyReadBuffer, Handle);
+ GL.BindBuffer(BufferTarget.CopyReadBuffer, buffer.ToInt32());
byte[] data = new byte[size];
@@ -40,22 +40,9 @@ namespace Ryujinx.Graphics.OpenGL
return data;
}
- public void SetData(ReadOnlySpan<byte> data)
- {
- unsafe
- {
- GL.BindBuffer(BufferTarget.CopyWriteBuffer, Handle);
-
- fixed (byte* ptr = data)
- {
- GL.BufferData(BufferTarget.CopyWriteBuffer, data.Length, (IntPtr)ptr, BufferUsageHint.DynamicDraw);
- }
- }
- }
-
- public void SetData(int offset, ReadOnlySpan<byte> data)
+ public static void SetData(BufferHandle buffer, int offset, ReadOnlySpan<byte> data)
{
- GL.BindBuffer(BufferTarget.CopyWriteBuffer, Handle);
+ GL.BindBuffer(BufferTarget.CopyWriteBuffer, buffer.ToInt32());
unsafe
{
@@ -66,9 +53,9 @@ namespace Ryujinx.Graphics.OpenGL
}
}
- public void Dispose()
+ public static void Delete(BufferHandle buffer)
{
- GL.DeleteBuffer(Handle);
+ GL.DeleteBuffer(buffer.ToInt32());
}
}
}