Improve performance by swapping render groups
Last used render groups are brought to front of render list when searching for valid group- as per- recently used items are likely to be used again.
This commit is contained in:
parent
72d30b6320
commit
82421ca64c
@ -13,6 +13,11 @@
|
||||
INTERNAL void addVertexToRenderGroup(Renderer *renderer, Texture *tex, v4 color,
|
||||
Vertex *vertexList, i32 numVertexes)
|
||||
{
|
||||
|
||||
#ifdef DENGINE_DEBUG
|
||||
ASSERT(numVertexes > 0);
|
||||
#endif
|
||||
|
||||
/* Find vacant/matching render group */
|
||||
RenderGroup *targetGroup = NULL;
|
||||
for (i32 i = 0; i < ARRAY_COUNT(renderer->groups); i++)
|
||||
@ -46,7 +51,13 @@ INTERNAL void addVertexToRenderGroup(Renderer *renderer, Texture *tex, v4 color,
|
||||
i32 freeVertexSlots = renderer->groupCapacity - group->vertexIndex;
|
||||
if (numVertexes < freeVertexSlots)
|
||||
{
|
||||
targetGroup = &renderer->groups[i];
|
||||
if (i != 0)
|
||||
{
|
||||
RenderGroup tmp = renderer->groups[0];
|
||||
renderer->groups[0] = renderer->groups[i];
|
||||
renderer->groups[i] = tmp;
|
||||
}
|
||||
targetGroup = &renderer->groups[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -289,6 +300,7 @@ void renderer_string(Renderer *const renderer, MemoryArena *arena, Rect camera,
|
||||
v2 pivotPoint, f32 rotate, v4 color)
|
||||
{
|
||||
i32 strLen = common_strlen(string);
|
||||
if (strLen <= 0) return;
|
||||
|
||||
// TODO(doyle): Slightly incorrect string length in pixels calculation,
|
||||
// because we use the advance metric of each character for length not
|
||||
|
@ -101,7 +101,7 @@ INTERNAL void rendererInit(GameState *state, v2 windowSize)
|
||||
GL_CHECK_ERROR();
|
||||
|
||||
// TODO(doyle): Lazy allocate render group capacity
|
||||
renderer->groupCapacity = 1024;
|
||||
renderer->groupCapacity = 4096;
|
||||
for (i32 i = 0; i < ARRAY_COUNT(renderer->groups); i++)
|
||||
{
|
||||
renderer->groups[i].vertexList =
|
||||
|
@ -224,9 +224,14 @@ i32 main(void)
|
||||
f32 msPerFrame = secondsElapsed * 1000.0f;
|
||||
f32 framesPerSecond = 1.0f / secondsElapsed;
|
||||
|
||||
i32 entityCount =
|
||||
worldTraveller.world[worldTraveller.currWorldIndex]
|
||||
.freeEntityIndex;
|
||||
|
||||
char textBuffer[256];
|
||||
snprintf(textBuffer, ARRAY_COUNT(textBuffer),
|
||||
"Dengine | %f ms/f | %f fps", msPerFrame, framesPerSecond);
|
||||
"Dengine | %f ms/f | %f fps | Entity Count: %d",
|
||||
msPerFrame, framesPerSecond, entityCount);
|
||||
|
||||
glfwSetWindowTitle(window, textBuffer);
|
||||
titleUpdateFrequencyInSeconds = 0.5f;
|
||||
|
Loading…
Reference in New Issue
Block a user