diff options
Diffstat (limited to 'src/rend2/tr_cmds.c')
-rw-r--r-- | src/rend2/tr_cmds.c | 96 |
1 files changed, 12 insertions, 84 deletions
diff --git a/src/rend2/tr_cmds.c b/src/rend2/tr_cmds.c index fe4d33d8..622b401a 100644 --- a/src/rend2/tr_cmds.c +++ b/src/rend2/tr_cmds.c @@ -23,9 +23,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA volatile renderCommandList_t *renderCommandList; -volatile qboolean renderThreadActive; - - /* ===================== R_PerformanceCounters @@ -84,47 +81,13 @@ void R_PerformanceCounters( void ) { /* ==================== -R_InitCommandBuffers -==================== -*/ -void R_InitCommandBuffers( void ) { - glConfig.smpActive = qfalse; - if ( r_smp->integer ) { - ri.Printf( PRINT_ALL, "Trying SMP acceleration...\n" ); - if ( GLimp_SpawnRenderThread( RB_RenderThread ) ) { - ri.Printf( PRINT_ALL, "...succeeded.\n" ); - glConfig.smpActive = qtrue; - } else { - ri.Printf( PRINT_ALL, "...failed.\n" ); - } - } -} - -/* -==================== -R_ShutdownCommandBuffers -==================== -*/ -void R_ShutdownCommandBuffers( void ) { - // kill the rendering thread - if ( glConfig.smpActive ) { - GLimp_WakeRenderer( NULL ); - glConfig.smpActive = qfalse; - } -} - -/* -==================== R_IssueRenderCommands ==================== */ -int c_blockedOnRender; -int c_blockedOnMain; - void R_IssueRenderCommands( qboolean runPerformanceCounters ) { renderCommandList_t *cmdList; - cmdList = &backEndData[tr.smpFrame]->commands; + cmdList = &backEndData->commands; assert(cmdList); // add an end-of-list command *(int *)(cmdList->cmds + cmdList->used) = RC_END_OF_LIST; @@ -132,26 +95,6 @@ void R_IssueRenderCommands( qboolean runPerformanceCounters ) { // clear it out, in case this is a sync and not a buffer flip cmdList->used = 0; - if ( glConfig.smpActive ) { - // if the render thread is not idle, wait for it - if ( renderThreadActive ) { - c_blockedOnRender++; - if ( r_showSmp->integer ) { - ri.Printf( PRINT_ALL, "R" ); - } - } else { - c_blockedOnMain++; - if ( r_showSmp->integer ) { - ri.Printf( PRINT_ALL, "." ); - } - } - - // sleep until the renderer has completed - GLimp_FrontEndSleep(); - } - - // at this point, the back end thread is idle, so it is ok - // to look at its performance counters if ( runPerformanceCounters ) { R_PerformanceCounters(); } @@ -159,49 +102,36 @@ void R_IssueRenderCommands( qboolean runPerformanceCounters ) { // actually start the commands going if ( !r_skipBackEnd->integer ) { // let it start on the new batch - if ( !glConfig.smpActive ) { - RB_ExecuteRenderCommands( cmdList->cmds ); - } else { - GLimp_WakeRenderer( cmdList ); - } + RB_ExecuteRenderCommands( cmdList->cmds ); } } /* ==================== -R_SyncRenderThread +R_IssuePendingRenderCommands Issue any pending commands and wait for them to complete. -After exiting, the render thread will have completed its work -and will remain idle and the main thread is free to issue -OpenGL calls until R_IssueRenderCommands is called. ==================== */ -void R_SyncRenderThread( void ) { +void R_IssuePendingRenderCommands( void ) { if ( !tr.registered ) { return; } R_IssueRenderCommands( qfalse ); - - if ( !glConfig.smpActive ) { - return; - } - GLimp_FrontEndSleep(); } /* ============ R_GetCommandBuffer -make sure there is enough command space, waiting on the -render thread if needed. +make sure there is enough command space ============ */ void *R_GetCommandBuffer( int bytes ) { renderCommandList_t *cmdList; - cmdList = &backEndData[tr.smpFrame]->commands; + cmdList = &backEndData->commands; bytes = PAD(bytes, sizeof(void *)); // always leave room for the end of list command @@ -508,7 +438,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { } else { - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); qglEnable( GL_STENCIL_TEST ); qglStencilMask( ~0U ); qglClearStencil( 0U ); @@ -521,7 +451,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { { // this is only reached if it was on and is now off if ( r_measureOverdraw->modified ) { - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); qglDisable( GL_STENCIL_TEST ); } r_measureOverdraw->modified = qfalse; @@ -531,7 +461,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { // texturemode stuff // if ( r_textureMode->modified ) { - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); GL_TextureMode( r_textureMode->string ); r_textureMode->modified = qfalse; } @@ -542,7 +472,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if ( r_gamma->modified ) { r_gamma->modified = qfalse; - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); R_SetColorMappings(); } @@ -551,7 +481,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { { int err; - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); if ((err = qglGetError()) != GL_NO_ERROR) ri.Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err); } @@ -697,9 +627,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { R_IssueRenderCommands( qtrue ); - // use the other buffers next frame, because another CPU - // may still be rendering into the current ones - R_ToggleSmpFrame(); + R_InitNextFrame(); if ( frontEndMsec ) { *frontEndMsec = tr.frontEndMsec; |