diff options
author | Zack Middleton <zturtleman@gmail.com> | 2015-10-16 19:18:38 -0500 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2016-04-07 11:12:56 +0100 |
commit | 27b955ed8aae71e0a4a15d75e1c06ffa6516fbe5 (patch) | |
tree | 3d749bd7398f3d36316e4ea05eb514df83d84e5a | |
parent | 2680cae42a9009628ded887d9470ed8abf45fc0f (diff) |
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.
-rw-r--r-- | src/renderergl1/tr_cmds.c | 19 | ||||
-rw-r--r-- | src/renderergl2/tr_cmds.c | 19 |
2 files changed, 30 insertions, 8 deletions
diff --git a/src/renderergl1/tr_cmds.c b/src/renderergl1/tr_cmds.c index 23aa9897..0ff7faee 100644 --- a/src/renderergl1/tr_cmds.c +++ b/src/renderergl1/tr_cmds.c @@ -115,19 +115,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 ); } @@ -140,6 +140,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 ) ); +} + /* ============= @@ -540,7 +551,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; } diff --git a/src/renderergl2/tr_cmds.c b/src/renderergl2/tr_cmds.c index 07fe146f..4599511b 100644 --- a/src/renderergl2/tr_cmds.c +++ b/src/renderergl2/tr_cmds.c @@ -122,19 +122,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 ); } @@ -147,6 +147,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 ) ); +} + /* ============= @@ -611,7 +622,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; } |