diff options
author | Tim Angus <tim@ngus.net> | 2013-01-24 22:53:08 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-02-16 21:53:37 +0000 |
commit | 980a331cec780fe0b2a860517d02a2566eb7451c (patch) | |
tree | a57f0d76da9177fdfbf4af1ffde730084507c682 | |
parent | b236ff1748a52589237e3ae7506ef9969cf6ad44 (diff) |
Remove the SMP renderer feature
35 files changed, 159 insertions, 832 deletions
@@ -29,9 +29,6 @@ endif ifndef BUILD_CLIENT BUILD_CLIENT = endif -ifndef BUILD_CLIENT_SMP - BUILD_CLIENT_SMP = -endif ifndef BUILD_SERVER BUILD_SERVER = endif @@ -45,10 +42,6 @@ ifndef BUILD_RENDERER_REND2 BUILD_RENDERER_REND2= endif -ifneq ($(PLATFORM),darwin) - BUILD_CLIENT_SMP = 0 -endif - ############################################################################# # # If you require a different configuration from the defaults below, create a @@ -571,8 +564,6 @@ ifeq ($(PLATFORM),mingw32) SDLDLL=SDL.dll endif - BUILD_CLIENT_SMP = 0 - else # ifeq mingw32 ############################################################################# @@ -843,26 +834,14 @@ endif ifneq ($(BUILD_CLIENT),0) ifneq ($(USE_RENDERER_DLOPEN),0) TARGETS += $(B)/$(CLIENTBIN)$(FULLBINEXT) $(B)/renderer_opengl1_$(SHLIBNAME) - ifneq ($(BUILD_CLIENT_SMP),0) - TARGETS += $(B)/renderer_opengl1_smp_$(SHLIBNAME) - endif ifneq ($(BUILD_RENDERER_REND2), 0) TARGETS += $(B)/renderer_rend2_$(SHLIBNAME) - ifneq ($(BUILD_CLIENT_SMP),0) - TARGETS += $(B)/renderer_rend2_smp_$(SHLIBNAME) - endif endif else TARGETS += $(B)/$(CLIENTBIN)$(FULLBINEXT) ifneq ($(BUILD_RENDERER_REND2), 0) TARGETS += $(B)/$(CLIENTBIN)_rend2$(FULLBINEXT) endif - ifneq ($(BUILD_CLIENT_SMP),0) - TARGETS += $(B)/$(CLIENTBIN)-smp$(FULLBINEXT) - ifneq ($(BUILD_RENDERER_REND2), 0) - TARGETS += $(B)/$(CLIENTBIN)_rend2-smp$(FULLBINEXT) - endif - endif endif endif @@ -996,11 +975,6 @@ $(Q)cat $< | sed 's/^/\"/;s/$$/\\n\"/' >> $@ $(Q)echo ";" >> $@ endef -define DO_SMP_CC -$(echo_cmd) "SMP_CC $<" -$(Q)$(CC) $(SHLIBCFLAGS) $(CFLAGS) $(CLIENT_CFLAGS) $(OPTIMIZE) -DSMP -o $@ -c $< -endef - ifeq ($(GENERATE_DEPENDENCIES),1) DO_QVM_DEP=cat $(@:%.o=%.d) | sed -e 's/\.o/\.asm/g' >> $(@:%.o=%.d) endif @@ -1137,7 +1111,6 @@ makedirs: @if [ ! -d $(B)/renderer ];then $(MKDIR) $(B)/renderer;fi @if [ ! -d $(B)/rend2 ];then $(MKDIR) $(B)/rend2;fi @if [ ! -d $(B)/rend2/glsl ];then $(MKDIR) $(B)/rend2/glsl;fi - @if [ ! -d $(B)/renderersmp ];then $(MKDIR) $(B)/renderersmp;fi @if [ ! -d $(B)/ded ];then $(MKDIR) $(B)/ded;fi @if [ ! -d $(B)/$(BASEGAME) ];then $(MKDIR) $(B)/$(BASEGAME);fi @if [ ! -d $(B)/$(BASEGAME)/cgame ];then $(MKDIR) $(B)/$(BASEGAME)/cgame;fi @@ -1488,14 +1461,9 @@ Q3ROBJ = \ $(B)/renderer/tr_surface.o \ $(B)/renderer/tr_world.o \ \ - $(B)/renderer/sdl_gamma.o - -Q3RPOBJ_UP = \ + $(B)/renderer/sdl_gamma.o \ $(B)/renderer/sdl_glimp.o -Q3RPOBJ_SMP = \ - $(B)/renderersmp/sdl_glimp.o - ifneq ($(USE_RENDERER_DLOPEN), 0) Q3ROBJ += \ $(B)/renderer/q_shared.o \ @@ -1711,50 +1679,27 @@ $(B)/$(CLIENTBIN)$(FULLBINEXT): $(Q3OBJ) $(LIBSDLMAIN) -o $@ $(Q3OBJ) \ $(LIBSDLMAIN) $(CLIENT_LIBS) $(LIBS) -$(B)/renderer_opengl1_$(SHLIBNAME): $(Q3ROBJ) $(Q3RPOBJ_UP) $(JPGOBJ) +$(B)/renderer_opengl1_$(SHLIBNAME): $(Q3ROBJ) $(JPGOBJ) $(echo_cmd) "LD $@" - $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3ROBJ) $(Q3RPOBJ_UP) $(JPGOBJ) \ + $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3ROBJ) $(JPGOBJ) \ $(THREAD_LIBS) $(LIBSDLMAIN) $(RENDERER_LIBS) $(LIBS) -$(B)/renderer_opengl1_smp_$(SHLIBNAME): $(Q3ROBJ) $(Q3RPOBJ_SMP) $(JPGOBJ) +$(B)/renderer_rend2_$(SHLIBNAME): $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ) $(echo_cmd) "LD $@" - $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3ROBJ) $(Q3RPOBJ_SMP) $(JPGOBJ) \ + $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ) \ $(THREAD_LIBS) $(LIBSDLMAIN) $(RENDERER_LIBS) $(LIBS) - -$(B)/renderer_rend2_$(SHLIBNAME): $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(Q3RPOBJ_UP) $(JPGOBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(Q3RPOBJ_UP) $(JPGOBJ) \ - $(THREAD_LIBS) $(LIBSDLMAIN) $(RENDERER_LIBS) $(LIBS) - -$(B)/renderer_rend2_smp_$(SHLIBNAME): $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(Q3RPOBJ_SMP) $(JPGOBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(Q3RPOBJ_SMP) $(JPGOBJ) \ - $(THREAD_LIBS) $(LIBSDLMAIN) $(RENDERER_LIBS) $(LIBS) - else -$(B)/$(CLIENTBIN)$(FULLBINEXT): $(Q3OBJ) $(Q3ROBJ) $(Q3RPOBJ_UP) $(JPGOBJ) $(LIBSDLMAIN) +$(B)/$(CLIENTBIN)$(FULLBINEXT): $(Q3OBJ) $(Q3ROBJ) $(JPGOBJ) $(LIBSDLMAIN) $(echo_cmd) "LD $@" $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) \ - -o $@ $(Q3OBJ) $(Q3ROBJ) $(Q3RPOBJ_UP) $(JPGOBJ) \ + -o $@ $(Q3OBJ) $(Q3ROBJ) $(JPGOBJ) \ $(LIBSDLMAIN) $(CLIENT_LIBS) $(RENDERER_LIBS) $(LIBS) -$(B)/$(CLIENTBIN)-smp$(FULLBINEXT): $(Q3OBJ) $(Q3ROBJ) $(Q3RPOBJ_SMP) $(JPGOBJ) $(LIBSDLMAIN) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) $(THREAD_LDFLAGS) \ - -o $@ $(Q3OBJ) $(Q3ROBJ) $(Q3RPOBJ_SMP) $(JPGOBJ) \ - $(THREAD_LIBS) $(LIBSDLMAIN) $(CLIENT_LIBS) $(RENDERER_LIBS) $(LIBS) - -$(B)/$(CLIENTBIN)_rend2$(FULLBINEXT): $(Q3OBJ) $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(Q3RPOBJ_UP) $(JPGOBJ) $(LIBSDLMAIN) +$(B)/$(CLIENTBIN)_rend2$(FULLBINEXT): $(Q3OBJ) $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ) $(LIBSDLMAIN) $(echo_cmd) "LD $@" $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) \ - -o $@ $(Q3OBJ) $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(Q3RPOBJ_UP) $(JPGOBJ) \ + -o $@ $(Q3OBJ) $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ) \ $(LIBSDLMAIN) $(CLIENT_LIBS) $(RENDERER_LIBS) $(LIBS) - -$(B)/$(CLIENTBIN)_rend2-smp$(FULLBINEXT): $(Q3OBJ) $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(Q3RPOBJ_SMP) $(JPGOBJ) $(LIBSDLMAIN) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) $(THREAD_LDFLAGS) \ - -o $@ $(Q3OBJ) $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(Q3RPOBJ_SMP) $(JPGOBJ) \ - $(THREAD_LIBS) $(LIBSDLMAIN) $(CLIENT_LIBS) $(RENDERER_LIBS) $(LIBS) endif ifneq ($(strip $(LIBSDLMAIN)),) @@ -2069,9 +2014,6 @@ $(B)/client/%.o: $(ZDIR)/%.c $(B)/client/%.o: $(SDLDIR)/%.c $(DO_CC) -$(B)/renderersmp/%.o: $(SDLDIR)/%.c - $(DO_SMP_CC) - $(B)/client/%.o: $(SYSDIR)/%.c $(DO_CC) @@ -2188,7 +2130,7 @@ $(B)/$(BASEGAME)/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) # MISC ############################################################################# -OBJ = $(Q3OBJ) $(Q3ROBJ) $(Q3R2OBJ) $(Q3RPOBJ_UP) $(Q3RPOBJ_SMP) $(Q3DOBJ) $(JPGOBJ) \ +OBJ = $(Q3OBJ) $(Q3ROBJ) $(Q3R2OBJ) $(Q3DOBJ) $(JPGOBJ) \ $(GOBJ) $(CGOBJ) $(UIOBJ) \ $(GVMOBJ) $(CGVMOBJ) $(UIVMOBJ) TOOLSOBJ = $(LBURGOBJ) $(Q3CPPOBJ) $(Q3RCCOBJ) $(Q3LCCOBJ) $(Q3ASMOBJ) diff --git a/src/client/cl_cin.c b/src/client/cl_cin.c index 30633c03..d6bb0b9f 100644 --- a/src/client/cl_cin.c +++ b/src/client/cl_cin.c @@ -1159,7 +1159,6 @@ redump: if (cinTable[currentHandle].numQuads == -1) { readQuadInfo( framedata ); setupQuad( 0, 0 ); - // we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds()*com_timescale->value; } if (cinTable[currentHandle].numQuads != 1) cinTable[currentHandle].numQuads = 0; @@ -1227,7 +1226,6 @@ redump: static void RoQ_init( void ) { - // we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds()*com_timescale->value; cinTable[currentHandle].RoQPlayed = 24; @@ -1359,12 +1357,10 @@ e_status CIN_RunCinematic (int handle) return cinTable[currentHandle].status; } - // we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer thisTime = CL_ScaledMilliseconds()*com_timescale->value; if (cinTable[currentHandle].shader && (abs(thisTime - cinTable[currentHandle].lastTime))>100) { cinTable[currentHandle].startTime += thisTime - cinTable[currentHandle].lastTime; } - // we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer cinTable[currentHandle].tfps = ((((CL_ScaledMilliseconds()*com_timescale->value) - cinTable[currentHandle].startTime)*3)/100); start = cinTable[currentHandle].startTime; @@ -1373,7 +1369,6 @@ e_status CIN_RunCinematic (int handle) { RoQInterrupt(); if (start != cinTable[currentHandle].startTime) { - // we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer cinTable[currentHandle].tfps = ((((CL_ScaledMilliseconds()*com_timescale->value) - cinTable[currentHandle].startTime)*3)/100); start = cinTable[currentHandle].startTime; diff --git a/src/rend2/tr_backend.c b/src/rend2/tr_backend.c index c3d39433..4e6ab2dd 100644 --- a/src/rend2/tr_backend.c +++ b/src/rend2/tr_backend.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "tr_local.h" -backEndData_t *backEndData[SMP_FRAMES]; +backEndData_t *backEndData; backEndState_t backEnd; @@ -838,7 +838,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { /* ============================================================================ -RENDER BACK END THREAD FUNCTIONS +RENDER BACK END FUNCTIONS ============================================================================ */ @@ -913,7 +913,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * if ( !tr.registered ) { return; } - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); // we definately want to sync every frame for the cinematics qglFinish(); @@ -1811,9 +1811,6 @@ const void *RB_PostProcess(const void *data) /* ==================== RB_ExecuteRenderCommands - -This function will be called synchronously if running without -smp extensions, or asynchronously by another thread. ==================== */ void RB_ExecuteRenderCommands( const void *data ) { @@ -1821,12 +1818,6 @@ void RB_ExecuteRenderCommands( const void *data ) { t1 = ri.Milliseconds (); - if ( !r_smp->integer || data == backEndData[0]->commands.cmds ) { - backEnd.smpFrame = 0; - } else { - backEnd.smpFrame = 1; - } - while ( 1 ) { data = PADP(data, sizeof(void *)); @@ -1866,7 +1857,7 @@ void RB_ExecuteRenderCommands( const void *data ) { break; case RC_END_OF_LIST: default: - // stop rendering on this thread + // stop rendering t2 = ri.Milliseconds (); backEnd.pc.msec = t2 - t1; return; @@ -1874,31 +1865,3 @@ void RB_ExecuteRenderCommands( const void *data ) { } } - - -/* -================ -RB_RenderThread -================ -*/ -void RB_RenderThread( void ) { - const void *data; - - // wait for either a rendering command or a quit command - while ( 1 ) { - // sleep until we have work to do - data = GLimp_RendererSleep(); - - if ( !data ) { - return; // all done, renderer is shutting down - } - - renderThreadActive = qtrue; - - RB_ExecuteRenderCommands( data ); - - renderThreadActive = qfalse; - } -} - - diff --git a/src/rend2/tr_bsp.c b/src/rend2/tr_bsp.c index 08e66c85..0eb56ce4 100644 --- a/src/rend2/tr_bsp.c +++ b/src/rend2/tr_bsp.c @@ -218,7 +218,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { buf = fileBase + l->fileofs; // we are about to upload textures - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); tr.lightmapSize = DEFAULT_LIGHTMAP_SIZE; numLightmaps = len / (tr.lightmapSize * tr.lightmapSize * 3); @@ -3185,7 +3185,7 @@ void R_MergeLeafSurfaces(void) } // finish up the ibo - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); qglGenBuffersARB(1, &ibo->indexesVBO); 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; diff --git a/src/rend2/tr_fbo.c b/src/rend2/tr_fbo.c index 0e84d944..b498fe70 100644 --- a/src/rend2/tr_fbo.c +++ b/src/rend2/tr_fbo.c @@ -370,8 +370,7 @@ void FBO_Init(void) GL_CheckErrors(); - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); /* if(glRefConfig.textureNonPowerOfTwo) { @@ -862,4 +861,4 @@ void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int bu qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glState.currentFBO = NULL; -}
\ No newline at end of file +} diff --git a/src/rend2/tr_font.c b/src/rend2/tr_font.c index 87465e52..0c3d2236 100644 --- a/src/rend2/tr_font.c +++ b/src/rend2/tr_font.c @@ -356,8 +356,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) { pointSize = 12; } - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); if (registeredFontCount >= MAX_FONTS) { ri.Printf(PRINT_WARNING, "RE_RegisterFont: Too many fonts registered already.\n"); diff --git a/src/rend2/tr_glsl.c b/src/rend2/tr_glsl.c index 941d75a9..6e8d91ac 100644 --- a/src/rend2/tr_glsl.c +++ b/src/rend2/tr_glsl.c @@ -829,8 +829,7 @@ void GLSL_InitGPUShaders(void) ri.Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); startTime = ri.Milliseconds(); diff --git a/src/rend2/tr_image.c b/src/rend2/tr_image.c index 20edb0af..13dda827 100644 --- a/src/rend2/tr_image.c +++ b/src/rend2/tr_image.c @@ -3349,8 +3349,7 @@ qhandle_t RE_RegisterSkin( const char *name ) { Q_strncpyz( skin->name, name, sizeof( skin->name ) ); skin->numSurfaces = 0; - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); // If not a .skin file, load as a single shader if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) { diff --git a/src/rend2/tr_init.c b/src/rend2/tr_init.c index 30062bb9..ce2f6176 100644 --- a/src/rend2/tr_init.c +++ b/src/rend2/tr_init.c @@ -55,8 +55,6 @@ cvar_t *r_znear; cvar_t *r_zproj; cvar_t *r_stereoSeparation; -cvar_t *r_smp; -cvar_t *r_showSmp; cvar_t *r_skipBackEnd; cvar_t *r_stereoEnabled; @@ -268,9 +266,6 @@ static void InitOpenGL( void ) } } - // init command buffers and SMP - R_InitCommandBuffers(); - // set default state GL_SetDefaultState(); } @@ -957,9 +952,6 @@ void GfxInfo_f( void ) { ri.Printf( PRINT_ALL, "HACK: riva128 approximations\n" ); } - if ( glConfig.smpActive ) { - ri.Printf( PRINT_ALL, "Using dual processor acceleration\n" ); - } if ( r_finish->integer ) { ri.Printf( PRINT_ALL, "Forcing glFinish\n" ); } @@ -1071,7 +1063,6 @@ void R_Register( void ) r_vertexLight = ri.Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_uiFullScreen = ri.Cvar_Get( "r_uifullscreen", "0", 0); r_subdivisions = ri.Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH); - r_smp = ri.Cvar_Get( "r_smp", "0", CVAR_ARCHIVE | CVAR_LATCH); r_stereoEnabled = ri.Cvar_Get( "r_stereoEnabled", "0", CVAR_ARCHIVE | CVAR_LATCH); r_greyscale = ri.Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); ri.Cvar_CheckRange(r_greyscale, 0, 1, qfalse); @@ -1185,7 +1176,6 @@ void R_Register( void ) r_flareFade = ri.Cvar_Get ("r_flareFade", "7", CVAR_CHEAT); r_flareCoeff = ri.Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT); - r_showSmp = ri.Cvar_Get ("r_showSmp", "0", CVAR_CHEAT); r_skipBackEnd = ri.Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT); r_measureOverdraw = ri.Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT ); @@ -1318,19 +1308,11 @@ void R_Init( void ) { if (max_polyverts < MAX_POLYVERTS) max_polyverts = MAX_POLYVERTS; - ptr = ri.Hunk_Alloc( sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); - backEndData[0] = (backEndData_t *) ptr; - backEndData[0]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[0] )); - backEndData[0]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys); - if ( r_smp->integer ) { - ptr = ri.Hunk_Alloc( sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); - backEndData[1] = (backEndData_t *) ptr; - backEndData[1]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[1] )); - backEndData[1]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys); - } else { - backEndData[1] = NULL; - } - R_ToggleSmpFrame(); + ptr = ri.Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); + backEndData = (backEndData_t *) ptr; + backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData )); + backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); + R_InitNextFrame(); InitOpenGL(); @@ -1385,8 +1367,7 @@ void RE_Shutdown( qboolean destroyWindow ) { if ( tr.registered ) { - R_SyncRenderThread(); - R_ShutdownCommandBuffers(); + R_IssuePendingRenderCommands(); R_ShutDownQueries(); if (glRefConfig.framebufferObject) FBO_Shutdown(); @@ -1414,7 +1395,7 @@ Touch all images to make sure they are resident ============= */ void RE_EndRegistration( void ) { - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); if (!ri.Sys_LowPhysicalMemory()) { RB_ShowImages(); } diff --git a/src/rend2/tr_light.c b/src/rend2/tr_light.c index 9c15982a..4e90ce20 100644 --- a/src/rend2/tr_light.c +++ b/src/rend2/tr_light.c @@ -95,11 +95,11 @@ void R_DlightBmodel( bmodel_t *bmodel ) { surf = tr.world->surfaces + bmodel->firstSurface + i; if ( *surf->data == SF_FACE ) { - ((srfSurfaceFace_t *)surf->data)->dlightBits[ tr.smpFrame ] = mask; + ((srfSurfaceFace_t *)surf->data)->dlightBits = mask; } else if ( *surf->data == SF_GRID ) { - ((srfGridMesh_t *)surf->data)->dlightBits[ tr.smpFrame ] = mask; + ((srfGridMesh_t *)surf->data)->dlightBits = mask; } else if ( *surf->data == SF_TRIANGLES ) { - ((srfTriangles_t *)surf->data)->dlightBits[ tr.smpFrame ] = mask; + ((srfTriangles_t *)surf->data)->dlightBits = mask; } } } @@ -444,4 +444,4 @@ int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *w VectorCopy(ent.lightDir, lightDir); return qtrue; -}
\ No newline at end of file +} diff --git a/src/rend2/tr_local.h b/src/rend2/tr_local.h index 6730f5c1..4b46f612 100644 --- a/src/rend2/tr_local.h +++ b/src/rend2/tr_local.h @@ -40,11 +40,6 @@ typedef unsigned int glIndex_t; #define BUFFER_OFFSET(i) ((char *)NULL + (i)) -// everything that is needed by the backend needs -// to be double buffered to allow it to run in -// parallel on a dual cpu machine -#define SMP_FRAMES 2 - // 14 bits // can't be increased without changing bit packing for drawsurfs // see QSORT_SHADERNUM_SHIFT @@ -1138,8 +1133,8 @@ typedef struct srfGridMesh_s surfaceType_t surfaceType; // dynamic lighting information - int dlightBits[SMP_FRAMES]; - int pshadowBits[SMP_FRAMES]; + int dlightBits; + int pshadowBits; // culling information vec3_t meshBounds[2]; @@ -1182,8 +1177,8 @@ typedef struct surfaceType_t surfaceType; // dynamic lighting information - int dlightBits[SMP_FRAMES]; - int pshadowBits[SMP_FRAMES]; + int dlightBits; + int pshadowBits; // culling information cplane_t plane; @@ -1214,8 +1209,8 @@ typedef struct surfaceType_t surfaceType; // dynamic lighting information - int dlightBits[SMP_FRAMES]; - int pshadowBits[SMP_FRAMES]; + int dlightBits; + int pshadowBits; // culling information // vec3_t bounds[2]; @@ -1280,8 +1275,8 @@ typedef struct srfVBOMesh_s int fogIndex; // dynamic lighting information - int dlightBits[SMP_FRAMES]; - int pshadowBits[SMP_FRAMES]; + int dlightBits; + int pshadowBits; // culling information vec3_t bounds[2]; @@ -1752,7 +1747,6 @@ typedef struct { // all state modified by the back end is seperated // from the front end state typedef struct { - int smpFrame; trRefdef_t refdef; viewParms_t viewParms; orientationr_t or; @@ -1798,8 +1792,6 @@ typedef struct { int viewCount; // incremented every view (twice a scene if portaled) // and every R_MarkFragments call - int smpFrame; // toggles from 0 to 1 every endFrame - int frameSceneNum; // zeroed at RE_BeginFrame qboolean worldMapLoaded; @@ -2084,8 +2076,6 @@ extern cvar_t *r_portalOnly; extern cvar_t *r_subdivisions; extern cvar_t *r_lodCurveError; -extern cvar_t *r_smp; -extern cvar_t *r_showSmp; extern cvar_t *r_skipBackEnd; extern cvar_t *r_stereoEnabled; @@ -2329,11 +2319,6 @@ void GLimp_Init( void ); void GLimp_Shutdown( void ); void GLimp_EndFrame( void ); -qboolean GLimp_SpawnRenderThread( void (*function)( void ) ); -void *GLimp_RendererSleep( void ); -void GLimp_FrontEndSleep( void ); -void GLimp_WakeRenderer( void *data ); - void GLimp_LogComment( char *comment ); void GLimp_Minimize(void); @@ -2588,7 +2573,7 @@ SCENE GENERATION ============================================================ */ -void R_ToggleSmpFrame( void ); +void R_InitNextFrame( void ); void RE_ClearScene( void ); void RE_AddRefEntityToScene( const refEntity_t *ent ); @@ -2702,7 +2687,6 @@ RENDERER BACK END FUNCTIONS ============================================================= */ -void RB_RenderThread( void ); void RB_ExecuteRenderCommands( const void *data ); /* @@ -2830,9 +2814,7 @@ typedef enum { #define MAX_POLYVERTS 3000 // all of the information needed by the back end must be -// contained in a backEndData_t. This entire structure is -// duplicated so the front and back end can run in parallel -// on an SMP machine +// contained in a backEndData_t typedef struct { drawSurf_t drawSurfs[MAX_DRAWSURFS]; dlight_t dlights[MAX_DLIGHTS]; @@ -2846,20 +2828,15 @@ typedef struct { extern int max_polys; extern int max_polyverts; -extern backEndData_t *backEndData[SMP_FRAMES]; // the second one may not be allocated +extern backEndData_t *backEndData; // the second one may not be allocated extern volatile renderCommandList_t *renderCommandList; -extern volatile qboolean renderThreadActive; - void *R_GetCommandBuffer( int bytes ); void RB_ExecuteRenderCommands( const void *data ); -void R_InitCommandBuffers( void ); -void R_ShutdownCommandBuffers( void ); - -void R_SyncRenderThread( void ); +void R_IssuePendingRenderCommands( void ); void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); void R_AddCapShadowmapCmd( int dlight, int cubeSide ); diff --git a/src/rend2/tr_main.c b/src/rend2/tr_main.c index 5b7ad5f7..0935dce7 100644 --- a/src/rend2/tr_main.c +++ b/src/rend2/tr_main.c @@ -1606,10 +1606,6 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 unsigned int pointOr = 0; unsigned int pointAnd = (unsigned int)~0; - if ( glConfig.smpActive ) { // FIXME! we can't do RB_BeginSurface/RB_EndSurface stuff with smp! - return qfalse; - } - R_RotateForViewer(); R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); @@ -2122,8 +2118,7 @@ void R_DebugGraphics( void ) { return; } - // the render thread can't make callbacks to the main thread - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); GL_Bind( tr.whiteImage); GL_Cull( CT_FRONT_SIDED ); diff --git a/src/rend2/tr_model.c b/src/rend2/tr_model.c index b77e10a1..5aeab8ef 100644 --- a/src/rend2/tr_model.c +++ b/src/rend2/tr_model.c @@ -307,8 +307,7 @@ qhandle_t RE_RegisterModel( const char *name ) { Q_strncpyz( mod->name, name, sizeof( mod->name ) ); - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); mod->type = MOD_BAD; mod->numLods = 0; @@ -1305,7 +1304,7 @@ void RE_BeginRegistration( glconfig_t *glconfigOut ) { *glconfigOut = glConfig; - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); tr.visIndex = 0; memset(tr.visClusters, -2, sizeof(tr.visClusters)); // force markleafs to regenerate diff --git a/src/rend2/tr_scene.c b/src/rend2/tr_scene.c index f134c997..c7a414f2 100644 --- a/src/rend2/tr_scene.c +++ b/src/rend2/tr_scene.c @@ -38,20 +38,12 @@ int r_numpolyverts; /* ==================== -R_ToggleSmpFrame +R_InitNextFrame ==================== */ -void R_ToggleSmpFrame( void ) { - if ( r_smp->integer ) { - // use the other buffers next frame, because another CPU - // may still be rendering into the current ones - tr.smpFrame ^= 1; - } else { - tr.smpFrame = 0; - } - - backEndData[tr.smpFrame]->commands.used = 0; +void R_InitNextFrame( void ) { + backEndData->commands.used = 0; r_firstSceneDrawSurf = 0; @@ -148,11 +140,11 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts return; } - poly = &backEndData[tr.smpFrame]->polys[r_numpolys]; + poly = &backEndData->polys[r_numpolys]; poly->surfaceType = SF_POLY; poly->hShader = hShader; poly->numVerts = numVerts; - poly->verts = &backEndData[tr.smpFrame]->polyVerts[r_numpolyverts]; + poly->verts = &backEndData->polyVerts[r_numpolyverts]; Com_Memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) ); @@ -234,13 +226,13 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { ri.Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); } - backEndData[tr.smpFrame]->entities[r_numentities].e = *ent; - backEndData[tr.smpFrame]->entities[r_numentities].lightingCalculated = qfalse; + backEndData->entities[r_numentities].e = *ent; + backEndData->entities[r_numentities].lightingCalculated = qfalse; #ifdef REACTION // JBravo: Mirrored models CrossProduct(ent->axis[0], ent->axis[1], cross); - backEndData[tr.smpFrame]->entities[r_numentities].mirrored = (DotProduct(ent->axis[2], cross) < 0.f); + backEndData->entities[r_numentities].mirrored = (DotProduct(ent->axis[2], cross) < 0.f); #endif r_numentities++; @@ -269,7 +261,7 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa if ( glConfig.hardwareType == GLHW_RIVA128 || glConfig.hardwareType == GLHW_PERMEDIA2 ) { return; } - dl = &backEndData[tr.smpFrame]->dlights[r_numdlights++]; + dl = &backEndData->dlights[r_numdlights++]; VectorCopy (org, dl->origin); dl->radius = intensity; dl->color[0] = r; @@ -439,19 +431,19 @@ void RE_RenderScene( const refdef_t *fd ) { tr.refdef.floatTime = tr.refdef.time * 0.001f; tr.refdef.numDrawSurfs = r_firstSceneDrawSurf; - tr.refdef.drawSurfs = backEndData[tr.smpFrame]->drawSurfs; + tr.refdef.drawSurfs = backEndData->drawSurfs; tr.refdef.num_entities = r_numentities - r_firstSceneEntity; - tr.refdef.entities = &backEndData[tr.smpFrame]->entities[r_firstSceneEntity]; + tr.refdef.entities = &backEndData->entities[r_firstSceneEntity]; tr.refdef.num_dlights = r_numdlights - r_firstSceneDlight; - tr.refdef.dlights = &backEndData[tr.smpFrame]->dlights[r_firstSceneDlight]; + tr.refdef.dlights = &backEndData->dlights[r_firstSceneDlight]; tr.refdef.numPolys = r_numpolys - r_firstScenePoly; - tr.refdef.polys = &backEndData[tr.smpFrame]->polys[r_firstScenePoly]; + tr.refdef.polys = &backEndData->polys[r_firstScenePoly]; tr.refdef.num_pshadows = 0; - tr.refdef.pshadows = &backEndData[tr.smpFrame]->pshadows[0]; + tr.refdef.pshadows = &backEndData->pshadows[0]; // turn off dynamic lighting globally by clearing all the // dlights if it needs to be disabled or if vertex lighting is enabled diff --git a/src/rend2/tr_shader.c b/src/rend2/tr_shader.c index d66b5408..04aa73ae 100644 --- a/src/rend2/tr_shader.c +++ b/src/rend2/tr_shader.c @@ -2499,7 +2499,7 @@ sortedIndex. ============== */ static void FixRenderCommandList( int newShader ) { - renderCommandList_t *cmdList = &backEndData[tr.smpFrame]->commands; + renderCommandList_t *cmdList = &backEndData->commands; if( cmdList ) { const void *curCmd = cmdList->cmds; @@ -3103,12 +3103,6 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag } } - // make sure the render thread is stopped, because we are probably - // going to have to upload an image - if (r_smp->integer) { - R_SyncRenderThread(); - } - // clear the global shader Com_Memset( &shader, 0, sizeof( shader ) ); Com_Memset( &stages, 0, sizeof( stages ) ); @@ -3254,12 +3248,6 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_ } } - // make sure the render thread is stopped, because we are probably - // going to have to upload an image - if (r_smp->integer) { - R_SyncRenderThread(); - } - // clear the global shader Com_Memset( &shader, 0, sizeof( shader ) ); Com_Memset( &stages, 0, sizeof( stages ) ); diff --git a/src/rend2/tr_surface.c b/src/rend2/tr_surface.c index ace8980e..406c7a26 100644 --- a/src/rend2/tr_surface.c +++ b/src/rend2/tr_surface.c @@ -574,12 +574,14 @@ RB_SurfaceTriangles ============= */ static void RB_SurfaceTriangles( srfTriangles_t *srf ) { - if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qtrue ) ) + if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, + srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } - RB_SurfaceHelper(srf->numVerts, srf->verts, srf->numTriangles, srf->triangles, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame]); + RB_SurfaceHelper(srf->numVerts, srf->verts, srf->numTriangles, + srf->triangles, srf->dlightBits, srf->pshadowBits); } @@ -1305,12 +1307,14 @@ RB_SurfaceFace ============== */ static void RB_SurfaceFace( srfSurfaceFace_t *srf ) { - if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qtrue ) ) + if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, + srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } - RB_SurfaceHelper(srf->numVerts, srf->verts, srf->numTriangles, srf->triangles, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame]); + RB_SurfaceHelper(srf->numVerts, srf->verts, srf->numTriangles, + srf->triangles, srf->dlightBits, srf->pshadowBits); } @@ -1372,15 +1376,16 @@ static void RB_SurfaceGrid( srfGridMesh_t *srf ) { int pshadowBits; //int *vDlightBits; - if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qtrue ) ) + if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, + srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } - dlightBits = srf->dlightBits[backEnd.smpFrame]; + dlightBits = srf->dlightBits; tess.dlightBits |= dlightBits; - pshadowBits = srf->pshadowBits[backEnd.smpFrame]; + pshadowBits = srf->pshadowBits; tess.pshadowBits |= pshadowBits; // determine the allowable discrepance @@ -1630,7 +1635,8 @@ static void RB_SurfaceFlare(srfFlare_t *surf) static void RB_SurfaceVBOMesh(srfVBOMesh_t * srf) { - RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qfalse ); + RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, + srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qfalse ); } void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) diff --git a/src/rend2/tr_vbo.c b/src/rend2/tr_vbo.c index 41af9375..65946f18 100644 --- a/src/rend2/tr_vbo.c +++ b/src/rend2/tr_vbo.c @@ -56,8 +56,7 @@ VBO_t *R_CreateVBO(const char *name, byte * vertexes, int vertexesSize, ri.Error( ERR_DROP, "R_CreateVBO: MAX_VBOS hit\n"); } - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); vbo = tr.vbos[tr.numVBOs] = ri.Hunk_Alloc(sizeof(*vbo), h_low); tr.numVBOs++; @@ -125,8 +124,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert ri.Error( ERR_DROP, "R_CreateVBO2: MAX_VBOS hit\n"); } - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); vbo = tr.vbos[tr.numVBOs] = ri.Hunk_Alloc(sizeof(*vbo), h_low); tr.numVBOs++; @@ -475,8 +473,7 @@ IBO_t *R_CreateIBO(const char *name, byte * indexes, int indexesSize, v ri.Error( ERR_DROP, "R_CreateIBO: MAX_IBOS hit\n"); } - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); ibo = tr.ibos[tr.numIBOs] = ri.Hunk_Alloc(sizeof(*ibo), h_low); tr.numIBOs++; @@ -544,8 +541,7 @@ IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * ri.Error( ERR_DROP, "R_CreateIBO2: MAX_IBOS hit\n"); } - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); ibo = tr.ibos[tr.numIBOs] = ri.Hunk_Alloc(sizeof(*ibo), h_low); tr.numIBOs++; diff --git a/src/rend2/tr_world.c b/src/rend2/tr_world.c index 5e1bcf7b..950ee6a4 100644 --- a/src/rend2/tr_world.c +++ b/src/rend2/tr_world.c @@ -206,13 +206,13 @@ static int R_DlightSurface( msurface_t *surf, int dlightBits ) { } if ( *surf->data == SF_FACE ) { - ((srfSurfaceFace_t *)surf->data)->dlightBits[ tr.smpFrame ] = dlightBits; + ((srfSurfaceFace_t *)surf->data)->dlightBits = dlightBits; } else if ( *surf->data == SF_GRID ) { - ((srfGridMesh_t *)surf->data)->dlightBits[ tr.smpFrame ] = dlightBits; + ((srfGridMesh_t *)surf->data)->dlightBits = dlightBits; } else if ( *surf->data == SF_TRIANGLES ) { - ((srfTriangles_t *)surf->data)->dlightBits[ tr.smpFrame ] = dlightBits; + ((srfTriangles_t *)surf->data)->dlightBits = dlightBits; } else if ( *surf->data == SF_VBO_MESH ) { - ((srfVBOMesh_t *)surf->data)->dlightBits[ tr.smpFrame ] = dlightBits; + ((srfVBOMesh_t *)surf->data)->dlightBits = dlightBits; } else { dlightBits = 0; } @@ -289,13 +289,13 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { } if ( *surf->data == SF_FACE ) { - ((srfSurfaceFace_t *)surf->data)->pshadowBits[ tr.smpFrame ] = pshadowBits; + ((srfSurfaceFace_t *)surf->data)->pshadowBits = pshadowBits; } else if ( *surf->data == SF_GRID ) { - ((srfGridMesh_t *)surf->data)->pshadowBits[ tr.smpFrame ] = pshadowBits; + ((srfGridMesh_t *)surf->data)->pshadowBits = pshadowBits; } else if ( *surf->data == SF_TRIANGLES ) { - ((srfTriangles_t *)surf->data)->pshadowBits[ tr.smpFrame ] = pshadowBits; + ((srfTriangles_t *)surf->data)->pshadowBits = pshadowBits; } else if ( *surf->data == SF_VBO_MESH ) { - ((srfVBOMesh_t *)surf->data)->pshadowBits[ tr.smpFrame ] = pshadowBits; + ((srfVBOMesh_t *)surf->data)->pshadowBits = pshadowBits; } else { pshadowBits = 0; } diff --git a/src/renderer/tr_backend.c b/src/renderer/tr_backend.c index 6b34a813..61495083 100644 --- a/src/renderer/tr_backend.c +++ b/src/renderer/tr_backend.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "tr_local.h" -backEndData_t *backEndData[SMP_FRAMES]; +backEndData_t *backEndData; backEndState_t backEnd; @@ -683,7 +683,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { /* ============================================================================ -RENDER BACK END THREAD FUNCTIONS +RENDER BACK END FUNCTIONS ============================================================================ */ @@ -735,7 +735,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * if ( !tr.registered ) { return; } - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); // we definately want to sync every frame for the cinematics qglFinish(); @@ -1112,9 +1112,6 @@ const void *RB_SwapBuffers( const void *data ) { /* ==================== RB_ExecuteRenderCommands - -This function will be called synchronously if running without -smp extensions, or asynchronously by another thread. ==================== */ void RB_ExecuteRenderCommands( const void *data ) { @@ -1122,12 +1119,6 @@ void RB_ExecuteRenderCommands( const void *data ) { t1 = ri.Milliseconds (); - if ( !r_smp->integer || data == backEndData[0]->commands.cmds ) { - backEnd.smpFrame = 0; - } else { - backEnd.smpFrame = 1; - } - while ( 1 ) { data = PADP(data, sizeof(void *)); @@ -1161,7 +1152,7 @@ void RB_ExecuteRenderCommands( const void *data ) { break; case RC_END_OF_LIST: default: - // stop rendering on this thread + // stop rendering t2 = ri.Milliseconds (); backEnd.pc.msec = t2 - t1; return; @@ -1169,30 +1160,3 @@ void RB_ExecuteRenderCommands( const void *data ) { } } - - -/* -================ -RB_RenderThread -================ -*/ -void RB_RenderThread( void ) { - const void *data; - - // wait for either a rendering command or a quit command - while ( 1 ) { - // sleep until we have work to do - data = GLimp_RendererSleep(); - - if ( !data ) { - return; // all done, renderer is shutting down - } - - renderThreadActive = qtrue; - - RB_ExecuteRenderCommands( data ); - - renderThreadActive = qfalse; - } -} - diff --git a/src/renderer/tr_bsp.c b/src/renderer/tr_bsp.c index 3ca40f08..74596a53 100644 --- a/src/renderer/tr_bsp.c +++ b/src/renderer/tr_bsp.c @@ -148,7 +148,7 @@ static void R_LoadLightmaps( lump_t *l ) { buf = fileBase + l->fileofs; // we are about to upload textures - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); // create all the lightmaps tr.numLightmaps = len / (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3); diff --git a/src/renderer/tr_cmds.c b/src/renderer/tr_cmds.c index 30088429..e4a2dcfe 100644 --- a/src/renderer/tr_cmds.c +++ b/src/renderer/tr_cmds.c @@ -24,9 +24,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA volatile renderCommandList_t *renderCommandList; -volatile qboolean renderThreadActive; - - /* ===================== R_PerformanceCounters @@ -78,47 +75,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; @@ -126,26 +89,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(); } @@ -153,49 +96,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 @@ -463,7 +393,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { } else { - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); qglEnable( GL_STENCIL_TEST ); qglStencilMask( ~0U ); qglClearStencil( 0U ); @@ -476,7 +406,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; @@ -486,7 +416,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; } @@ -497,7 +427,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if ( r_gamma->modified ) { r_gamma->modified = qfalse; - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); R_SetColorMappings(); } @@ -506,7 +436,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); } @@ -620,9 +550,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; diff --git a/src/renderer/tr_font.c b/src/renderer/tr_font.c index 59ce62f7..432d1215 100644 --- a/src/renderer/tr_font.c +++ b/src/renderer/tr_font.c @@ -357,8 +357,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) { pointSize = 12; } - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); if (registeredFontCount >= MAX_FONTS) { ri.Printf(PRINT_WARNING, "RE_RegisterFont: Too many fonts registered already.\n"); diff --git a/src/renderer/tr_image.c b/src/renderer/tr_image.c index a8b1a3be..3338a25b 100644 --- a/src/renderer/tr_image.c +++ b/src/renderer/tr_image.c @@ -1496,8 +1496,7 @@ qhandle_t RE_RegisterSkin( const char *name ) { Q_strncpyz( skin->name, name, sizeof( skin->name ) ); skin->numSurfaces = 0; - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); // If not a .skin file, load as a single shader if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) { diff --git a/src/renderer/tr_init.c b/src/renderer/tr_init.c index 3795d97d..14b91927 100644 --- a/src/renderer/tr_init.c +++ b/src/renderer/tr_init.c @@ -52,8 +52,6 @@ cvar_t *r_znear; cvar_t *r_zproj; cvar_t *r_stereoSeparation; -cvar_t *r_smp; -cvar_t *r_showSmp; cvar_t *r_skipBackEnd; cvar_t *r_stereoEnabled; @@ -294,9 +292,6 @@ static void InitOpenGL( void ) } } - // init command buffers and SMP - R_InitCommandBuffers(); - // set default state GL_SetDefaultState(); } @@ -1002,9 +997,6 @@ void GfxInfo_f( void ) { ri.Printf( PRINT_ALL, "HACK: riva128 approximations\n" ); } - if ( glConfig.smpActive ) { - ri.Printf( PRINT_ALL, "Using dual processor acceleration\n" ); - } if ( r_finish->integer ) { ri.Printf( PRINT_ALL, "Forcing glFinish\n" ); } @@ -1057,7 +1049,6 @@ void R_Register( void ) r_vertexLight = ri.Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_uiFullScreen = ri.Cvar_Get( "r_uifullscreen", "0", 0); r_subdivisions = ri.Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH); - r_smp = ri.Cvar_Get( "r_smp", "0", CVAR_ARCHIVE | CVAR_LATCH); r_stereoEnabled = ri.Cvar_Get( "r_stereoEnabled", "0", CVAR_ARCHIVE | CVAR_LATCH); r_ignoreFastPath = ri.Cvar_Get( "r_ignoreFastPath", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_greyscale = ri.Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); @@ -1125,7 +1116,6 @@ void R_Register( void ) r_flareFade = ri.Cvar_Get ("r_flareFade", "7", CVAR_CHEAT); r_flareCoeff = ri.Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT); - r_showSmp = ri.Cvar_Get ("r_showSmp", "0", CVAR_CHEAT); r_skipBackEnd = ri.Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT); r_measureOverdraw = ri.Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT ); @@ -1237,19 +1227,11 @@ void R_Init( void ) { if (max_polyverts < MAX_POLYVERTS) max_polyverts = MAX_POLYVERTS; - ptr = ri.Hunk_Alloc( sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); - backEndData[0] = (backEndData_t *) ptr; - backEndData[0]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[0] )); - backEndData[0]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys); - if ( r_smp->integer ) { - ptr = ri.Hunk_Alloc( sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); - backEndData[1] = (backEndData_t *) ptr; - backEndData[1]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[1] )); - backEndData[1]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys); - } else { - backEndData[1] = NULL; - } - R_ToggleSmpFrame(); + ptr = ri.Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); + backEndData = (backEndData_t *) ptr; + backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData )); + backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); + R_InitNextFrame(); InitOpenGL(); @@ -1294,8 +1276,7 @@ void RE_Shutdown( qboolean destroyWindow ) { if ( tr.registered ) { - R_SyncRenderThread(); - R_ShutdownCommandBuffers(); + R_IssuePendingRenderCommands(); R_DeleteTextures(); } @@ -1318,7 +1299,7 @@ Touch all images to make sure they are resident ============= */ void RE_EndRegistration( void ) { - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); if (!ri.Sys_LowPhysicalMemory()) { RB_ShowImages(); } diff --git a/src/renderer/tr_light.c b/src/renderer/tr_light.c index 78441bb7..36c1c480 100644 --- a/src/renderer/tr_light.c +++ b/src/renderer/tr_light.c @@ -96,11 +96,11 @@ void R_DlightBmodel( bmodel_t *bmodel ) { surf = bmodel->firstSurface + i; if ( *surf->data == SF_FACE ) { - ((srfSurfaceFace_t *)surf->data)->dlightBits[ tr.smpFrame ] = mask; + ((srfSurfaceFace_t *)surf->data)->dlightBits = mask; } else if ( *surf->data == SF_GRID ) { - ((srfGridMesh_t *)surf->data)->dlightBits[ tr.smpFrame ] = mask; + ((srfGridMesh_t *)surf->data)->dlightBits = mask; } else if ( *surf->data == SF_TRIANGLES ) { - ((srfTriangles_t *)surf->data)->dlightBits[ tr.smpFrame ] = mask; + ((srfTriangles_t *)surf->data)->dlightBits = mask; } } } diff --git a/src/renderer/tr_local.h b/src/renderer/tr_local.h index c7b584da..fc80645b 100644 --- a/src/renderer/tr_local.h +++ b/src/renderer/tr_local.h @@ -35,11 +35,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define GL_INDEX_TYPE GL_UNSIGNED_INT typedef unsigned int glIndex_t; -// everything that is needed by the backend needs -// to be double buffered to allow it to run in -// parallel on a dual cpu machine -#define SMP_FRAMES 2 - // 14 bits // can't be increased without changing bit packing for drawsurfs // see QSORT_SHADERNUM_SHIFT @@ -574,7 +569,7 @@ typedef struct srfGridMesh_s { surfaceType_t surfaceType; // dynamic lighting information - int dlightBits[SMP_FRAMES]; + int dlightBits; // culling information vec3_t meshBounds[2]; @@ -604,7 +599,7 @@ typedef struct { cplane_t plane; // dynamic lighting information - int dlightBits[SMP_FRAMES]; + int dlightBits; // triangle definitions (no normals at points) int numPoints; @@ -620,7 +615,7 @@ typedef struct { surfaceType_t surfaceType; // dynamic lighting information - int dlightBits[SMP_FRAMES]; + int dlightBits; // culling information (FIXME: use this!) vec3_t bounds[2]; @@ -892,7 +887,6 @@ typedef struct { // all state modified by the back end is seperated // from the front end state typedef struct { - int smpFrame; trRefdef_t refdef; viewParms_t viewParms; orientationr_t or; @@ -924,8 +918,6 @@ typedef struct { int viewCount; // incremented every view (twice a scene if portaled) // and every R_MarkFragments call - int smpFrame; // toggles from 0 to 1 every endFrame - int frameSceneNum; // zeroed at RE_BeginFrame qboolean worldMapLoaded; @@ -1121,8 +1113,6 @@ extern cvar_t *r_portalOnly; extern cvar_t *r_subdivisions; extern cvar_t *r_lodCurveError; -extern cvar_t *r_smp; -extern cvar_t *r_showSmp; extern cvar_t *r_skipBackEnd; extern cvar_t *r_stereoEnabled; @@ -1298,11 +1288,6 @@ void GLimp_Init( void ); void GLimp_Shutdown( void ); void GLimp_EndFrame( void ); -qboolean GLimp_SpawnRenderThread( void (*function)( void ) ); -void *GLimp_RendererSleep( void ); -void GLimp_FrontEndSleep( void ); -void GLimp_WakeRenderer( void *data ); - void GLimp_LogComment( char *comment ); void GLimp_Minimize(void); @@ -1479,7 +1464,7 @@ SCENE GENERATION ============================================================ */ -void R_ToggleSmpFrame( void ); +void R_InitNextFrame( void ); void RE_ClearScene( void ); void RE_AddRefEntityToScene( const refEntity_t *ent ); @@ -1583,7 +1568,6 @@ RENDERER BACK END FUNCTIONS ============================================================= */ -void RB_RenderThread( void ); void RB_ExecuteRenderCommands( const void *data ); /* @@ -1697,9 +1681,7 @@ typedef enum { #define MAX_POLYVERTS 3000 // all of the information needed by the back end must be -// contained in a backEndData_t. This entire structure is -// duplicated so the front and back end can run in parallel -// on an SMP machine +// contained in a backEndData_t typedef struct { drawSurf_t drawSurfs[MAX_DRAWSURFS]; dlight_t dlights[MAX_DLIGHTS]; @@ -1712,20 +1694,15 @@ typedef struct { extern int max_polys; extern int max_polyverts; -extern backEndData_t *backEndData[SMP_FRAMES]; // the second one may not be allocated +extern backEndData_t *backEndData; // the second one may not be allocated extern volatile renderCommandList_t *renderCommandList; -extern volatile qboolean renderThreadActive; - void *R_GetCommandBuffer( int bytes ); void RB_ExecuteRenderCommands( const void *data ); -void R_InitCommandBuffers( void ); -void R_ShutdownCommandBuffers( void ); - -void R_SyncRenderThread( void ); +void R_IssuePendingRenderCommands( void ); void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); diff --git a/src/renderer/tr_main.c b/src/renderer/tr_main.c index 8d5c444f..3b82a777 100644 --- a/src/renderer/tr_main.c +++ b/src/renderer/tr_main.c @@ -863,10 +863,6 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 unsigned int pointOr = 0; unsigned int pointAnd = (unsigned int)~0; - if ( glConfig.smpActive ) { // FIXME! we can't do RB_BeginSurface/RB_EndSurface stuff with smp! - return qfalse; - } - R_RotateForViewer(); R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted ); @@ -1353,8 +1349,7 @@ void R_DebugGraphics( void ) { return; } - // the render thread can't make callbacks to the main thread - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); GL_Bind( tr.whiteImage); GL_Cull( CT_FRONT_SIDED ); diff --git a/src/renderer/tr_model.c b/src/renderer/tr_model.c index b79fd458..b51c3ce1 100644 --- a/src/renderer/tr_model.c +++ b/src/renderer/tr_model.c @@ -307,8 +307,7 @@ qhandle_t RE_RegisterModel( const char *name ) { Q_strncpyz( mod->name, name, sizeof( mod->name ) ); - // make sure the render thread is stopped - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); mod->type = MOD_BAD; mod->numLods = 0; @@ -1046,7 +1045,7 @@ void RE_BeginRegistration( glconfig_t *glconfigOut ) { *glconfigOut = glConfig; - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); tr.viewCluster = -1; // force markleafs to regenerate R_ClearFlares(); diff --git a/src/renderer/tr_scene.c b/src/renderer/tr_scene.c index 49c0e593..6ee77dc6 100644 --- a/src/renderer/tr_scene.c +++ b/src/renderer/tr_scene.c @@ -39,20 +39,12 @@ int r_numpolyverts; /* ==================== -R_ToggleSmpFrame +R_InitNextFrame ==================== */ -void R_ToggleSmpFrame( void ) { - if ( r_smp->integer ) { - // use the other buffers next frame, because another CPU - // may still be rendering into the current ones - tr.smpFrame ^= 1; - } else { - tr.smpFrame = 0; - } - - backEndData[tr.smpFrame]->commands.used = 0; +void R_InitNextFrame( void ) { + backEndData->commands.used = 0; r_firstSceneDrawSurf = 0; @@ -144,11 +136,11 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts return; } - poly = &backEndData[tr.smpFrame]->polys[r_numpolys]; + poly = &backEndData->polys[r_numpolys]; poly->surfaceType = SF_POLY; poly->hShader = hShader; poly->numVerts = numVerts; - poly->verts = &backEndData[tr.smpFrame]->polyVerts[r_numpolyverts]; + poly->verts = &backEndData->polyVerts[r_numpolyverts]; Com_Memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) ); @@ -225,8 +217,8 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { ri.Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); } - backEndData[tr.smpFrame]->entities[r_numentities].e = *ent; - backEndData[tr.smpFrame]->entities[r_numentities].lightingCalculated = qfalse; + backEndData->entities[r_numentities].e = *ent; + backEndData->entities[r_numentities].lightingCalculated = qfalse; r_numentities++; } @@ -254,7 +246,7 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa if ( glConfig.hardwareType == GLHW_RIVA128 || glConfig.hardwareType == GLHW_PERMEDIA2 ) { return; } - dl = &backEndData[tr.smpFrame]->dlights[r_numdlights++]; + dl = &backEndData->dlights[r_numdlights++]; VectorCopy (org, dl->origin); dl->radius = intensity; dl->color[0] = r; @@ -356,16 +348,16 @@ void RE_RenderScene( const refdef_t *fd ) { tr.refdef.floatTime = tr.refdef.time * 0.001f; tr.refdef.numDrawSurfs = r_firstSceneDrawSurf; - tr.refdef.drawSurfs = backEndData[tr.smpFrame]->drawSurfs; + tr.refdef.drawSurfs = backEndData->drawSurfs; tr.refdef.num_entities = r_numentities - r_firstSceneEntity; - tr.refdef.entities = &backEndData[tr.smpFrame]->entities[r_firstSceneEntity]; + tr.refdef.entities = &backEndData->entities[r_firstSceneEntity]; tr.refdef.num_dlights = r_numdlights - r_firstSceneDlight; - tr.refdef.dlights = &backEndData[tr.smpFrame]->dlights[r_firstSceneDlight]; + tr.refdef.dlights = &backEndData->dlights[r_firstSceneDlight]; tr.refdef.numPolys = r_numpolys - r_firstScenePoly; - tr.refdef.polys = &backEndData[tr.smpFrame]->polys[r_firstScenePoly]; + tr.refdef.polys = &backEndData->polys[r_firstScenePoly]; // turn off dynamic lighting globally by clearing all the // dlights if it needs to be disabled or if vertex lighting is enabled diff --git a/src/renderer/tr_shader.c b/src/renderer/tr_shader.c index 6226d020..8440dd63 100644 --- a/src/renderer/tr_shader.c +++ b/src/renderer/tr_shader.c @@ -1873,7 +1873,7 @@ sortedIndex. ============== */ static void FixRenderCommandList( int newShader ) { - renderCommandList_t *cmdList = &backEndData[tr.smpFrame]->commands; + renderCommandList_t *cmdList = &backEndData->commands; if( cmdList ) { const void *curCmd = cmdList->cmds; @@ -2474,12 +2474,6 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag } } - // make sure the render thread is stopped, because we are probably - // going to have to upload an image - if (r_smp->integer) { - R_SyncRenderThread(); - } - // clear the global shader Com_Memset( &shader, 0, sizeof( shader ) ); Com_Memset( &stages, 0, sizeof( stages ) ); @@ -2610,12 +2604,6 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_ } } - // make sure the render thread is stopped, because we are probably - // going to have to upload an image - if (r_smp->integer) { - R_SyncRenderThread(); - } - // clear the global shader Com_Memset( &shader, 0, sizeof( shader ) ); Com_Memset( &stages, 0, sizeof( stages ) ); diff --git a/src/renderer/tr_surface.c b/src/renderer/tr_surface.c index 0fcfc3f0..7a836386 100644 --- a/src/renderer/tr_surface.c +++ b/src/renderer/tr_surface.c @@ -232,7 +232,7 @@ static void RB_SurfaceTriangles( srfTriangles_t *srf ) { int dlightBits; qboolean needsNormal; - dlightBits = srf->dlightBits[backEnd.smpFrame]; + dlightBits = srf->dlightBits; tess.dlightBits |= dlightBits; RB_CHECKOVERFLOW( srf->numVerts, srf->numIndexes ); @@ -916,7 +916,7 @@ static void RB_SurfaceFace( srfSurfaceFace_t *surf ) { RB_CHECKOVERFLOW( surf->numPoints, surf->numIndices ); - dlightBits = surf->dlightBits[backEnd.smpFrame]; + dlightBits = surf->dlightBits; tess.dlightBits |= dlightBits; indices = ( unsigned * ) ( ( ( char * ) surf ) + surf->ofsIndices ); @@ -1008,7 +1008,7 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) { int *vDlightBits; qboolean needsNormal; - dlightBits = cv->dlightBits[backEnd.smpFrame]; + dlightBits = cv->dlightBits; tess.dlightBits |= dlightBits; // determine the allowable discrepance diff --git a/src/renderer/tr_types.h b/src/renderer/tr_types.h index 1ddb9a18..0e15c9e8 100644 --- a/src/renderer/tr_types.h +++ b/src/renderer/tr_types.h @@ -214,11 +214,8 @@ typedef struct { // used CDS. qboolean isFullscreen; qboolean stereoEnabled; - qboolean smpActive; // dual processor - qboolean textureFilterAnisotropic; int maxAnisotropy; - } glconfig_t; #endif // __TR_TYPES_H diff --git a/src/renderer/tr_world.c b/src/renderer/tr_world.c index 2bd5f316..de9715a8 100644 --- a/src/renderer/tr_world.c +++ b/src/renderer/tr_world.c @@ -181,7 +181,7 @@ static int R_DlightFace( srfSurfaceFace_t *face, int dlightBits ) { tr.pc.c_dlightSurfacesCulled++; } - face->dlightBits[ tr.smpFrame ] = dlightBits; + face->dlightBits = dlightBits; return dlightBits; } @@ -209,14 +209,14 @@ static int R_DlightGrid( srfGridMesh_t *grid, int dlightBits ) { tr.pc.c_dlightSurfacesCulled++; } - grid->dlightBits[ tr.smpFrame ] = dlightBits; + grid->dlightBits = dlightBits; return dlightBits; } static int R_DlightTrisurf( srfTriangles_t *surf, int dlightBits ) { // FIXME: more dlight culling to trisurfs... - surf->dlightBits[ tr.smpFrame ] = dlightBits; + surf->dlightBits = dlightBits; return dlightBits; #if 0 int i; @@ -242,7 +242,7 @@ static int R_DlightTrisurf( srfTriangles_t *surf, int dlightBits ) { tr.pc.c_dlightSurfacesCulled++; } - grid->dlightBits[ tr.smpFrame ] = dlightBits; + grid->dlightBits = dlightBits; return dlightBits; #endif } diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c index f15816af..f9c2ce87 100644 --- a/src/sdl/sdl_glimp.c +++ b/src/sdl/sdl_glimp.c @@ -27,14 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # include <SDL.h> #endif -#ifdef SMP -# ifdef USE_LOCAL_HEADERS -# include "SDL_thread.h" -# else -# include <SDL_thread.h> -# endif -#endif - #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -822,245 +814,3 @@ void GLimp_EndFrame( void ) r_fullscreen->modified = qfalse; } } - - - -#ifdef SMP -/* -=========================================================== - -SMP acceleration - -=========================================================== -*/ - -/* - * I have no idea if this will even work...most platforms don't offer - * thread-safe OpenGL libraries, and it looks like the original Linux - * code counted on each thread claiming the GL context with glXMakeCurrent(), - * which you can't currently do in SDL. We'll just have to hope for the best. - */ - -static SDL_mutex *smpMutex = NULL; -static SDL_cond *renderCommandsEvent = NULL; -static SDL_cond *renderCompletedEvent = NULL; -static void (*glimpRenderThread)( void ) = NULL; -static SDL_Thread *renderThread = NULL; - -/* -=============== -GLimp_ShutdownRenderThread -=============== -*/ -static void GLimp_ShutdownRenderThread(void) -{ - if (smpMutex != NULL) - { - SDL_DestroyMutex(smpMutex); - smpMutex = NULL; - } - - if (renderCommandsEvent != NULL) - { - SDL_DestroyCond(renderCommandsEvent); - renderCommandsEvent = NULL; - } - - if (renderCompletedEvent != NULL) - { - SDL_DestroyCond(renderCompletedEvent); - renderCompletedEvent = NULL; - } - - glimpRenderThread = NULL; -} - -/* -=============== -GLimp_RenderThreadWrapper -=============== -*/ -static int GLimp_RenderThreadWrapper( void *arg ) -{ - Com_Printf( "Render thread starting\n" ); - - glimpRenderThread(); - - GLimp_SetCurrentContext(NULL); - - Com_Printf( "Render thread terminating\n" ); - - return 0; -} - -/* -=============== -GLimp_SpawnRenderThread -=============== -*/ -qboolean GLimp_SpawnRenderThread( void (*function)( void ) ) -{ - static qboolean warned = qfalse; - if (!warned) - { - Com_Printf("WARNING: You enable r_smp at your own risk!\n"); - warned = qtrue; - } - -#ifndef MACOS_X - return qfalse; /* better safe than sorry for now. */ -#endif - - if (renderThread != NULL) /* hopefully just a zombie at this point... */ - { - Com_Printf("Already a render thread? Trying to clean it up...\n"); - SDL_WaitThread(renderThread, NULL); - renderThread = NULL; - GLimp_ShutdownRenderThread(); - } - - smpMutex = SDL_CreateMutex(); - if (smpMutex == NULL) - { - Com_Printf( "smpMutex creation failed: %s\n", SDL_GetError() ); - GLimp_ShutdownRenderThread(); - return qfalse; - } - - renderCommandsEvent = SDL_CreateCond(); - if (renderCommandsEvent == NULL) - { - Com_Printf( "renderCommandsEvent creation failed: %s\n", SDL_GetError() ); - GLimp_ShutdownRenderThread(); - return qfalse; - } - - renderCompletedEvent = SDL_CreateCond(); - if (renderCompletedEvent == NULL) - { - Com_Printf( "renderCompletedEvent creation failed: %s\n", SDL_GetError() ); - GLimp_ShutdownRenderThread(); - return qfalse; - } - - glimpRenderThread = function; - renderThread = SDL_CreateThread(GLimp_RenderThreadWrapper, NULL); - if ( renderThread == NULL ) - { - ri.Printf( PRINT_ALL, "SDL_CreateThread() returned %s", SDL_GetError() ); - GLimp_ShutdownRenderThread(); - return qfalse; - } - else - { - // tma 01/09/07: don't think this is necessary anyway? - // - // !!! FIXME: No detach API available in SDL! - //ret = pthread_detach( renderThread ); - //if ( ret ) { - //ri.Printf( PRINT_ALL, "pthread_detach returned %d: %s", ret, strerror( ret ) ); - //} - } - - return qtrue; -} - -static volatile void *smpData = NULL; -static volatile qboolean smpDataReady; - -/* -=============== -GLimp_RendererSleep -=============== -*/ -void *GLimp_RendererSleep( void ) -{ - void *data = NULL; - - GLimp_SetCurrentContext(NULL); - - SDL_LockMutex(smpMutex); - { - smpData = NULL; - smpDataReady = qfalse; - - // after this, the front end can exit GLimp_FrontEndSleep - SDL_CondSignal(renderCompletedEvent); - - while ( !smpDataReady ) - SDL_CondWait(renderCommandsEvent, smpMutex); - - data = (void *)smpData; - } - SDL_UnlockMutex(smpMutex); - - GLimp_SetCurrentContext(opengl_context); - - return data; -} - -/* -=============== -GLimp_FrontEndSleep -=============== -*/ -void GLimp_FrontEndSleep( void ) -{ - SDL_LockMutex(smpMutex); - { - while ( smpData ) - SDL_CondWait(renderCompletedEvent, smpMutex); - } - SDL_UnlockMutex(smpMutex); - - GLimp_SetCurrentContext(opengl_context); -} - -/* -=============== -GLimp_WakeRenderer -=============== -*/ -void GLimp_WakeRenderer( void *data ) -{ - GLimp_SetCurrentContext(NULL); - - SDL_LockMutex(smpMutex); - { - assert( smpData == NULL ); - smpData = data; - smpDataReady = qtrue; - - // after this, the renderer can continue through GLimp_RendererSleep - SDL_CondSignal(renderCommandsEvent); - } - SDL_UnlockMutex(smpMutex); -} - -#else - -// No SMP - stubs -void GLimp_RenderThreadWrapper( void *arg ) -{ -} - -qboolean GLimp_SpawnRenderThread( void (*function)( void ) ) -{ - ri.Printf( PRINT_WARNING, "ERROR: SMP support was disabled at compile time\n"); - return qfalse; -} - -void *GLimp_RendererSleep( void ) -{ - return NULL; -} - -void GLimp_FrontEndSleep( void ) -{ -} - -void GLimp_WakeRenderer( void *data ) -{ -} - -#endif |