Spanify Graphics Abstraction Layer (#1226)
* Spanify Graphics Abstraction Layer * Be explicit about BufferHandle size
This commit is contained in:
parent
cc8dbdd3fb
commit
5011640b30
24 changed files with 208 additions and 134 deletions
|
@ -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)
|
||||
public static void SetData(BufferHandle buffer, int offset, 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)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue