Fix not swapping buffers because out of cmd buffer space

Reserve space for end of list and swap buffer commands. These are absolutely
required and cannot be dropped. Dropping swap buffer command causes screen
to not update and possible crash from drawsurf buffer overflow if not enough
cmd buffer space for many continous frames.
This commit is contained in:
Zack Middleton committed 2015-10-16 19:38:49 -05:00
1 parent ce35188acd
commit 8531162bd9
2 files changed
+30 -8

No files matched your search

+15 -4
View File
@@ -114,19 +114,19 @@ void R_IssuePendingRenderCommands( void ) {
/*
============
R_GetCommandBuffer
R_GetCommandBufferReserved
make sure there is enough command space
============
*/
void *R_GetCommandBuffer( int bytes ) {
void *R_GetCommandBufferReserved( int bytes, int reservedBytes ) {
renderCommandList_t *cmdList;
cmdList = &backEndData->commands;
bytes = PAD(bytes, sizeof(void *));
// always leave room for the end of list command
if ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) {
if ( cmdList->used + bytes + 4 + reservedBytes > MAX_RENDER_COMMANDS ) {
if ( bytes > MAX_RENDER_COMMANDS - 4 ) {
ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes );
}
@@ -139,6 +139,17 @@ void *R_GetCommandBuffer( int bytes ) {
return cmdList->cmds + cmdList->used - bytes;
}
/*
=============
R_GetCommandBuffer
returns NULL if there is not enough space for important commands
=============
*/
void *R_GetCommandBuffer( int bytes ) {
return R_GetCommandBufferReserved( bytes, sizeof ( swapBuffersCommand_t ) );
}
/*
=============
@@ -454,7 +465,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) {
if ( !tr.registered ) {
return;
}
cmd = R_GetCommandBuffer( sizeof( *cmd ) );
cmd = R_GetCommandBufferReserved( sizeof( *cmd ), 0 );
if ( !cmd ) {
return;
}
+15 -4
View File
@@ -121,19 +121,19 @@ void R_IssuePendingRenderCommands( void ) {
/*
============
R_GetCommandBuffer
R_GetCommandBufferReserved
make sure there is enough command space
============
*/
void *R_GetCommandBuffer( int bytes ) {
void *R_GetCommandBufferReserved( int bytes, int reservedBytes ) {
renderCommandList_t *cmdList;
cmdList = &backEndData->commands;
bytes = PAD(bytes, sizeof(void *));
// always leave room for the end of list command
if ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) {
if ( cmdList->used + bytes + 4 + reservedBytes > MAX_RENDER_COMMANDS ) {
if ( bytes > MAX_RENDER_COMMANDS - 4 ) {
ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes );
}
@@ -146,6 +146,17 @@ void *R_GetCommandBuffer( int bytes ) {
return cmdList->cmds + cmdList->used - bytes;
}
/*
=============
R_GetCommandBuffer
returns NULL if there is not enough space for important commands
=============
*/
void *R_GetCommandBuffer( int bytes ) {
return R_GetCommandBufferReserved( bytes, sizeof ( swapBuffersCommand_t ) );
}
/*
=============
@@ -525,7 +536,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) {
if ( !tr.registered ) {
return;
}
cmd = R_GetCommandBuffer( sizeof( *cmd ) );
cmd = R_GetCommandBufferReserved( sizeof( *cmd ), 0 );
if ( !cmd ) {
return;
}