0
0
Fork 0

Support instanced draw of quads" (#881)

This commit is contained in:
gdkchan 2020-01-12 19:14:50 -03:00 committed by jduncanator
parent 2bb39ff03e
commit 8b90924c1e

View file

@ -170,9 +170,17 @@ namespace Ryujinx.Graphics.OpenGL
int firstVertex, int firstVertex,
int firstInstance) int firstInstance)
{ {
// TODO: Instanced rendering.
int quadsCount = (vertexCount - 2) / 2; 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[] firsts = new int[quadsCount];
int[] counts = new int[quadsCount]; int[] counts = new int[quadsCount];
@ -191,6 +199,7 @@ namespace Ryujinx.Graphics.OpenGL
counts, counts,
quadsCount); quadsCount);
} }
}
private void DrawImpl( private void DrawImpl(
int vertexCount, int vertexCount,
@ -282,9 +291,52 @@ namespace Ryujinx.Graphics.OpenGL
int firstVertex, int firstVertex,
int firstInstance) int firstInstance)
{ {
// TODO: Instanced rendering.
int quadsCount = indexCount / 4; 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]; IntPtr[] indices = new IntPtr[quadsCount];
int[] counts = new int[quadsCount]; int[] counts = new int[quadsCount];
@ -308,6 +360,7 @@ namespace Ryujinx.Graphics.OpenGL
quadsCount, quadsCount,
baseVertices); baseVertices);
} }
}
private void DrawQuadStripIndexedImpl( private void DrawQuadStripIndexedImpl(
int indexCount, int indexCount,