Small OpenGL Renderer refactoring (#177)
* Call OpenGL functions directly, remove the pfifo thread, some refactoring * Fix PerformanceStatistics calculating the wrong host fps, remove wait event on PFIFO as this wasn't exactly was causing the freezes (may replace with an exception later) * Organized the Gpu folder a bit more, renamed a few things, address PR feedback * Make PerformanceStatistics thread safe * Remove unused constant * Use unlimited update rate for better pref
This commit is contained in:
parent
69697957e6
commit
e7559f128f
58 changed files with 518 additions and 633 deletions
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
{
|
||||
class OGLRasterizer
|
||||
public class OGLRasterizer : IGalRasterizer
|
||||
{
|
||||
private static Dictionary<GalVertexAttribSize, int> AttribElements =
|
||||
new Dictionary<GalVertexAttribSize, int>()
|
||||
|
@ -74,8 +74,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{
|
||||
ClearBufferMask Mask = 0;
|
||||
|
||||
//OpenGL doesn't support clearing just a single color channel,
|
||||
//so we can't just clear all channels...
|
||||
//TODO: Use glColorMask to clear just the specified channels.
|
||||
if (Flags.HasFlag(GalClearBufferFlags.ColorRed) &&
|
||||
Flags.HasFlag(GalClearBufferFlags.ColorGreen) &&
|
||||
Flags.HasFlag(GalClearBufferFlags.ColorBlue) &&
|
||||
|
@ -97,45 +96,43 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
GL.Clear(Mask);
|
||||
}
|
||||
|
||||
public bool IsVboCached(long Tag, long DataSize)
|
||||
public bool IsVboCached(long Key, long DataSize)
|
||||
{
|
||||
return VboCache.TryGetSize(Tag, out long Size) && Size == DataSize;
|
||||
return VboCache.TryGetSize(Key, out long Size) && Size == DataSize;
|
||||
}
|
||||
|
||||
public bool IsIboCached(long Tag, long DataSize)
|
||||
public bool IsIboCached(long Key, long DataSize)
|
||||
{
|
||||
return IboCache.TryGetSize(Tag, out long Size) && Size == DataSize;
|
||||
return IboCache.TryGetSize(Key, out long Size) && Size == DataSize;
|
||||
}
|
||||
|
||||
public void CreateVbo(long Tag, byte[] Buffer)
|
||||
public void CreateVbo(long Key, byte[] Buffer)
|
||||
{
|
||||
int Handle = GL.GenBuffer();
|
||||
|
||||
VboCache.AddOrUpdate(Tag, Handle, (uint)Buffer.Length);
|
||||
VboCache.AddOrUpdate(Key, Handle, (uint)Buffer.Length);
|
||||
|
||||
IntPtr Length = new IntPtr(Buffer.Length);
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, Handle);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, Length, Buffer, BufferUsageHint.StreamDraw);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||
}
|
||||
|
||||
public void CreateIbo(long Tag, byte[] Buffer)
|
||||
public void CreateIbo(long Key, byte[] Buffer)
|
||||
{
|
||||
int Handle = GL.GenBuffer();
|
||||
|
||||
IboCache.AddOrUpdate(Tag, Handle, (uint)Buffer.Length);
|
||||
IboCache.AddOrUpdate(Key, Handle, (uint)Buffer.Length);
|
||||
|
||||
IntPtr Length = new IntPtr(Buffer.Length);
|
||||
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, Handle);
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, Length, Buffer, BufferUsageHint.StreamDraw);
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
|
||||
}
|
||||
|
||||
public void SetVertexArray(int VbIndex, int Stride, long VboTag, GalVertexAttrib[] Attribs)
|
||||
public void SetVertexArray(int VbIndex, int Stride, long VboKey, GalVertexAttrib[] Attribs)
|
||||
{
|
||||
if (!VboCache.TryGetValue(VboTag, out int VboHandle))
|
||||
if (!VboCache.TryGetValue(VboKey, out int VboHandle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -178,11 +175,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
GL.VertexAttribPointer(Attrib.Index, Size, Type, Normalize, Stride, Offset);
|
||||
}
|
||||
|
||||
GL.BindVertexArray(0);
|
||||
}
|
||||
|
||||
public void SetIndexArray(long Tag, int Size, GalIndexFormat Format)
|
||||
public void SetIndexArray(long Key, int Size, GalIndexFormat Format)
|
||||
{
|
||||
IndexBuffer.Type = OGLEnumConverter.GetDrawElementsType(Format);
|
||||
|
||||
|
@ -201,9 +196,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
GL.DrawArrays(OGLEnumConverter.GetPrimitiveType(PrimType), First, PrimCount);
|
||||
}
|
||||
|
||||
public void DrawElements(long IboTag, int First, GalPrimitiveType PrimType)
|
||||
public void DrawElements(long IboKey, int First, GalPrimitiveType PrimType)
|
||||
{
|
||||
if (!IboCache.TryGetValue(IboTag, out int IboHandle))
|
||||
if (!IboCache.TryGetValue(IboKey, out int IboHandle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue