- more timer cleanup

* store the frame time in the current screen buffer from where all render code can access it.
* replace some uses of I_MSTime with I_FPSTime, because they should not use a per-frame timer. The only one left is the wipe code but even this doesn't look like it needs either a per-frame timer or a timer counting from the start of the playsim.
This commit is contained in:
Christoph Oelckers 2017-11-13 00:28:43 +01:00
parent e94109f1c3
commit 2c65f08011
24 changed files with 31 additions and 38 deletions

View file

@ -744,8 +744,8 @@ bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds)
dclick = false;
// This used level.time which didn't work outside a level.
nowtime = I_MSTime();
if (doublebinds != NULL && DClickTime[ev->data1] > nowtime && ev->type == EV_KeyDown)
nowtime = I_FPSTime();
if (doublebinds != NULL && int(DClickTime[ev->data1] - nowtime) > 0 && ev->type == EV_KeyDown)
{
// Key pressed for a double click
binding = doublebinds->GetBinding(ev->data1);

View file

@ -779,9 +779,9 @@ void D_Display ()
{
unsigned int nowtime = I_FPSTime();
TexMan.UpdateAnimations(nowtime);
R_UpdateSky(nowtime);
screen->FrameTime = I_FPSTime();
TexMan.UpdateAnimations(screen->FrameTime);
R_UpdateSky(screen->FrameTime);
switch (gamestate)
{
case GS_FULLCONSOLE:
@ -808,7 +808,7 @@ void D_Display ()
// [ZZ] execute event hook that we just started the frame
//E_RenderFrame();
//
Renderer->RenderView(&players[consoleplayer], nowtime);
Renderer->RenderView(&players[consoleplayer]);
if ((hw2d = screen->Begin2D(viewactive)))
{

View file

@ -783,7 +783,7 @@ void GetPackets (void)
// [RH] Get "ping" times - totally useless, since it's bound to the frequency
// packets go out at.
lastrecvtime[netconsole] = currrecvtime[netconsole];
currrecvtime[netconsole] = I_MSTime ();
currrecvtime[netconsole] = I_FPSTime ();
// check for exiting the game
if (netbuffer[0] & NCMD_EXIT)

View file

@ -55,7 +55,6 @@
#include "gl/gl_functions.h"
GLRenderSettings glset;
long gl_frameMS;
EXTERN_CVAR(Int, gl_lightmode)
EXTERN_CVAR(Bool, gl_brightfog)

View file

@ -65,6 +65,4 @@ void gl_InitPortals();
void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, const DVector2 &displacement);
void gl_InitData();
extern long gl_frameMS;
#endif

View file

@ -55,7 +55,7 @@
static inline float GetTimeFloat()
{
return (float)gl_frameMS * (float)TICRATE / 1000.0f;
return (float)screen->FrameTime * (float)TICRATE / 1000.0f;
}
CVAR(Bool, gl_interpolate_model_frames, true, CVAR_ARCHIVE)

View file

@ -171,7 +171,7 @@ public:
unsigned char *GetTextureBuffer(FTexture *tex, int &w, int &h);
void SetupLevel();
void RenderView(player_t* player, unsigned int nowtime);
void RenderView(player_t* player);
void RenderScreenQuad();
void PostProcessScene(int fixedcm);

View file

@ -161,7 +161,7 @@ bool FRenderState::ApplyShader()
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
activeShader->muClipHeight.Set(mClipHeight);
activeShader->muClipHeightDirection.Set(mClipHeightDirection);
activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f);
activeShader->muTimer.Set(screen->FrameTime * mShaderTimer / 1000.f);
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now
activeShader->muClipSplit.Set(mClipSplit);

View file

@ -785,7 +785,7 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
GLRenderer->mSceneClearColor[0] = 0.0f;
GLRenderer->mSceneClearColor[1] = 0.0f;
GLRenderer->mSceneClearColor[2] = 0.0f;
R_SetupFrame (r_viewpoint, r_viewwindow, camera, gl_frameMS);
R_SetupFrame (r_viewpoint, r_viewwindow, camera);
SetViewArea();
GLRenderer->mGlobVis = R_GetGlobVis(r_viewwindow, r_visibility);
@ -800,8 +800,8 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
GLRenderer->mAngles.Roll.Degrees = r_viewpoint.Angles.Roll.Degrees;
// Scroll the sky
GLRenderer->mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f;
GLRenderer->mSky2Pos = (float)fmod(gl_frameMS * level.skyspeed2, 1024.f) * 90.f/256.f;
GLRenderer->mSky1Pos = (float)fmod(screen->FrameTime * level.skyspeed1, 1024.f) * 90.f/256.f;
GLRenderer->mSky2Pos = (float)fmod(screen->FrameTime * level.skyspeed2, 1024.f) * 90.f/256.f;
@ -878,7 +878,7 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
//
//-----------------------------------------------------------------------------
void FGLRenderer::RenderView (player_t* player, unsigned int nowtime)
void FGLRenderer::RenderView (player_t* player)
{
checkBenchActive();
@ -891,7 +891,6 @@ void FGLRenderer::RenderView (player_t* player, unsigned int nowtime)
// Get this before everything else
if (cl_capfps || r_NoInterpolate) r_viewpoint.TicFrac = 1.;
else r_viewpoint.TicFrac = I_GetTimeFrac (&r_viewpoint.FrameTime);
gl_frameMS = nowtime;
P_FindParticleSubsectors ();
@ -984,7 +983,7 @@ void GLSceneDrawer::WriteSavePic (player_t *player, FileWriter *file, int width,
struct FGLInterface : public FRenderer
{
void Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitlist) override;
void RenderView(player_t *player, unsigned int nowtime) override;
void RenderView(player_t *player) override;
void WriteSavePic (player_t *player, FileWriter *file, int width, int height) override;
void StartSerialize(FSerializer &arc) override;
void EndSerialize(FSerializer &arc) override;
@ -1075,9 +1074,9 @@ void FGLInterface::WriteSavePic (player_t *player, FileWriter *file, int width,
//
//===========================================================================
void FGLInterface::RenderView(player_t *player, unsigned int nowtime)
void FGLInterface::RenderView(player_t *player)
{
GLRenderer->RenderView(player, nowtime);
GLRenderer->RenderView(player);
}
//===========================================================================

View file

@ -60,7 +60,7 @@ public:
void CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);
sector_t *RenderViewpoint(AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
void RenderView(player_t *player, unsigned int nowtime);
void RenderView(player_t *player);
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
void DrawPSprite(player_t * player, DPSprite *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture);

View file

@ -12,7 +12,6 @@ class FHardwareTexture;
class FSimpleVertexBuffer;
class FGLDebug;
extern long gl_frameMS;
#ifdef _WIN32
class OpenGLFrameBuffer : public Win32GLFrameBuffer
{

View file

@ -115,7 +115,7 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
DontMapLines = dontmaplines;
R_SetupFrame(Viewpoint, Viewwindow, actor, swrenderer::renderTime);
R_SetupFrame(Viewpoint, Viewwindow, actor);
P_FindParticleSubsectors();
PO_LinkToSubsectors();

View file

@ -200,7 +200,7 @@ struct TimedUpdater
{
explicit TimedUpdater(const Function& function)
{
const unsigned int currentTime = I_MSTime();
const unsigned int currentTime = I_FPSTime();
if (currentTime - m_previousTime > interval)
{

View file

@ -29,7 +29,7 @@ struct FRenderer
virtual void Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitlist) = 0;
// render 3D view
virtual void RenderView(player_t *player, unsigned int nowtime) = 0;
virtual void RenderView(player_t *player) = 0;
// Remap voxel palette
virtual void RemapVoxels() {}

View file

@ -751,7 +751,7 @@ static double QuakePower(double factor, double intensity, double offset)
//
//==========================================================================
void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor *actor, unsigned int renderTime)
void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor *actor)
{
if (actor == NULL)
{
@ -982,7 +982,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
if (hom == 3)
{
hom = ((renderTime / 128) & 1) + 1;
hom = ((screen->FrameTime / 128) & 1) + 1;
}
if (hom == 1)
{
@ -994,7 +994,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
}
else if (hom == 4)
{
color = (renderTime / 32) & 255;
color = (screen->FrameTime / 32) & 255;
}
else
{

View file

@ -111,7 +111,7 @@ void R_ClearInterpolationPath();
void R_AddInterpolationPoint(const DVector3a &vec);
void R_SetViewSize (int blocks);
void R_SetFOV (FRenderViewpoint &viewpoint, DAngle fov);
void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor * camera, unsigned int renderTime);
void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor * camera);
void R_SetViewAngle (FRenderViewpoint &viewpoint, const FViewWindow &viewwindow);
// Called by startup code.

View file

@ -64,7 +64,6 @@ namespace swrenderer
int fuzzoffset[FUZZTABLE + 1];
int fuzzpos;
int fuzzviewheight;
unsigned int renderTime;
int fuzz_random_x_offset[FUZZ_RANDOM_X_SIZE] =
{

View file

@ -35,7 +35,6 @@ namespace swrenderer
extern FDynamicColormap ShadeFakeColormap[16];
extern uint8_t identitymap[256];
extern FDynamicColormap identitycolormap;
extern unsigned int renderTime;
// Constant arrays used for psprite clipping and initializing clipping.
extern short zeroarray[MAXWIDTH];

View file

@ -170,9 +170,8 @@ void FSoftwareRenderer::Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &
}
}
void FSoftwareRenderer::RenderView(player_t *player, unsigned int nowtime)
void FSoftwareRenderer::RenderView(player_t *player)
{
renderTime = nowtime;
if (r_polyrenderer)
{
PolyRenderer::Instance()->Viewpoint = r_viewpoint;

View file

@ -13,7 +13,7 @@ struct FSoftwareRenderer : public FRenderer
void Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitlist) override;
// render 3D view
void RenderView(player_t *player, unsigned int nowtime) override;
void RenderView(player_t *player) override;
// Remap voxel palette
void RemapVoxels() override;

View file

@ -136,7 +136,7 @@ namespace swrenderer
MaskedCycles.Reset();
DrawerWaitCycles.Reset();
R_SetupFrame(MainThread()->Viewport->viewpoint, MainThread()->Viewport->viewwindow, actor, renderTime);
R_SetupFrame(MainThread()->Viewport->viewpoint, MainThread()->Viewport->viewwindow, actor);
if (APART(R_OldBlend)) NormalLight.Maps = realcolormaps.Maps;
else NormalLight.Maps = realcolormaps.Maps + NUMCOLORMAPS * 256 * R_OldBlend;

View file

@ -135,7 +135,7 @@ namespace swrenderer
int voxelspin = (thing->flags & MF_DROPPED) ? voxel->DroppedSpin : voxel->PlacedSpin;
if (voxelspin != 0)
{
DAngle ang = double(renderTime) * voxelspin / 1000;
DAngle ang = double(screen->FrameTime) * voxelspin / 1000;
vis->Angle -= ang;
}

View file

@ -870,7 +870,7 @@ void DFrameBuffer::DrawRateStuff ()
// Draws frame time and cumulative fps
if (vid_fps)
{
uint32_t ms = I_FPSTime();
uint32_t ms = screen->FrameTime;
uint32_t howlong = ms - LastMS;
if ((signed)howlong >= 0)
{

View file

@ -453,6 +453,7 @@ public:
// The original size of the framebuffer as selected in the video menu.
int VideoWidth = 0;
int VideoHeight = 0;
uint32_t FrameTime = 0;
protected:
void DrawRateStuff ();