Corrected issue with batch overflows
When a batch reach its vertex limit, a draw call is issued and batch restarted for refilling but if the draw call was issued for vertex data accumulated inside rlPushMatrix/rlPopMatrix, draw call was issued before the rlPopMatrix, consequently modelview matrix was not properly recovered before the draw call... obviously, it only happened the following draw calls, not the first one... Now it works ok but this system needs to reviewed, noticed and important frames drop when processing around 20 dynamic batch draw calls, it means filling MAX_QUADS_BATCH (8192) quads of data 20 times per frame, including data updating and sending for draw processing. Doing some maths, it means: Vertex data (float) -----> 8192 quads * 4 vertex * 3 comp * 4 byte = 393216 bytes Texcoords data (float) -> 8192 quads * 4 vertex * 2 comp * 4 byte = 262144 bytes Color data (uchar) -----> 8192 quads * 4 vertex * 4 comp * 1 byte = 131072 bytes Thats a total of 786432 bytes (0.75MB) sent to GPU 20 times per frame for processing... I'm testing in an Intel HD Graphics integrated, I imagine is too much data to be sent and and it causes stalls, so the frames drop...
This commit is contained in:
parent
732b775a1d
commit
506b7b8d7c
30
src/rlgl.h
30
src/rlgl.h
@ -1213,21 +1213,30 @@ void rlEnd(void)
|
||||
// NOTE: This check is combined with usage of rlCheckBufferLimit()
|
||||
if ((lines.vCounter/2 >= (MAX_LINES_BATCH - 2)) ||
|
||||
(triangles.vCounter/3 >= (MAX_TRIANGLES_BATCH - 3)) ||
|
||||
(quads.vCounter/4 >= (MAX_QUADS_BATCH - 4))) rlglDraw();
|
||||
(quads.vCounter/4 >= (MAX_QUADS_BATCH - 4)))
|
||||
{
|
||||
// WARNING: If we are between rlPushMatrix() and rlPopMatrix() and we need to force a rlglDraw(),
|
||||
// we need to call rlPopMatrix() before to recover *currentMatrix (modelview) for the next forced draw call!
|
||||
// Also noted that if we had multiple matrix pushed, it will require "stackCounter" pops before launching the draw
|
||||
|
||||
// TODO: Undoubtely, current rlPushMatrix/rlPopMatrix should be redesigned... or removed... it's not working properly
|
||||
|
||||
rlPopMatrix();
|
||||
rlglDraw();
|
||||
}
|
||||
}
|
||||
|
||||
// Define one vertex (position)
|
||||
void rlVertex3f(float x, float y, float z)
|
||||
{
|
||||
if (useTempBuffer)
|
||||
// NOTE: Temp buffer is processed and resetted at rlEnd()
|
||||
// Between rlBegin() and rlEnd() can not be more than TEMP_VERTEX_BUFFER_SIZE rlVertex3f() calls
|
||||
if (useTempBuffer && (tempBufferCount < TEMP_VERTEX_BUFFER_SIZE))
|
||||
{
|
||||
if (tempBufferCount < TEMP_VERTEX_BUFFER_SIZE)
|
||||
{
|
||||
tempBuffer[tempBufferCount].x = x;
|
||||
tempBuffer[tempBufferCount].y = y;
|
||||
tempBuffer[tempBufferCount].z = z;
|
||||
tempBufferCount++;
|
||||
}
|
||||
tempBuffer[tempBufferCount].x = x;
|
||||
tempBuffer[tempBufferCount].y = y;
|
||||
tempBuffer[tempBufferCount].z = z;
|
||||
tempBufferCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4321,9 +4330,6 @@ static void DrawBuffersDefault(void)
|
||||
quads.tcCounter = 0;
|
||||
quads.cCounter = 0;
|
||||
|
||||
tempBufferCount = 0;
|
||||
useTempBuffer = false;
|
||||
|
||||
// Reset depth for next draw
|
||||
currentDepth = -1.0f;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user