aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-06-28 20:48:18 -0300
committerGitHub <noreply@github.com>2018-06-28 20:48:18 -0300
commit3e81421b2f8789fd2e57124dd6805e031e1a2a9f (patch)
treefe54fbb1d6982e2e5f4e2d81584113fd86e22529
parent3262fd13dadb98b189e8e8447aacc4762845bbe5 (diff)
Add support for vertex base on indexed draws, fix index buffer first (untested) (#197)
-rw-r--r--Ryujinx.Graphics/Gal/IGalRasterizer.cs2
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs18
-rw-r--r--Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs4
3 files changed, 20 insertions, 4 deletions
diff --git a/Ryujinx.Graphics/Gal/IGalRasterizer.cs b/Ryujinx.Graphics/Gal/IGalRasterizer.cs
index 45f92f27..e0469382 100644
--- a/Ryujinx.Graphics/Gal/IGalRasterizer.cs
+++ b/Ryujinx.Graphics/Gal/IGalRasterizer.cs
@@ -28,6 +28,6 @@ namespace Ryujinx.Graphics.Gal
void DrawArrays(int First, int PrimCount, GalPrimitiveType PrimType);
- void DrawElements(long IboKey, int First, GalPrimitiveType PrimType);
+ void DrawElements(long IboKey, int First, int VertexBase, GalPrimitiveType PrimType);
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs
index ebd1e8d1..8bff6bb3 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs
@@ -54,6 +54,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
private struct IbInfo
{
public int Count;
+ public int ElemSizeLog2;
public DrawElementsType Type;
}
@@ -206,6 +207,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
IndexBuffer.Type = OGLEnumConverter.GetDrawElementsType(Format);
IndexBuffer.Count = Size >> (int)Format;
+
+ IndexBuffer.ElemSizeLog2 = (int)Format;
}
public void DrawArrays(int First, int PrimCount, GalPrimitiveType PrimType)
@@ -220,7 +223,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GL.DrawArrays(OGLEnumConverter.GetPrimitiveType(PrimType), First, PrimCount);
}
- public void DrawElements(long IboKey, int First, GalPrimitiveType PrimType)
+ public void DrawElements(long IboKey, int First, int VertexBase, GalPrimitiveType PrimType)
{
if (!IboCache.TryGetValue(IboKey, out int IboHandle))
{
@@ -233,7 +236,18 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GL.BindBuffer(BufferTarget.ElementArrayBuffer, IboHandle);
- GL.DrawElements(Mode, IndexBuffer.Count, IndexBuffer.Type, First);
+ First <<= IndexBuffer.ElemSizeLog2;
+
+ if (VertexBase != 0)
+ {
+ IntPtr Indices = new IntPtr(First);
+
+ GL.DrawElementsBaseVertex(Mode, IndexBuffer.Count, IndexBuffer.Type, Indices, VertexBase);
+ }
+ else
+ {
+ GL.DrawElements(Mode, IndexBuffer.Count, IndexBuffer.Type, First);
+ }
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs
index 56cb7688..b27f5c14 100644
--- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs
+++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs
@@ -487,7 +487,9 @@ namespace Ryujinx.HLE.Gpu.Engines
if (IndexCount != 0)
{
- Gpu.Renderer.Rasterizer.DrawElements(IndexPosition, IndexFirst, PrimType);
+ int VertexBase = ReadRegister(NvGpuEngine3dReg.VertexArrayElemBase);
+
+ Gpu.Renderer.Rasterizer.DrawElements(IndexPosition, IndexFirst, VertexBase, PrimType);
}
else
{