aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-06-08 21:15:56 -0300
committerGitHub <noreply@github.com>2018-06-08 21:15:56 -0300
commit231fae1a4c97d7588655e9775f37c1dc9bd55fb0 (patch)
tree1c0e7b298ec33d5bf5b6a5693dd69a8c7e0bd23b /Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
parent6fe51f970501fe732276c17ed0dacb564b92a73d (diff)
Texture/Vertex/Index data cache (#132)
* Initial implementation of the texture cache * Cache vertex and index data aswell, some cleanup * Improve handling of the cache by storing cached ranges on a list for each page * Delete old data from the caches automatically, ensure that the cache is cleaned when the mapping/size changes, and some general cleanup
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs')
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs65
1 files changed, 39 insertions, 26 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
index 69e344c7..4c4bd2ca 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
@@ -156,46 +156,54 @@ namespace Ryujinx.Graphics.Gal.OpenGL
ActionsQueue.Enqueue(() => Rasterizer.ClearBuffers(RtIndex, Flags));
}
- public void SetVertexArray(int VbIndex, int Stride, byte[] Buffer, GalVertexAttrib[] Attribs)
+ public bool IsVboCached(long Tag, long DataSize)
{
- if ((uint)VbIndex > 31)
- {
- throw new ArgumentOutOfRangeException(nameof(VbIndex));
- }
+ return Rasterizer.IsVboCached(Tag, DataSize);
+ }
- ActionsQueue.Enqueue(() => Rasterizer.SetVertexArray(VbIndex, Stride,
- Buffer ?? throw new ArgumentNullException(nameof(Buffer)),
- Attribs ?? throw new ArgumentNullException(nameof(Attribs))));
+ public bool IsIboCached(long Tag, long DataSize)
+ {
+ return Rasterizer.IsIboCached(Tag, DataSize);
}
- public void SetIndexArray(byte[] Buffer, GalIndexFormat Format)
+ public void CreateVbo(long Tag, byte[] Buffer)
{
- if (Buffer == null)
- {
- throw new ArgumentNullException(nameof(Buffer));
- }
+ ActionsQueue.Enqueue(() => Rasterizer.CreateVbo(Tag, Buffer));
+ }
- ActionsQueue.Enqueue(() => Rasterizer.SetIndexArray(Buffer, Format));
+ public void CreateIbo(long Tag, byte[] Buffer)
+ {
+ ActionsQueue.Enqueue(() => Rasterizer.CreateIbo(Tag, Buffer));
}
- public void DrawArrays(int VbIndex, int First, int PrimCount, GalPrimitiveType PrimType)
+ public void SetVertexArray(int VbIndex, int Stride, long VboTag, GalVertexAttrib[] Attribs)
{
if ((uint)VbIndex > 31)
{
throw new ArgumentOutOfRangeException(nameof(VbIndex));
}
- ActionsQueue.Enqueue(() => Rasterizer.DrawArrays(VbIndex, First, PrimCount, PrimType));
+ if (Attribs == null)
+ {
+ throw new ArgumentNullException(nameof(Attribs));
+ }
+
+ ActionsQueue.Enqueue(() => Rasterizer.SetVertexArray(VbIndex, Stride, VboTag, Attribs));
}
- public void DrawElements(int VbIndex, int First, GalPrimitiveType PrimType)
+ public void SetIndexArray(long Tag, int Size, GalIndexFormat Format)
{
- if ((uint)VbIndex > 31)
- {
- throw new ArgumentOutOfRangeException(nameof(VbIndex));
- }
+ ActionsQueue.Enqueue(() => Rasterizer.SetIndexArray(Tag, Size, Format));
+ }
+
+ public void DrawArrays(int First, int PrimCount, GalPrimitiveType PrimType)
+ {
+ ActionsQueue.Enqueue(() => Rasterizer.DrawArrays(First, PrimCount, PrimType));
+ }
- ActionsQueue.Enqueue(() => Rasterizer.DrawElements(VbIndex, First, PrimType));
+ public void DrawElements(long IboTag, int First, GalPrimitiveType PrimType)
+ {
+ ActionsQueue.Enqueue(() => Rasterizer.DrawElements(IboTag, First, PrimType));
}
public void CreateShader(IGalMemory Memory, long Tag, GalShaderType Type)
@@ -253,19 +261,24 @@ namespace Ryujinx.Graphics.Gal.OpenGL
ActionsQueue.Enqueue(() => Shader.BindProgram());
}
- public void SetTextureAndSampler(int Index, GalTexture Texture, GalTextureSampler Sampler)
+ public void SetTextureAndSampler(long Tag, byte[] Data, GalTexture Texture, GalTextureSampler Sampler)
{
ActionsQueue.Enqueue(() =>
{
- this.Texture.Set(Index, Texture);
+ this.Texture.Create(Tag, Data, Texture);
OGLTexture.Set(Sampler);
});
}
- public void BindTexture(int Index)
+ public bool TryGetCachedTexture(long Tag, long DataSize, out GalTexture Texture)
+ {
+ return this.Texture.TryGetCachedTexture(Tag, DataSize, out Texture);
+ }
+
+ public void BindTexture(long Tag, int Index)
{
- ActionsQueue.Enqueue(() => Texture.Bind(Index));
+ ActionsQueue.Enqueue(() => Texture.Bind(Tag, Index));
}
}
} \ No newline at end of file