From a99a214589128b093af8ee6dca9eea29dccc813b Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 9 Jan 2013 23:15:21 -0600 Subject: [PATCH 01/18] Fix #5849 - broken snapvector inverts player speed Snapvector was converting floats to 16 bit integers instead of 32 bit integers. --- code/asm/snapvector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/asm/snapvector.c b/code/asm/snapvector.c index f0f62466..44e81f58 100644 --- a/code/asm/snapvector.c +++ b/code/asm/snapvector.c @@ -55,8 +55,8 @@ void qsnapvectorsse(vec3_t vec) #define QROUNDX87(src) \ "flds " src "\n" \ - "fistps " src "\n" \ - "filds " src "\n" \ + "fistpl " src "\n" \ + "fildl " src "\n" \ "fstps " src "\n" void qsnapvectorx87(vec3_t vec) From c1ddacf5be364a13b48910a16db6d92de6ca6461 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 10 Jan 2013 15:06:59 -0600 Subject: [PATCH 02/18] Fix win32 input left on buffer and overwritten The input line on the console screen buffer was moved up a line and overwritten by CON_Print. Remove input line when console shutdown as well. --- code/sys/con_win32.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/code/sys/con_win32.c b/code/sys/con_win32.c index 037e9f76..9f2f98aa 100644 --- a/code/sys/con_win32.c +++ b/code/sys/con_win32.c @@ -221,6 +221,25 @@ static void CON_Show( void ) } } +/* +================== +CON_Hide +================== +*/ +static void CON_Hide( void ) +{ + int realLen; + + realLen = qconsole_linelen; + + // remove input line from console output buffer + qconsole_linelen = 0; + CON_Show( ); + + qconsole_linelen = realLen; +} + + /* ================== CON_Shutdown @@ -228,6 +247,7 @@ CON_Shutdown */ void CON_Shutdown( void ) { + CON_Hide( ); SetConsoleMode( qconsole_hin, qconsole_orig_mode ); SetConsoleCursorInfo( qconsole_hout, &qconsole_orig_cursorinfo ); SetConsoleTextAttribute( qconsole_hout, qconsole_attrib ); @@ -458,6 +478,8 @@ CON_Print */ void CON_Print( const char *msg ) { + CON_Hide( ); + CON_WindowsColorPrint( msg ); CON_Show( ); From 20cd170993f8f4808ee99b7482cb990ec880eaca Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 10 Jan 2013 15:34:54 -0600 Subject: [PATCH 03/18] Make win32 console cursor visible --- code/sys/con_win32.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/code/sys/con_win32.c b/code/sys/con_win32.c index 9f2f98aa..990d55da 100644 --- a/code/sys/con_win32.c +++ b/code/sys/con_win32.c @@ -174,16 +174,13 @@ static void CON_Show( void ) COORD writeSize = { MAX_EDIT_LINE, 1 }; COORD writePos = { 0, 0 }; SMALL_RECT writeArea = { 0, 0, 0, 0 }; + COORD cursorPos; int i; CHAR_INFO line[ MAX_EDIT_LINE ]; WORD attrib; GetConsoleScreenBufferInfo( qconsole_hout, &binfo ); - // if we're in the middle of printf, don't bother writing the buffer - if( binfo.dwCursorPosition.X != 0 ) - return; - writeArea.Left = 0; writeArea.Top = binfo.dwCursorPosition.Y; writeArea.Bottom = binfo.dwCursorPosition.Y; @@ -219,6 +216,12 @@ static void CON_Show( void ) WriteConsoleOutput( qconsole_hout, line, writeSize, writePos, &writeArea ); } + + // set curor position + cursorPos.Y = binfo.dwCursorPosition.Y; + cursorPos.X = qconsole_linelen > binfo.srWindow.Right ? binfo.srWindow.Right : qconsole_linelen; + + SetConsoleCursorPosition( qconsole_hout, cursorPos ); } /* @@ -262,7 +265,6 @@ CON_Init */ void CON_Init( void ) { - CONSOLE_CURSOR_INFO curs; CONSOLE_SCREEN_BUFFER_INFO info; int i; @@ -291,12 +293,6 @@ void CON_Init( void ) SetConsoleTitle(CLIENT_WINDOW_TITLE " Dedicated Server Console"); - // make cursor invisible - GetConsoleCursorInfo( qconsole_hout, &qconsole_orig_cursorinfo ); - curs.dwSize = 1; - curs.bVisible = FALSE; - SetConsoleCursorInfo( qconsole_hout, &curs ); - // initialize history for( i = 0; i < QCONSOLE_HISTORY; i++ ) qconsole_history[ i ][ 0 ] = '\0'; From 2d6b68edd8f5fde93e997062a8672c53c99277a5 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 10 Jan 2013 16:29:54 -0600 Subject: [PATCH 04/18] Fix win32 console partial print being overwritten --- code/sys/con_win32.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/sys/con_win32.c b/code/sys/con_win32.c index 990d55da..edfa4e6a 100644 --- a/code/sys/con_win32.c +++ b/code/sys/con_win32.c @@ -42,6 +42,7 @@ static int qconsole_history_oldest = 0; // current edit buffer static char qconsole_line[ MAX_EDIT_LINE ]; static int qconsole_linelen = 0; +static qboolean qconsole_drawinput = qtrue; static HANDLE qconsole_hout; static HANDLE qconsole_hin; @@ -181,6 +182,10 @@ static void CON_Show( void ) GetConsoleScreenBufferInfo( qconsole_hout, &binfo ); + // if we're in the middle of printf, don't bother writing the buffer + if( !qconsole_drawinput ) + return; + writeArea.Left = 0; writeArea.Top = binfo.dwCursorPosition.Y; writeArea.Bottom = binfo.dwCursorPosition.Y; @@ -424,6 +429,8 @@ void CON_WindowsColorPrint( const char *msg ) while( *msg ) { + qconsole_drawinput = ( *msg == '\n' ); + if( Q_IsColorString( msg ) || *msg == '\n' ) { // First empty the buffer From 693e51c6544f1b903d6a6587c4d9d8bd520d104b Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 11 Jan 2013 17:29:39 -0600 Subject: [PATCH 05/18] Remove old FIXME, pmove_framecount isn't networked --- code/qcommon/q_shared.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 622f98c3..786fca25 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -1184,7 +1184,7 @@ typedef struct playerState_s { // not communicated over the net at all int ping; // server to game info for scoreboard - int pmove_framecount; // FIXME: don't transmit over the network + int pmove_framecount; int jumppad_frame; int entityEventSequence; } playerState_t; From 5fd456ff7c87577b73a8eede5b05a09206b103cd Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sun, 13 Jan 2013 22:05:58 +0000 Subject: [PATCH 06/18] Fix FS_FOpenFileRead corner case FS_FOpenFileRead is a fairly mental function that changes its return behaviour depending on whether or not file is NULL or not. It turns out in the case where file is NULL, we were returning the wrong value when the file didn't exist. --- code/qcommon/files.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/code/qcommon/files.c b/code/qcommon/files.c index 5dffc06f..aa7dde8f 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -1360,10 +1360,17 @@ long FS_FOpenFileRead(const char *filename, fileHandle_t *file, qboolean uniqueF fprintf(missingFiles, "%s\n", filename); #endif - if(file) - *file = 0; - - return -1; + if(file) + { + *file = 0; + return -1; + } + else + { + // When file is NULL, we're querying the existance of the file + // If we've got here, it doesn't exist + return 0; + } } /* From 70b165ee336c9fb7086a628bb8e3e9721bcd920b Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sun, 13 Jan 2013 22:17:10 +0000 Subject: [PATCH 07/18] Fix screwed up whitespace in files.c Apologies to anyone merging this :( --- code/qcommon/files.c | 338 +++++++++++++++++++++---------------------- 1 file changed, 169 insertions(+), 169 deletions(-) diff --git a/code/qcommon/files.c b/code/qcommon/files.c index aa7dde8f..e4f3f020 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -450,9 +450,9 @@ long FS_filelength(fileHandle_t f) h = FS_FileForHandle(f); if(h == NULL) - return -1; - else - return FS_fplength(h); + return -1; + else + return FS_fplength(h); } /* @@ -986,7 +986,7 @@ Ignore case and seprator char distinctions */ qboolean FS_FilenameCompare( const char *s1, const char *s2 ) { int c1, c2; - + do { c1 = *s1++; c2 = *s2++; @@ -1004,12 +1004,12 @@ qboolean FS_FilenameCompare( const char *s1, const char *s2 ) { if ( c2 == '\\' || c2 == ':' ) { c2 = '/'; } - + if (c1 != c2) { return qtrue; // strings not equal } } while (c1); - + return qfalse; // strings are equal } @@ -1057,8 +1057,8 @@ qboolean FS_IsDemoExt(const char *filename, int namelen) return qtrue; #ifdef LEGACY_PROTOCOL - if(protocol == com_legacyprotocol->integer) - return qtrue; + if(protocol == com_legacyprotocol->integer) + return qtrue; #endif for(index = 0; demo_protocols[index]; index++) @@ -1103,19 +1103,19 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ // be prepended, so we don't need to worry about "c:" or "//limbo" if(strstr(filename, ".." ) || strstr(filename, "::")) { - if(file == NULL) - return qfalse; - + if(file == NULL) + return qfalse; + *file = 0; return -1; } - + // make sure the q3key file is only readable by the quake3.exe at initialization // any other time the key should only be accessed in memory using the provided functions if(com_fullyInitialized && strstr(filename, "q3key")) { - if(file == NULL) - return qfalse; + if(file == NULL) + return qfalse; *file = 0; return -1; @@ -1129,9 +1129,9 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ if(search->pack) { hash = FS_HashFileName(filename, search->pack->hashSize); - - if(search->pack->hashTable[hash]) - { + + if(search->pack->hashTable[hash]) + { // look through all the pak file elements pak = search->pack; pakFile = pak->hashTable[hash]; @@ -1143,14 +1143,14 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ { // found it! if(pakFile->len) - return pakFile->len; - else - { - // It's not nice, but legacy code depends - // on positive value if file exists no matter - // what size - return 1; - } + return pakFile->len; + else + { + // It's not nice, but legacy code depends + // on positive value if file exists no matter + // what size + return 1; + } } pakFile = pakFile->next; @@ -1160,28 +1160,28 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ else if(search->dir) { dir = search->dir; - + netpath = FS_BuildOSPath(dir->path, dir->gamedir, filename); filep = fopen (netpath, "rb"); if(filep) { - len = FS_fplength(filep); + len = FS_fplength(filep); fclose(filep); - + if(len) - return len; - else - return 1; + return len; + else + return 1; } } - + return 0; } *file = FS_HandleForFile(); fsh[*file].handleFiles.unique = uniqueFILE; - + // is the element a pak file? if(search->pack) { @@ -1199,7 +1199,7 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ // look through all the pak file elements pak = search->pack; pakFile = pak->hashTable[hash]; - + do { // case and separator insensitive comparisons @@ -1238,7 +1238,7 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ { // open a new file on the pakfile fsh[*file].handleFiles.file.z = unzOpen(pak->pakFilename); - + if(fsh[*file].handleFiles.file.z == NULL) Com_Error(ERR_FATAL, "Couldn't open %s", pak->pakFilename); } @@ -1247,7 +1247,7 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ Q_strncpyz(fsh[*file].name, filename, sizeof(fsh[*file].name)); fsh[*file].zipFile = qtrue; - + // set the file position in the zip file (also sets the current file info) unzSetOffset(fsh[*file].handleFiles.file.z, pakFile->pos); @@ -1258,12 +1258,12 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ if(fs_debug->integer) { Com_Printf("FS_FOpenFileRead: %s (found in '%s')\n", - filename, pak->pakFilename); + filename, pak->pakFilename); } - + return pakFile->len; } - + pakFile = pakFile->next; } while(pakFile != NULL); } @@ -1301,16 +1301,16 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ if (filep == NULL) { *file = 0; - return -1; + return -1; } Q_strncpyz(fsh[*file].name, filename, sizeof(fsh[*file].name)); fsh[*file].zipFile = qfalse; - + if(fs_debug->integer) { Com_Printf("FS_FOpenFileRead: %s (found in '%s/%s')\n", filename, - dir->path, dir->gamedir); + dir->path, dir->gamedir); } fsh[*file].handleFiles.file.o = filep; @@ -1340,19 +1340,19 @@ long FS_FOpenFileRead(const char *filename, fileHandle_t *file, qboolean uniqueF for(search = fs_searchpaths; search; search = search->next) { - len = FS_FOpenFileReadDir(filename, search, file, uniqueFILE, qfalse); - - if(file == NULL) - { - if(len > 0) - return len; - } - else - { - if(len >= 0 && *file) - return len; - } - + len = FS_FOpenFileReadDir(filename, search, file, uniqueFILE, qfalse); + + if(file == NULL) + { + if(len > 0) + return len; + } + else + { + if(len >= 0 && *file) + return len; + } + } #ifdef FS_MISSING @@ -1403,7 +1403,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha if(enableDll) Com_sprintf(dllName, sizeof(dllName), "%s" ARCH_STRING DLL_EXT, name); - + Com_sprintf(qvmName, sizeof(qvmName), "vm/%s.qvm", name); lastSearch = *startSearch; @@ -1411,7 +1411,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha search = fs_searchpaths; else search = lastSearch->next; - + while(search) { if(search->dir && !fs_numServerPaks) @@ -1426,7 +1426,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha { Q_strncpyz(found, netpath, foundlen); *startSearch = search; - + return VMI_NATIVE; } } @@ -1441,17 +1441,17 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha { pack = search->pack; - if(lastSearch && lastSearch->pack) - { - // make sure we only try loading one VM file per game dir - // i.e. if VM from pak7.pk3 fails we won't try one from pak6.pk3 - - if(!FS_FilenameCompare(lastSearch->pack->pakPathname, pack->pakPathname)) - { - search = search->next; - continue; - } - } + if(lastSearch && lastSearch->pack) + { + // make sure we only try loading one VM file per game dir + // i.e. if VM from pak7.pk3 fails we won't try one from pak6.pk3 + + if(!FS_FilenameCompare(lastSearch->pack->pakPathname, pack->pakPathname)) + { + search = search->next; + continue; + } + } if(FS_FOpenFileReadDir(qvmName, search, NULL, qfalse, qfalse) > 0) { @@ -1460,7 +1460,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha return VMI_COMPILED; } } - + search = search->next; } @@ -1621,7 +1621,7 @@ int FS_Seek( fileHandle_t f, long offset, int origin ) { if (fsh[f].streamed) { fsh[f].streamed = qfalse; - FS_Seek( f, offset, origin ); + FS_Seek( f, offset, origin ); fsh[f].streamed = qtrue; } @@ -1827,7 +1827,7 @@ long FS_ReadFileDir(const char *qpath, void *searchPath, qboolean unpure, void * { // look for it in the filesystem or pack files len = FS_FOpenFileRead(qpath, &h, qfalse); - } + } else { // look for it in a specific search path only @@ -1847,7 +1847,7 @@ long FS_ReadFileDir(const char *qpath, void *searchPath, qboolean unpure, void * } return -1; } - + if ( !buffer ) { if ( isConfig && com_journal && com_journal->integer == 1 ) { Com_DPrintf( "Writing len for %s to journal file.\n", qpath ); @@ -2088,21 +2088,21 @@ qboolean FS_CompareZipChecksum(const char *zipfile) { pack_t *thepak; int index, checksum; - + thepak = FS_LoadZipFile(zipfile, ""); - + if(!thepak) return qfalse; - + checksum = thepak->checksum; FS_FreePak(thepak); - + for(index = 0; index < fs_numServerReferencedPaks; index++) { if(checksum == fs_serverReferencedPaks[index]) return qtrue; } - + return qfalse; } @@ -2253,7 +2253,7 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt temp = pathLength; if (pathLength) { - temp++; // include the '/' + temp++; // include the '/' } nfiles = FS_AddFileToList( name + temp, list, nfiles ); } @@ -2266,8 +2266,8 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt // don't scan directories for files if we are pure or restricted if ( fs_numServerPaks && !allowNonPureFilesOnDisk ) { - continue; - } else { + continue; + } else { netpath = FS_BuildOSPath( search->dir->path, search->dir->gamedir, path ); sysFiles = Sys_ListFiles( netpath, extension, filter, &numSysFiles, qfalse ); for ( i = 0 ; i < numSysFiles ; i++ ) { @@ -2277,7 +2277,7 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt } Sys_FreeFileList( sysFiles ); } - } + } } // return a copy of the list @@ -2842,7 +2842,7 @@ void FS_AddGameDirectory( const char *path, const char *dir ) { return; // we've already got this one } } - + Q_strncpyz( fs_gamedir, dir, sizeof( fs_gamedir ) ); // find all pak files in this directory @@ -2861,7 +2861,7 @@ void FS_AddGameDirectory( const char *path, const char *dir ) { Q_strncpyz(pak->pakPathname, curpath, sizeof(pak->pakPathname)); // store the game name for downloading Q_strncpyz(pak->pakGamename, dir, sizeof(pak->pakGamename)); - + fs_packFiles += pak->numfiles; search = Z_Malloc (sizeof(searchpath_t)); @@ -2969,9 +2969,9 @@ qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ) { // never autodownload any of the id paks if(FS_idPak(fs_serverReferencedPakNames[i], BASEGAME, NUM_ID_PAKS) #ifndef STANDALONE - || FS_idPak(fs_serverReferencedPakNames[i], BASETA, NUM_TA_PAKS) + || FS_idPak(fs_serverReferencedPakNames[i], BASETA, NUM_TA_PAKS) #endif - ) + ) { continue; } @@ -3171,14 +3171,14 @@ static void FS_Startup( const char *gameName ) FS_AddGameDirectory( fs_basepath->string, gameName ); } // fs_homepath is somewhat particular to *nix systems, only add if relevant - - #ifdef MACOS_X + +#ifdef MACOS_X fs_apppath = Cvar_Get ("fs_apppath", Sys_DefaultAppPath(), CVAR_INIT|CVAR_PROTECTED ); // Make MacOSX also include the base path included with the .app bundle if (fs_apppath->string[0]) FS_AddGameDirectory(fs_apppath->string, gameName); - #endif - +#endif + // NOTE: same filtering below for mods and basegame if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { FS_CreatePath ( fs_homepath->string ); @@ -3270,80 +3270,80 @@ static void FS_CheckPak0( void ) if(!path->pack) continue; - + curpack = path->pack; if(!Q_stricmpn( curpack->pakGamename, "demoq3", MAX_OSPATH ) - && !Q_stricmpn( pakBasename, "pak0", MAX_OSPATH )) + && !Q_stricmpn( pakBasename, "pak0", MAX_OSPATH )) { if(curpack->checksum == DEMO_PAK0_CHECKSUM) founddemo = qtrue; } else if(!Q_stricmpn( curpack->pakGamename, BASEGAME, MAX_OSPATH ) - && strlen(pakBasename) == 4 && !Q_stricmpn( pakBasename, "pak", 3 ) - && pakBasename[3] >= '0' && pakBasename[3] <= '0' + NUM_ID_PAKS - 1) + && strlen(pakBasename) == 4 && !Q_stricmpn( pakBasename, "pak", 3 ) + && pakBasename[3] >= '0' && pakBasename[3] <= '0' + NUM_ID_PAKS - 1) { if( curpack->checksum != pak_checksums[pakBasename[3]-'0'] ) { if(pakBasename[3] == '0') { Com_Printf("\n\n" - "**************************************************\n" - "WARNING: " BASEGAME "/pak0.pk3 is present but its checksum (%u)\n" - "is not correct. Please re-copy pak0.pk3 from your\n" - "legitimate Q3 CDROM.\n" - "**************************************************\n\n\n", - curpack->checksum ); + "**************************************************\n" + "WARNING: " BASEGAME "/pak0.pk3 is present but its checksum (%u)\n" + "is not correct. Please re-copy pak0.pk3 from your\n" + "legitimate Q3 CDROM.\n" + "**************************************************\n\n\n", + curpack->checksum ); } else { Com_Printf("\n\n" - "**************************************************\n" - "WARNING: " BASEGAME "/pak%d.pk3 is present but its checksum (%u)\n" - "is not correct. Please re-install the point release\n" - "**************************************************\n\n\n", - pakBasename[3]-'0', curpack->checksum ); + "**************************************************\n" + "WARNING: " BASEGAME "/pak%d.pk3 is present but its checksum (%u)\n" + "is not correct. Please re-install the point release\n" + "**************************************************\n\n\n", + pakBasename[3]-'0', curpack->checksum ); } } foundPak |= 1<<(pakBasename[3]-'0'); } else if(!Q_stricmpn(curpack->pakGamename, BASETA, MAX_OSPATH) - && strlen(pakBasename) == 4 && !Q_stricmpn(pakBasename, "pak", 3) - && pakBasename[3] >= '0' && pakBasename[3] <= '0' + NUM_TA_PAKS - 1) - + && strlen(pakBasename) == 4 && !Q_stricmpn(pakBasename, "pak", 3) + && pakBasename[3] >= '0' && pakBasename[3] <= '0' + NUM_TA_PAKS - 1) + { if(curpack->checksum != missionpak_checksums[pakBasename[3]-'0']) { Com_Printf("\n\n" - "**************************************************\n" - "WARNING: " BASETA "/pak%d.pk3 is present but its checksum (%u)\n" - "is not correct. Please re-install Team Arena\n" - "**************************************************\n\n\n", - pakBasename[3]-'0', curpack->checksum ); + "**************************************************\n" + "WARNING: " BASETA "/pak%d.pk3 is present but its checksum (%u)\n" + "is not correct. Please re-install Team Arena\n" + "**************************************************\n\n\n", + pakBasename[3]-'0', curpack->checksum ); } - + foundTA |= 1 << (pakBasename[3]-'0'); } else { int index; - + // Finally check whether this pak's checksum is listed because the user tried // to trick us by renaming the file, and set foundPak's highest bit to indicate this case. - + for(index = 0; index < ARRAY_LEN(pak_checksums); index++) { if(curpack->checksum == pak_checksums[index]) { Com_Printf("\n\n" - "**************************************************\n" - "WARNING: %s is renamed pak file %s%cpak%d.pk3\n" - "Running in standalone mode won't work\n" - "Please rename, or remove this file\n" - "**************************************************\n\n\n", - curpack->pakFilename, BASEGAME, PATH_SEP, index); + "**************************************************\n" + "WARNING: %s is renamed pak file %s%cpak%d.pk3\n" + "Running in standalone mode won't work\n" + "Please rename, or remove this file\n" + "**************************************************\n\n\n", + curpack->pakFilename, BASEGAME, PATH_SEP, index); foundPak |= 0x80000000; @@ -3355,12 +3355,12 @@ static void FS_CheckPak0( void ) if(curpack->checksum == missionpak_checksums[index]) { Com_Printf("\n\n" - "**************************************************\n" - "WARNING: %s is renamed pak file %s%cpak%d.pk3\n" - "Running in standalone mode won't work\n" - "Please rename, or remove this file\n" - "**************************************************\n\n\n", - curpack->pakFilename, BASETA, PATH_SEP, index); + "**************************************************\n" + "WARNING: %s is renamed pak file %s%cpak%d.pk3\n" + "Running in standalone mode won't work\n" + "Please rename, or remove this file\n" + "**************************************************\n\n\n", + curpack->pakFilename, BASETA, PATH_SEP, index); foundTA |= 0x80000000; } @@ -3387,7 +3387,7 @@ static void FS_CheckPak0( void ) "from the demo. This may work fine, but it is not\n" "guaranteed or supported.\n" "**************************************************\n\n\n" ); - + foundPak |= 0x01; } } @@ -3401,25 +3401,25 @@ static void FS_CheckPak0( void ) if((foundPak & 0x01) != 0x01) { Q_strcat(errorText, sizeof(errorText), - "\"pak0.pk3\" is missing. Please copy it " - "from your legitimate Q3 CDROM. "); + "\"pak0.pk3\" is missing. Please copy it " + "from your legitimate Q3 CDROM. "); } if((foundPak & 0x1fe) != 0x1fe) { Q_strcat(errorText, sizeof(errorText), - "Point Release files are missing. Please " - "re-install the 1.32 point release. "); + "Point Release files are missing. Please " + "re-install the 1.32 point release. "); } Q_strcat(errorText, sizeof(errorText), - va("Also check that your ioq3 executable is in " - "the correct place and that every file " - "in the \"%s\" directory is present and readable", BASEGAME)); + va("Also check that your ioq3 executable is in " + "the correct place and that every file " + "in the \"%s\" directory is present and readable", BASEGAME)); Com_Error(ERR_FATAL, "%s", errorText); } - + if(!com_standalone->integer && foundTA && (foundTA & 0x0f) != 0x0f) { char errorText[MAX_STRING_CHARS] = ""; @@ -3427,15 +3427,15 @@ static void FS_CheckPak0( void ) if((foundTA & 0x01) != 0x01) { Com_sprintf(errorText, sizeof(errorText), - "\"" BASETA "%cpak0.pk3\" is missing. Please copy it " - "from your legitimate Quake 3 Team Arena CDROM. ", PATH_SEP); + "\"" BASETA "%cpak0.pk3\" is missing. Please copy it " + "from your legitimate Quake 3 Team Arena CDROM. ", PATH_SEP); } if((foundTA & 0x0e) != 0x0e) { Q_strcat(errorText, sizeof(errorText), - "Team Arena Point Release files are missing. Please " - "re-install the latest Team Arena point release."); + "Team Arena Point Release files are missing. Please " + "re-install the latest Team Arena point release."); } Com_Error(ERR_FATAL, "%s", errorText); @@ -3756,11 +3756,11 @@ void FS_PureServerSetReferencedPaks( const char *pakSums, const char *pakNames ) fs_serverReferencedPakNames[i] = CopyString( Cmd_Argv( i ) ); } } - + // ensure that there are as many checksums as there are pak names. if(d < c) c = d; - + fs_numServerReferencedPaks = c; } @@ -3870,8 +3870,8 @@ qboolean FS_ConditionalRestart(int checksumFeed, qboolean disconnect) if(fs_gamedirvar->modified) { if(FS_FilenameCompare(lastValidGame, fs_gamedirvar->string) && - (*lastValidGame || FS_FilenameCompare(fs_gamedirvar->string, com_basegame->string)) && - (*fs_gamedirvar->string || FS_FilenameCompare(lastValidGame, com_basegame->string))) + (*lastValidGame || FS_FilenameCompare(fs_gamedirvar->string, com_basegame->string)) && + (*fs_gamedirvar->string || FS_FilenameCompare(lastValidGame, com_basegame->string))) { Com_GameRestart(checksumFeed, disconnect); return qtrue; @@ -3879,12 +3879,12 @@ qboolean FS_ConditionalRestart(int checksumFeed, qboolean disconnect) else fs_gamedirvar->modified = qfalse; } - + if(checksumFeed != fs_checksumFeed) FS_Restart(checksumFeed); else if(fs_numServerPaks && !fs_reordered) FS_ReorderPurePaks(); - + return qfalse; } @@ -3903,28 +3903,28 @@ int FS_FOpenFileByMode( const char *qpath, fileHandle_t *f, fsMode_t mode ) { sync = qfalse; switch( mode ) { - case FS_READ: - r = FS_FOpenFileRead( qpath, f, qtrue ); - break; - case FS_WRITE: - *f = FS_FOpenFileWrite( qpath ); - r = 0; - if (*f == 0) { - r = -1; - } - break; - case FS_APPEND_SYNC: - sync = qtrue; - case FS_APPEND: - *f = FS_FOpenFileAppend( qpath ); - r = 0; - if (*f == 0) { - r = -1; - } - break; - default: - Com_Error( ERR_FATAL, "FS_FOpenFileByMode: bad mode" ); - return -1; + case FS_READ: + r = FS_FOpenFileRead( qpath, f, qtrue ); + break; + case FS_WRITE: + *f = FS_FOpenFileWrite( qpath ); + r = 0; + if (*f == 0) { + r = -1; + } + break; + case FS_APPEND_SYNC: + sync = qtrue; + case FS_APPEND: + *f = FS_FOpenFileAppend( qpath ); + r = 0; + if (*f == 0) { + r = -1; + } + break; + default: + Com_Error( ERR_FATAL, "FS_FOpenFileByMode: bad mode" ); + return -1; } if (!f) { From 76f906703ef7438762fa784919aba76a616cd2c1 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Mon, 14 Jan 2013 00:22:57 -0600 Subject: [PATCH 08/18] Fix error message in BG_EvaluateTrajectoryDelta --- code/game/bg_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/bg_misc.c b/code/game/bg_misc.c index 597b4928..36c9c403 100644 --- a/code/game/bg_misc.c +++ b/code/game/bg_misc.c @@ -1272,7 +1272,7 @@ void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t resu result[2] -= DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity... break; default: - Com_Error( ERR_DROP, "BG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime ); + Com_Error( ERR_DROP, "BG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trType ); break; } } From 4de32b1c1af6ced13e1ebcef7aa9662b513ee91f Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Mon, 14 Jan 2013 14:50:12 -0600 Subject: [PATCH 09/18] Fix error message in BG_EvaluateTrajectory --- code/game/bg_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/bg_misc.c b/code/game/bg_misc.c index 36c9c403..9a271098 100644 --- a/code/game/bg_misc.c +++ b/code/game/bg_misc.c @@ -1229,7 +1229,7 @@ void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) result[2] -= 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity... break; default: - Com_Error( ERR_DROP, "BG_EvaluateTrajectory: unknown trType: %i", tr->trTime ); + Com_Error( ERR_DROP, "BG_EvaluateTrajectory: unknown trType: %i", tr->trType ); break; } } From bf2b04254ab9c38cba0cd167bcaa0de8c3765349 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Wed, 16 Jan 2013 23:03:09 -0600 Subject: [PATCH 10/18] Add togglemenu command Allow togglemenu to be run in binds while in menu or message mode. --- README | 2 ++ code/client/cl_console.c | 12 ++++++++++ code/client/cl_keys.c | 51 +++++++++++++++++++++++++++++++--------- 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/README b/README index d8fd12af..b9b0ccbd 100644 --- a/README +++ b/README @@ -281,6 +281,8 @@ New commands stopvideo - stop video capture stopmusic - stop background music minimize - Minimize the game and show desktop + togglemenu - causes escape key event for opening/closing menu, or + going to a pervious menu. works in binds, even in UI print - print out the contents of a cvar unset - unset a user created cvar diff --git a/code/client/cl_console.c b/code/client/cl_console.c index 3d5ef021..2ee92db3 100644 --- a/code/client/cl_console.c +++ b/code/client/cl_console.c @@ -81,6 +81,16 @@ void Con_ToggleConsole_f (void) { Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_CONSOLE ); } +/* +=================== +Con_ToggleMenu_f +=================== +*/ +void Con_ToggleMenu_f( void ) { + CL_KeyEvent( K_ESCAPE, qtrue, Sys_Milliseconds() ); + CL_KeyEvent( K_ESCAPE, qfalse, Sys_Milliseconds() ); +} + /* ================ Con_MessageMode_f @@ -332,6 +342,7 @@ void Con_Init (void) { CL_LoadConsoleHistory( ); Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f); + Cmd_AddCommand ("togglemenu", Con_ToggleMenu_f); Cmd_AddCommand ("messagemode", Con_MessageMode_f); Cmd_AddCommand ("messagemode2", Con_MessageMode2_f); Cmd_AddCommand ("messagemode3", Con_MessageMode3_f); @@ -349,6 +360,7 @@ Con_Shutdown void Con_Shutdown(void) { Cmd_RemoveCommand("toggleconsole"); + Cmd_RemoveCommand("togglemenu"); Cmd_RemoveCommand("messagemode"); Cmd_RemoveCommand("messagemode2"); Cmd_RemoveCommand("messagemode3"); diff --git a/code/client/cl_keys.c b/code/client/cl_keys.c index 80e66754..73af33e5 100644 --- a/code/client/cl_keys.c +++ b/code/client/cl_keys.c @@ -1120,6 +1120,23 @@ void CL_InitKeyCommands( void ) { Cmd_AddCommand ("bindlist",Key_Bindlist_f); } +/* +=================== +CL_BindUICommand + +Returns qtrue if bind command should be executed while user interface is shown +=================== +*/ +static qboolean CL_BindUICommand( const char *cmd ) { + if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) + return qfalse; + + if ( !Q_stricmp( cmd, "togglemenu" ) ) + return qtrue; + + return qfalse; +} + /* =================== CL_ParseBinding @@ -1130,11 +1147,20 @@ Execute the commands in the bind string void CL_ParseBinding( int key, qboolean down, unsigned time ) { char buf[ MAX_STRING_CHARS ], *p = buf, *end; + qboolean allCommands, allowUpCmds; + if( clc.state == CA_DISCONNECTED && Key_GetCatcher( ) == 0 ) + return; if( !keys[key].binding || !keys[key].binding[0] ) return; Q_strncpyz( buf, keys[key].binding, sizeof( buf ) ); + // run all bind commands if console, ui, etc aren't reading keys + allCommands = ( Key_GetCatcher( ) == 0 ); + + // allow button up commands if in game even if key catcher is set + allowUpCmds = ( clc.state != CA_DISCONNECTED ); + while( 1 ) { while( isspace( *p ) ) @@ -1147,16 +1173,20 @@ void CL_ParseBinding( int key, qboolean down, unsigned time ) // button commands add keynum and time as parameters // so that multiple sources can be discriminated and // subframe corrected - char cmd[1024]; - Com_sprintf( cmd, sizeof( cmd ), "%c%s %d %d\n", - ( down ) ? '+' : '-', p + 1, key, time ); - Cbuf_AddText( cmd ); + if ( allCommands || ( allowUpCmds && !down ) ) { + char cmd[1024]; + Com_sprintf( cmd, sizeof( cmd ), "%c%s %d %d\n", + ( down ) ? '+' : '-', p + 1, key, time ); + Cbuf_AddText( cmd ); + } } else if( down ) { // normal commands only execute on key press - Cbuf_AddText( p ); - Cbuf_AddText( "\n" ); + if ( allCommands || CL_BindUICommand( p ) ) { + Cbuf_AddText( p ); + Cbuf_AddText( "\n" ); + } } if( !end ) break; @@ -1250,10 +1280,10 @@ void CL_KeyDownEvent( int key, unsigned time ) Message_Key( key ); } else if ( clc.state == CA_DISCONNECTED ) { Console_Key( key ); - } else { - // send the bound action - CL_ParseBinding( key, qtrue, time ); } + + // send the bound action + CL_ParseBinding( key, qtrue, time ); return; } @@ -1285,8 +1315,7 @@ void CL_KeyUpEvent( int key, unsigned time ) // console mode and menu mode, to keep the character from continuing // an action started before a mode switch. // - if( clc.state != CA_DISCONNECTED ) - CL_ParseBinding( key, qfalse, time ); + CL_ParseBinding( key, qfalse, time ); if ( Key_GetCatcher( ) & KEYCATCH_UI && uivm ) { VM_Call( uivm, UI_KEY_EVENT, key, qfalse ); From 4ba14425ed8631f89129d36de5dfb2cb2ecb527d Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Wed, 16 Jan 2013 23:04:50 -0600 Subject: [PATCH 11/18] Add togglemenu to q3_ui controls menu --- code/q3_ui/ui_controls2.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/code/q3_ui/ui_controls2.c b/code/q3_ui/ui_controls2.c index 907ad00f..55d33289 100644 --- a/code/q3_ui/ui_controls2.c +++ b/code/q3_ui/ui_controls2.c @@ -111,16 +111,17 @@ typedef struct #define ID_CHAT2 31 #define ID_CHAT3 32 #define ID_CHAT4 33 +#define ID_TOGGLEMENU 34 // all others -#define ID_FREELOOK 34 -#define ID_INVERTMOUSE 35 -#define ID_ALWAYSRUN 36 -#define ID_AUTOSWITCH 37 -#define ID_MOUSESPEED 38 -#define ID_JOYENABLE 39 -#define ID_JOYTHRESHOLD 40 -#define ID_SMOOTHMOUSE 41 +#define ID_FREELOOK 35 +#define ID_INVERTMOUSE 36 +#define ID_ALWAYSRUN 37 +#define ID_AUTOSWITCH 38 +#define ID_MOUSESPEED 39 +#define ID_JOYENABLE 40 +#define ID_JOYTHRESHOLD 41 +#define ID_SMOOTHMOUSE 42 #define ANIM_IDLE 0 #define ANIM_RUN 1 @@ -205,6 +206,7 @@ typedef struct menuaction_s chat2; menuaction_s chat3; menuaction_s chat4; + menuaction_s togglemenu; menuradiobutton_s joyenable; menuslider_s joythreshold; int section; @@ -261,6 +263,7 @@ static bind_t g_bindings[] = {"messagemode2", "chat - team", ID_CHAT2, ANIM_CHAT, -1, -1, -1, -1}, {"messagemode3", "chat - target", ID_CHAT3, ANIM_CHAT, -1, -1, -1, -1}, {"messagemode4", "chat - attacker", ID_CHAT4, ANIM_CHAT, -1, -1, -1, -1}, + {"togglemenu", "toggle menu", ID_TOGGLEMENU, ANIM_IDLE, K_ESCAPE, -1, -1, -1}, {(char*)NULL, (char*)NULL, 0, 0, -1, -1, -1, -1}, }; @@ -333,6 +336,7 @@ static menucommon_s *g_misc_controls[] = { (menucommon_s *)&s_controls.chat2, (menucommon_s *)&s_controls.chat3, (menucommon_s *)&s_controls.chat4, + (menucommon_s *)&s_controls.togglemenu, NULL, }; @@ -1532,6 +1536,12 @@ static void Controls_MenuInit( void ) s_controls.chat4.generic.ownerdraw = Controls_DrawKeyBinding; s_controls.chat4.generic.id = ID_CHAT4; + s_controls.togglemenu.generic.type = MTYPE_ACTION; + s_controls.togglemenu.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; + s_controls.togglemenu.generic.callback = Controls_ActionEvent; + s_controls.togglemenu.generic.ownerdraw = Controls_DrawKeyBinding; + s_controls.togglemenu.generic.id = ID_TOGGLEMENU; + s_controls.joyenable.generic.type = MTYPE_RADIOBUTTON; s_controls.joyenable.generic.flags = QMF_SMALLFONT; s_controls.joyenable.generic.x = SCREEN_WIDTH/2; @@ -1614,6 +1624,7 @@ static void Controls_MenuInit( void ) Menu_AddItem( &s_controls.menu, &s_controls.chat2 ); Menu_AddItem( &s_controls.menu, &s_controls.chat3 ); Menu_AddItem( &s_controls.menu, &s_controls.chat4 ); + Menu_AddItem( &s_controls.menu, &s_controls.togglemenu ); Menu_AddItem( &s_controls.menu, &s_controls.back ); From 9c701a781b518486e55a343cc574fa8583b78ac6 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Wed, 16 Jan 2013 23:06:35 -0600 Subject: [PATCH 12/18] Run toggleconsole in binds while in menu or message mode --- code/client/cl_keys.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/client/cl_keys.c b/code/client/cl_keys.c index 73af33e5..539dd77a 100644 --- a/code/client/cl_keys.c +++ b/code/client/cl_keys.c @@ -1131,6 +1131,8 @@ static qboolean CL_BindUICommand( const char *cmd ) { if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) return qfalse; + if ( !Q_stricmp( cmd, "toggleconsole" ) ) + return qtrue; if ( !Q_stricmp( cmd, "togglemenu" ) ) return qtrue; From 57632a0ae8cd2f29536fac5586522cd2cb567a15 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Wed, 16 Jan 2013 23:18:51 -0600 Subject: [PATCH 13/18] Fix typo in README --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index b9b0ccbd..f0fad313 100644 --- a/README +++ b/README @@ -282,7 +282,7 @@ New commands stopmusic - stop background music minimize - Minimize the game and show desktop togglemenu - causes escape key event for opening/closing menu, or - going to a pervious menu. works in binds, even in UI + going to a previous menu. works in binds, even in UI print - print out the contents of a cvar unset - unset a user created cvar From 4432a80a3c97cbebc0aab5b104afa701840c10fd Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Thu, 17 Jan 2013 17:47:11 +0000 Subject: [PATCH 14/18] Add vim stuff to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 810b319c..bfd2d925 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build Makefile.local +*.swp +*tags From 3f489fe5f2f83706fa04c1466ddc60ff743f70d5 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Thu, 17 Jan 2013 15:21:29 -0600 Subject: [PATCH 15/18] Make UI_CVAR_CREATE use VM specific code Makes cvar be flagged as VM created and unset ROM if ARCHIVE is set. --- code/client/cl_ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/client/cl_ui.c b/code/client/cl_ui.c index 19223a32..834fa649 100644 --- a/code/client/cl_ui.c +++ b/code/client/cl_ui.c @@ -750,7 +750,7 @@ intptr_t CL_UISystemCalls( intptr_t *args ) { return 0; case UI_CVAR_CREATE: - Cvar_Get( VMA(1), VMA(2), args[3] ); + Cvar_Register( NULL, VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: From 51df89ab132b8e05d9854df507c73e54fbd2884b Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Thu, 24 Jan 2013 22:53:08 +0000 Subject: [PATCH 16/18] Remove the SMP renderer feature --- Makefile | 87 ++----------- code/client/cl_cin.c | 5 - code/rend2/tr_backend.c | 45 +------ code/rend2/tr_bsp.c | 4 +- code/rend2/tr_cmds.c | 96 ++------------ code/rend2/tr_fbo.c | 5 +- code/rend2/tr_font.c | 3 +- code/rend2/tr_glsl.c | 3 +- code/rend2/tr_image.c | 3 +- code/rend2/tr_init.c | 33 ++--- code/rend2/tr_light.c | 8 +- code/rend2/tr_local.h | 47 ++----- code/rend2/tr_main.c | 7 +- code/rend2/tr_model.c | 5 +- code/rend2/tr_scene.c | 36 +++--- code/rend2/tr_shader.c | 14 +-- code/rend2/tr_surface.c | 22 ++-- code/rend2/tr_vbo.c | 12 +- code/rend2/tr_world.c | 16 +-- code/renderer/tr_backend.c | 44 +------ code/renderer/tr_bsp.c | 2 +- code/renderer/tr_cmds.c | 96 ++------------ code/renderer/tr_font.c | 3 +- code/renderer/tr_image.c | 3 +- code/renderer/tr_init.c | 33 ++--- code/renderer/tr_light.c | 6 +- code/renderer/tr_local.h | 37 ++---- code/renderer/tr_main.c | 7 +- code/renderer/tr_model.c | 5 +- code/renderer/tr_scene.c | 32 ++--- code/renderer/tr_shader.c | 14 +-- code/renderer/tr_surface.c | 6 +- code/renderer/tr_types.h | 2 +- code/renderer/tr_world.c | 8 +- code/sdl/sdl_glimp.c | 250 ------------------------------------- 35 files changed, 160 insertions(+), 839 deletions(-) diff --git a/Makefile b/Makefile index 194629dd..9ff5d917 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,6 @@ endif ifndef BUILD_CLIENT BUILD_CLIENT = endif -ifndef BUILD_CLIENT_SMP - BUILD_CLIENT_SMP = -endif ifndef BUILD_SERVER BUILD_SERVER = endif @@ -54,10 +51,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 @@ -586,8 +579,6 @@ ifeq ($(PLATFORM),mingw32) SDLDLL=SDL.dll endif - BUILD_CLIENT_SMP = 0 - else # ifeq mingw32 ############################################################################# @@ -861,26 +852,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 @@ -1030,11 +1009,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 - define DO_BOT_CC $(echo_cmd) "BOT_CC $<" $(Q)$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) $(BOTCFLAGS) $(OPTIMIZE) -DBOTLIB -o $@ -c $< @@ -1194,7 +1168,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 @@ -1599,14 +1572,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 \ @@ -1833,50 +1801,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)),) @@ -2390,9 +2335,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) @@ -2548,7 +2490,7 @@ $(B)/$(MISSIONPACK)/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) # MISC ############################################################################# -OBJ = $(Q3OBJ) $(Q3ROBJ) $(Q3R2OBJ) $(Q3RPOBJ_UP) $(Q3RPOBJ_SMP) $(Q3DOBJ) $(JPGOBJ) \ +OBJ = $(Q3OBJ) $(Q3ROBJ) $(Q3R2OBJ) $(Q3DOBJ) $(JPGOBJ) \ $(MPGOBJ) $(Q3GOBJ) $(Q3CGOBJ) $(MPCGOBJ) $(Q3UIOBJ) $(MPUIOBJ) \ $(MPGVMOBJ) $(Q3GVMOBJ) $(Q3CGVMOBJ) $(MPCGVMOBJ) $(Q3UIVMOBJ) $(MPUIVMOBJ) TOOLSOBJ = $(LBURGOBJ) $(Q3CPPOBJ) $(Q3RCCOBJ) $(Q3LCCOBJ) $(Q3ASMOBJ) @@ -2576,15 +2518,6 @@ ifneq ($(BUILD_CLIENT),0) endif endif -# Don't copy the SMP until it's working together with SDL. -ifneq ($(BUILD_CLIENT_SMP),0) - ifneq ($(USE_RENDERER_DLOPEN),0) - $(INSTALL) $(STRIP_FLAG) -m 0755 $(BR)/renderer_opengl1_smp_$(SHLIBNAME) $(COPYBINDIR)/renderer_opengl1_smp_$(SHLIBNAME) - else - $(INSTALL) $(STRIP_FLAG) -m 0755 $(BR)/$(CLIENTBIN)-smp$(FULLBINEXT) $(COPYBINDIR)/$(CLIENTBIN)-smp$(FULLBINEXT) - endif -endif - ifneq ($(BUILD_SERVER),0) @if [ -f $(BR)/$(SERVERBIN)$(FULLBINEXT) ]; then \ $(INSTALL) $(STRIP_FLAG) -m 0755 $(BR)/$(SERVERBIN)$(FULLBINEXT) $(COPYBINDIR)/$(SERVERBIN)$(FULLBINEXT); \ diff --git a/code/client/cl_cin.c b/code/client/cl_cin.c index 8d6f51c5..45c4dd45 100644 --- a/code/client/cl_cin.c +++ b/code/client/cl_cin.c @@ -1158,7 +1158,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; @@ -1226,7 +1225,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; @@ -1358,12 +1356,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; @@ -1372,7 +1368,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/code/rend2/tr_backend.c b/code/rend2/tr_backend.c index c3d39433..4e6ab2dd 100644 --- a/code/rend2/tr_backend.c +++ b/code/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/code/rend2/tr_bsp.c b/code/rend2/tr_bsp.c index 08e66c85..0eb56ce4 100644 --- a/code/rend2/tr_bsp.c +++ b/code/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/code/rend2/tr_cmds.c b/code/rend2/tr_cmds.c index 2f67d221..d4b83e1f 100644 --- a/code/rend2/tr_cmds.c +++ b/code/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 @@ -82,49 +79,15 @@ 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 @@ -423,7 +353,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { } else { - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); qglEnable( GL_STENCIL_TEST ); qglStencilMask( ~0U ); qglClearStencil( 0U ); @@ -436,7 +366,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; @@ -446,7 +376,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; } @@ -457,7 +387,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if ( r_gamma->modified ) { r_gamma->modified = qfalse; - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); R_SetColorMappings(); } @@ -466,7 +396,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); } @@ -612,9 +542,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/code/rend2/tr_fbo.c b/code/rend2/tr_fbo.c index 0e84d944..b498fe70 100644 --- a/code/rend2/tr_fbo.c +++ b/code/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/code/rend2/tr_font.c b/code/rend2/tr_font.c index 87465e52..0c3d2236 100644 --- a/code/rend2/tr_font.c +++ b/code/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/code/rend2/tr_glsl.c b/code/rend2/tr_glsl.c index 941d75a9..6e8d91ac 100644 --- a/code/rend2/tr_glsl.c +++ b/code/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/code/rend2/tr_image.c b/code/rend2/tr_image.c index 20edb0af..13dda827 100644 --- a/code/rend2/tr_image.c +++ b/code/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/code/rend2/tr_init.c b/code/rend2/tr_init.c index 94b97f8b..db782925 100644 --- a/code/rend2/tr_init.c +++ b/code/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(); } @@ -1028,9 +1023,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" ); } @@ -1142,7 +1134,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); @@ -1256,7 +1247,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 ); @@ -1393,19 +1383,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(); @@ -1461,8 +1443,7 @@ void RE_Shutdown( qboolean destroyWindow ) { if ( tr.registered ) { - R_SyncRenderThread(); - R_ShutdownCommandBuffers(); + R_IssuePendingRenderCommands(); R_ShutDownQueries(); if (glRefConfig.framebufferObject) FBO_Shutdown(); @@ -1490,7 +1471,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/code/rend2/tr_light.c b/code/rend2/tr_light.c index 9c15982a..4e90ce20 100644 --- a/code/rend2/tr_light.c +++ b/code/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/code/rend2/tr_local.h b/code/rend2/tr_local.h index 3abe5d3d..bb38e0e8 100644 --- a/code/rend2/tr_local.h +++ b/code/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; @@ -2082,8 +2074,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; @@ -2327,11 +2317,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); @@ -2586,7 +2571,7 @@ SCENE GENERATION ============================================================ */ -void R_ToggleSmpFrame( void ); +void R_InitNextFrame( void ); void RE_ClearScene( void ); void RE_AddRefEntityToScene( const refEntity_t *ent ); @@ -2700,7 +2685,6 @@ RENDERER BACK END FUNCTIONS ============================================================= */ -void RB_RenderThread( void ); void RB_ExecuteRenderCommands( const void *data ); /* @@ -2828,9 +2812,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]; @@ -2844,20 +2826,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/code/rend2/tr_main.c b/code/rend2/tr_main.c index 5b7ad5f7..0935dce7 100644 --- a/code/rend2/tr_main.c +++ b/code/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/code/rend2/tr_model.c b/code/rend2/tr_model.c index b77e10a1..5aeab8ef 100644 --- a/code/rend2/tr_model.c +++ b/code/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/code/rend2/tr_scene.c b/code/rend2/tr_scene.c index f134c997..c7a414f2 100644 --- a/code/rend2/tr_scene.c +++ b/code/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/code/rend2/tr_shader.c b/code/rend2/tr_shader.c index d66b5408..04aa73ae 100644 --- a/code/rend2/tr_shader.c +++ b/code/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/code/rend2/tr_surface.c b/code/rend2/tr_surface.c index 6f4e2b75..0ce683ec 100644 --- a/code/rend2/tr_surface.c +++ b/code/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/code/rend2/tr_vbo.c b/code/rend2/tr_vbo.c index 41af9375..65946f18 100644 --- a/code/rend2/tr_vbo.c +++ b/code/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/code/rend2/tr_world.c b/code/rend2/tr_world.c index 5e1bcf7b..950ee6a4 100644 --- a/code/rend2/tr_world.c +++ b/code/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/code/renderer/tr_backend.c b/code/renderer/tr_backend.c index 01c33af7..9113bbe3 100644 --- a/code/renderer/tr_backend.c +++ b/code/renderer/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; @@ -682,7 +682,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { /* ============================================================================ -RENDER BACK END THREAD FUNCTIONS +RENDER BACK END FUNCTIONS ============================================================================ */ @@ -734,7 +734,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(); @@ -1111,9 +1111,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 ) { @@ -1121,12 +1118,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 *)); @@ -1160,7 +1151,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; @@ -1168,30 +1159,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/code/renderer/tr_bsp.c b/code/renderer/tr_bsp.c index 17afd7ec..40e15412 100644 --- a/code/renderer/tr_bsp.c +++ b/code/renderer/tr_bsp.c @@ -147,7 +147,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/code/renderer/tr_cmds.c b/code/renderer/tr_cmds.c index fe3fd133..1d6beea5 100644 --- a/code/renderer/tr_cmds.c +++ b/code/renderer/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 @@ -75,49 +72,15 @@ 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; @@ -125,26 +88,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(); } @@ -152,49 +95,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 @@ -377,7 +307,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { } else { - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); qglEnable( GL_STENCIL_TEST ); qglStencilMask( ~0U ); qglClearStencil( 0U ); @@ -390,7 +320,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; @@ -400,7 +330,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; } @@ -411,7 +341,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if ( r_gamma->modified ) { r_gamma->modified = qfalse; - R_SyncRenderThread(); + R_IssuePendingRenderCommands(); R_SetColorMappings(); } @@ -420,7 +350,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); } @@ -534,9 +464,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/code/renderer/tr_font.c b/code/renderer/tr_font.c index 87465e52..0c3d2236 100644 --- a/code/renderer/tr_font.c +++ b/code/renderer/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/code/renderer/tr_image.c b/code/renderer/tr_image.c index f5112010..4ad15c37 100644 --- a/code/renderer/tr_image.c +++ b/code/renderer/tr_image.c @@ -1495,8 +1495,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/code/renderer/tr_init.c b/code/renderer/tr_init.c index a36e6f58..58b330e1 100644 --- a/code/renderer/tr_init.c +++ b/code/renderer/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; @@ -211,9 +209,6 @@ static void InitOpenGL( void ) } } - // init command buffers and SMP - R_InitCommandBuffers(); - // set default state GL_SetDefaultState(); } @@ -990,9 +985,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" ); } @@ -1045,7 +1037,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); @@ -1112,7 +1103,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 ); @@ -1228,19 +1218,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(); @@ -1286,8 +1268,7 @@ void RE_Shutdown( qboolean destroyWindow ) { if ( tr.registered ) { - R_SyncRenderThread(); - R_ShutdownCommandBuffers(); + R_IssuePendingRenderCommands(); R_DeleteTextures(); } @@ -1310,7 +1291,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/code/renderer/tr_light.c b/code/renderer/tr_light.c index 89153854..fc6af6a9 100644 --- a/code/renderer/tr_light.c +++ b/code/renderer/tr_light.c @@ -95,11 +95,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/code/renderer/tr_local.h b/code/renderer/tr_local.h index bd666a54..ce14c4a4 100644 --- a/code/renderer/tr_local.h +++ b/code/renderer/tr_local.h @@ -34,11 +34,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 @@ -573,7 +568,7 @@ typedef struct srfGridMesh_s { surfaceType_t surfaceType; // dynamic lighting information - int dlightBits[SMP_FRAMES]; + int dlightBits; // culling information vec3_t meshBounds[2]; @@ -603,7 +598,7 @@ typedef struct { cplane_t plane; // dynamic lighting information - int dlightBits[SMP_FRAMES]; + int dlightBits; // triangle definitions (no normals at points) int numPoints; @@ -619,7 +614,7 @@ typedef struct { surfaceType_t surfaceType; // dynamic lighting information - int dlightBits[SMP_FRAMES]; + int dlightBits; // culling information (FIXME: use this!) vec3_t bounds[2]; @@ -891,7 +886,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; @@ -923,8 +917,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; @@ -1122,8 +1114,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; @@ -1300,11 +1290,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); @@ -1480,7 +1465,7 @@ SCENE GENERATION ============================================================ */ -void R_ToggleSmpFrame( void ); +void R_InitNextFrame( void ); void RE_ClearScene( void ); void RE_AddRefEntityToScene( const refEntity_t *ent ); @@ -1584,7 +1569,6 @@ RENDERER BACK END FUNCTIONS ============================================================= */ -void RB_RenderThread( void ); void RB_ExecuteRenderCommands( const void *data ); /* @@ -1698,9 +1682,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]; @@ -1713,20 +1695,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/code/renderer/tr_main.c b/code/renderer/tr_main.c index 3cf8727e..233bbd2e 100644 --- a/code/renderer/tr_main.c +++ b/code/renderer/tr_main.c @@ -862,10 +862,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 ); @@ -1352,8 +1348,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/code/renderer/tr_model.c b/code/renderer/tr_model.c index 51e0427f..a6f79265 100644 --- a/code/renderer/tr_model.c +++ b/code/renderer/tr_model.c @@ -306,8 +306,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; @@ -1045,7 +1044,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/code/renderer/tr_scene.c b/code/renderer/tr_scene.c index 807cc48d..5d7a3dd1 100644 --- a/code/renderer/tr_scene.c +++ b/code/renderer/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; @@ -143,11 +135,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 ) ); @@ -224,8 +216,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++; } @@ -253,7 +245,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; @@ -355,16 +347,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/code/renderer/tr_shader.c b/code/renderer/tr_shader.c index 72fb5487..8fcd1122 100644 --- a/code/renderer/tr_shader.c +++ b/code/renderer/tr_shader.c @@ -1872,7 +1872,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; @@ -2473,12 +2473,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 ) ); @@ -2609,12 +2603,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/code/renderer/tr_surface.c b/code/renderer/tr_surface.c index 75592150..99b0d805 100644 --- a/code/renderer/tr_surface.c +++ b/code/renderer/tr_surface.c @@ -231,7 +231,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 ); @@ -915,7 +915,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 ); @@ -1007,7 +1007,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/code/renderer/tr_types.h b/code/renderer/tr_types.h index a83e6a41..70596434 100644 --- a/code/renderer/tr_types.h +++ b/code/renderer/tr_types.h @@ -212,7 +212,7 @@ typedef struct { // used CDS. qboolean isFullscreen; qboolean stereoEnabled; - qboolean smpActive; // dual processor + qboolean smpActive; // UNUSED, present for compatibility } glconfig_t; #endif // __TR_TYPES_H diff --git a/code/renderer/tr_world.c b/code/renderer/tr_world.c index 376bf122..de0ed339 100644 --- a/code/renderer/tr_world.c +++ b/code/renderer/tr_world.c @@ -180,7 +180,7 @@ static int R_DlightFace( srfSurfaceFace_t *face, int dlightBits ) { tr.pc.c_dlightSurfacesCulled++; } - face->dlightBits[ tr.smpFrame ] = dlightBits; + face->dlightBits = dlightBits; return dlightBits; } @@ -208,14 +208,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; @@ -241,7 +241,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/code/sdl/sdl_glimp.c b/code/sdl/sdl_glimp.c index a751c692..c5d6f8ee 100644 --- a/code/sdl/sdl_glimp.c +++ b/code/sdl/sdl_glimp.c @@ -26,14 +26,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # include #endif -#ifdef SMP -# ifdef USE_LOCAL_HEADERS -# include "SDL_thread.h" -# else -# include -# endif -#endif - #include #include #include @@ -827,245 +819,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 From 15aad331a45744f8bf3320e4679ecebc779b71d4 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Fri, 25 Jan 2013 19:52:44 +0000 Subject: [PATCH 17/18] Update README --- README | 1 - 1 file changed, 1 deletion(-) diff --git a/README b/README index f0fad313..16b3cbb4 100644 --- a/README +++ b/README @@ -82,7 +82,6 @@ Makefile.local: DEFAULT_BASEDIR - extra path to search for baseq3 and such BUILD_SERVER - build the 'ioq3ded' server binary BUILD_CLIENT - build the 'ioquake3' client binary - BUILD_CLIENT_SMP - build the 'ioquake3-smp' client binary BUILD_BASEGAME - build the 'baseq3' binaries BUILD_MISSIONPACK - build the 'missionpack' binaries BUILD_GAME_SO - build the game shared libraries From 517c65d85e89d1d4765fcef7c7ea89388ff09538 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sat, 26 Jan 2013 21:40:45 +0000 Subject: [PATCH 18/18] Fix some SMP bits I missed --- Makefile | 3 ++- make-macosx-ub.sh | 6 ------ make-macosx.sh | 2 -- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 9ff5d917..e062ca9a 100644 --- a/Makefile +++ b/Makefile @@ -1509,7 +1509,8 @@ Q3R2OBJ = \ $(B)/rend2/tr_vbo.o \ $(B)/rend2/tr_world.o \ \ - $(B)/renderer/sdl_gamma.o + $(B)/renderer/sdl_gamma.o \ + $(B)/renderer/sdl_glimp.o Q3R2STRINGOBJ = \ $(B)/rend2/glsl/bokeh_fp.o \ diff --git a/make-macosx-ub.sh b/make-macosx-ub.sh index 5d2ee069..eca258c0 100755 --- a/make-macosx-ub.sh +++ b/make-macosx-ub.sh @@ -42,15 +42,9 @@ MPACK_OBJ=" build/release-darwin-ppc/$MPACKDIR/qagameppc.dylib " RENDER_OBJ=" - build/release-darwin-x86_64/renderer_opengl1_smp_x86_64.dylib - build/release-darwin-i386/renderer_opengl1_smp_i386.dylib - build/release-darwin-ppc/renderer_opengl1_smp_ppc.dylib build/release-darwin-x86_64/renderer_opengl1_x86_64.dylib build/release-darwin-i386/renderer_opengl1_i386.dylib build/release-darwin-ppc/renderer_opengl1_ppc.dylib - build/release-darwin-x86_64/renderer_rend2_smp_x86_64.dylib - build/release-darwin-i386/renderer_rend2_smp_i386.dylib - build/release-darwin-ppc/renderer_rend2_smp_ppc.dylib build/release-darwin-x86_64/renderer_rend2_x86_64.dylib build/release-darwin-i386/renderer_rend2_i386.dylib build/release-darwin-ppc/renderer_rend2_ppc.dylib diff --git a/make-macosx.sh b/make-macosx.sh index f8995535..fbba6ca4 100755 --- a/make-macosx.sh +++ b/make-macosx.sh @@ -51,9 +51,7 @@ MPACK_OBJ=" build/release-darwin-${BUILDARCH}/$MPACKDIR/qagame${BUILDARCH}.dylib " RENDER_OBJ=" - build/release-darwin-${BUILDARCH}/renderer_opengl1_smp_${BUILDARCH}.dylib build/release-darwin-${BUILDARCH}/renderer_opengl1_${BUILDARCH}.dylib - build/release-darwin-${BUILDARCH}/renderer_rend2_smp_${BUILDARCH}.dylib build/release-darwin-${BUILDARCH}/renderer_rend2_${BUILDARCH}.dylib "