Support instanced draw of quads"

This commit is contained in:
gdkchan 2020-01-12 03:41:19 -03:00
commit 44b73329c7

View file

@ -165,9 +165,17 @@ namespace Ryujinx.Graphics.OpenGL
int firstVertex,
int firstInstance)
{
// TODO: Instanced rendering.
int quadsCount = (vertexCount - 2) / 2;
if (firstInstance != 0 || instanceCount != 1)
{
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
{
GL.DrawArraysInstancedBaseInstance(PrimitiveType.TriangleFan, firstVertex + quadIndex * 2, 4, instanceCount, firstInstance);
}
}
else
{
int[] firsts = new int[quadsCount];
int[] counts = new int[quadsCount];
@ -186,6 +194,7 @@ namespace Ryujinx.Graphics.OpenGL
counts,
quadsCount);
}
}
private void DrawImpl(
int vertexCount,
@ -277,9 +286,52 @@ namespace Ryujinx.Graphics.OpenGL
int firstVertex,
int firstInstance)
{
// TODO: Instanced rendering.
int quadsCount = indexCount / 4;
if (firstInstance != 0 || instanceCount != 1)
{
if (firstVertex != 0 && firstInstance != 0)
{
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
{
GL.DrawElementsInstancedBaseVertexBaseInstance(
PrimitiveType.TriangleFan,
4,
_elementsType,
indexBaseOffset + quadIndex * 4 * indexElemSize,
instanceCount,
firstVertex,
firstInstance);
}
}
else if (firstInstance != 0)
{
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
{
GL.DrawElementsInstancedBaseInstance(
PrimitiveType.TriangleFan,
4,
_elementsType,
indexBaseOffset + quadIndex * 4 * indexElemSize,
instanceCount,
firstInstance);
}
}
else
{
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
{
GL.DrawElementsInstanced(
PrimitiveType.TriangleFan,
4,
_elementsType,
indexBaseOffset + quadIndex * 4 * indexElemSize,
instanceCount);
}
}
}
else
{
IntPtr[] indices = new IntPtr[quadsCount];
int[] counts = new int[quadsCount];
@ -303,6 +355,7 @@ namespace Ryujinx.Graphics.OpenGL
quadsCount,
baseVertices);
}
}
private void DrawQuadStripIndexedImpl(
int indexCount,