SpriteRenderer, do not copy vertex array data each flush.

This commit is contained in:
Vapre
2021-07-17 00:03:12 +02:00
committed by abcdefg30
parent 243e2b2a2a
commit 7005da3592
6 changed files with 43 additions and 3 deletions

View File

@@ -404,6 +404,11 @@ namespace OpenRA.Platforms.Default
return Send(getCreateVertexBuffer, length);
}
public Vertex[] CreateVertices(int size)
{
return GetVertices(size);
}
public void DisableDepthBuffer()
{
Post(doDisableDepthBuffer);
@@ -526,6 +531,16 @@ namespace OpenRA.Platforms.Default
device.Post(setData1, (buffer, length));
}
/// <summary>
/// PERF: The vertices array is passed without copying to the render thread. Upon return `vertices` may reference another
/// array object of at least the same size - containing random values.
/// </summary>
public void SetData(ref Vertex[] vertices, int length)
{
device.Post(setData1, (vertices, length));
vertices = device.GetVertices(vertices.Length);
}
public void SetData(Vertex[] vertices, int offset, int start, int length)
{
if (length <= device.BatchSize)