2018-06-25 22:10:54 -07:00
|
|
|
using OpenTK.Graphics.OpenGL;
|
2018-07-19 12:02:51 -07:00
|
|
|
using System;
|
2018-06-25 22:10:54 -07:00
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gal.OpenGL
|
|
|
|
{
|
2018-07-19 12:02:51 -07:00
|
|
|
class OGLStreamBuffer : IDisposable
|
2018-06-25 22:10:54 -07:00
|
|
|
{
|
|
|
|
public int Handle { get; protected set; }
|
|
|
|
|
2018-08-09 21:09:40 -07:00
|
|
|
public long Size { get; protected set; }
|
2018-06-25 22:10:54 -07:00
|
|
|
|
|
|
|
protected BufferTarget Target { get; private set; }
|
|
|
|
|
2018-08-09 21:09:40 -07:00
|
|
|
public OGLStreamBuffer(BufferTarget Target, long Size)
|
2018-06-25 22:10:54 -07:00
|
|
|
{
|
|
|
|
this.Target = Target;
|
2018-07-19 12:02:51 -07:00
|
|
|
this.Size = Size;
|
2018-06-25 22:10:54 -07:00
|
|
|
|
2018-07-19 12:02:51 -07:00
|
|
|
Handle = GL.GenBuffer();
|
2018-06-25 22:10:54 -07:00
|
|
|
|
2018-07-19 12:02:51 -07:00
|
|
|
GL.BindBuffer(Target, Handle);
|
2018-06-25 22:10:54 -07:00
|
|
|
|
2018-08-09 21:09:40 -07:00
|
|
|
GL.BufferData(Target, (IntPtr)Size, IntPtr.Zero, BufferUsageHint.StreamDraw);
|
2018-06-25 22:10:54 -07:00
|
|
|
}
|
|
|
|
|
2018-08-09 21:09:40 -07:00
|
|
|
public void SetData(long Size, IntPtr HostAddress)
|
2018-06-25 22:10:54 -07:00
|
|
|
{
|
2018-07-19 12:02:51 -07:00
|
|
|
GL.BindBuffer(Target, Handle);
|
2018-06-25 22:10:54 -07:00
|
|
|
|
2018-08-09 21:09:40 -07:00
|
|
|
GL.BufferSubData(Target, IntPtr.Zero, (IntPtr)Size, HostAddress);
|
2018-06-25 22:10:54 -07:00
|
|
|
}
|
|
|
|
|
2018-11-28 14:18:09 -08:00
|
|
|
public void SetData(byte[] Data)
|
|
|
|
{
|
|
|
|
GL.BindBuffer(Target, Handle);
|
|
|
|
|
|
|
|
GL.BufferSubData(Target, IntPtr.Zero, (IntPtr)Data.Length, Data);
|
|
|
|
}
|
|
|
|
|
2018-06-25 22:10:54 -07:00
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
Dispose(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool Disposing)
|
|
|
|
{
|
|
|
|
if (Disposing && Handle != 0)
|
|
|
|
{
|
|
|
|
GL.DeleteBuffer(Handle);
|
|
|
|
|
|
|
|
Handle = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-25 22:30:46 -07:00
|
|
|
}
|