mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2025-02-01 13:20:50 +00:00
faster map loads by limiting the rendering back-end's frame-rate
This commit is contained in:
parent
51cda86421
commit
a26b150c59
6 changed files with 39 additions and 0 deletions
|
@ -16,6 +16,8 @@ add: /toggle can now accept a value sequence (2 or more entries) to loop through
|
|||
if the cvar's current value is in the sequence and not in the last spot, the next one is used
|
||||
otherwise, the first value in the sequence is used
|
||||
|
||||
chg: faster map loads by limiting the rendering back-end's frame-rate
|
||||
|
||||
chg: on Windows, the upper limit of open stdio file handles was raised from 512 to 2048
|
||||
|
||||
fix: the last byte of a maximum length bitstream string wasn't parsed ("q3msgboom")
|
||||
|
|
|
@ -687,7 +687,9 @@ void CL_InitCGame()
|
|||
// init for this gamestate
|
||||
// use the lastExecutedServerCommand instead of the serverCommandSequence
|
||||
// otherwise server commands sent just before a gamestate are dropped
|
||||
re.SetMaxFPS( 10 );
|
||||
VM_Call( cgvm, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum );
|
||||
re.SetMaxFPS( 0 );
|
||||
|
||||
// send a usercmd this frame, which will cause the server to send us the first snapshot
|
||||
cls.state = CA_PRIMED;
|
||||
|
|
|
@ -247,6 +247,12 @@ void RE_EndFrame( int* pcFE, int* pc2D, int* pc3D, qbool render )
|
|||
if (!tr.registered)
|
||||
return;
|
||||
|
||||
if (tr.maxFPS > 0) {
|
||||
if (Sys_Milliseconds() < tr.nextFrameTimeMS)
|
||||
return;
|
||||
tr.nextFrameTimeMS += 1000 / tr.maxFPS;
|
||||
}
|
||||
|
||||
qbool delayScreenshot = qfalse;
|
||||
if ( !render && r_delayedScreenshotPending )
|
||||
render = qtrue;
|
||||
|
|
|
@ -741,6 +741,23 @@ static int RE_GetCameraMatrixTime()
|
|||
}
|
||||
|
||||
|
||||
static void RE_SetMaxFPS( int maxFPS )
|
||||
{
|
||||
if (maxFPS > 0 && tr.maxFPS == 0) {
|
||||
tr.maxFPS = maxFPS;
|
||||
tr.nextFrameTimeMS = Sys_Milliseconds() + 1000 / maxFPS;
|
||||
tr.oldSwapInterval = r_swapInterval->integer;
|
||||
ri.Cvar_Set(r_swapInterval->name, "0");
|
||||
} else if (maxFPS == 0 && tr.maxFPS > 0) {
|
||||
tr.maxFPS = 0;
|
||||
ri.Cvar_Set(r_swapInterval->name, va("%i", tr.oldSwapInterval));
|
||||
} else if (maxFPS > 0 && tr.maxFPS > 0) {
|
||||
tr.maxFPS = maxFPS;
|
||||
tr.nextFrameTimeMS = Sys_Milliseconds() + 1000 / maxFPS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const refexport_t* GetRefAPI( const refimport_t* rimp )
|
||||
{
|
||||
static refexport_t re;
|
||||
|
@ -790,5 +807,7 @@ const refexport_t* GetRefAPI( const refimport_t* rimp )
|
|||
|
||||
re.GetCameraMatrixTime = RE_GetCameraMatrixTime;
|
||||
|
||||
re.SetMaxFPS = RE_SetMaxFPS;
|
||||
|
||||
return &re;
|
||||
}
|
||||
|
|
|
@ -912,6 +912,11 @@ typedef struct {
|
|||
float sawToothTable[FUNCTABLE_SIZE];
|
||||
float inverseSawToothTable[FUNCTABLE_SIZE];
|
||||
float fogTable[FOG_TABLE_SIZE];
|
||||
|
||||
// back-end frame-rate limiting, useful for scenarios like CGAME_INIT
|
||||
int maxFPS; // only active if > 0
|
||||
int nextFrameTimeMS;
|
||||
int oldSwapInterval;
|
||||
} trGlobals_t;
|
||||
|
||||
extern backEndState_t backEnd;
|
||||
|
|
|
@ -163,6 +163,11 @@ typedef struct {
|
|||
|
||||
// when the final model-view matrix is computed, for cl_drawMouseLag
|
||||
int (*GetCameraMatrixTime)();
|
||||
|
||||
// used for setting low frame-rates temporarily only (e.g. map loads)
|
||||
// maxFPS > 0 -> throttles frame-rate, disables v-sync
|
||||
// maxFPS = 0 -> no throttling , restores v-sync to whatever it was
|
||||
void (*SetMaxFPS)( int maxFPS );
|
||||
} refexport_t;
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue