mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- 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:
parent
e94109f1c3
commit
2c65f08011
24 changed files with 31 additions and 38 deletions
|
@ -744,8 +744,8 @@ bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds)
|
||||||
dclick = false;
|
dclick = false;
|
||||||
|
|
||||||
// This used level.time which didn't work outside a level.
|
// This used level.time which didn't work outside a level.
|
||||||
nowtime = I_MSTime();
|
nowtime = I_FPSTime();
|
||||||
if (doublebinds != NULL && DClickTime[ev->data1] > nowtime && ev->type == EV_KeyDown)
|
if (doublebinds != NULL && int(DClickTime[ev->data1] - nowtime) > 0 && ev->type == EV_KeyDown)
|
||||||
{
|
{
|
||||||
// Key pressed for a double click
|
// Key pressed for a double click
|
||||||
binding = doublebinds->GetBinding(ev->data1);
|
binding = doublebinds->GetBinding(ev->data1);
|
||||||
|
|
|
@ -779,9 +779,9 @@ void D_Display ()
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned int nowtime = I_FPSTime();
|
screen->FrameTime = I_FPSTime();
|
||||||
TexMan.UpdateAnimations(nowtime);
|
TexMan.UpdateAnimations(screen->FrameTime);
|
||||||
R_UpdateSky(nowtime);
|
R_UpdateSky(screen->FrameTime);
|
||||||
switch (gamestate)
|
switch (gamestate)
|
||||||
{
|
{
|
||||||
case GS_FULLCONSOLE:
|
case GS_FULLCONSOLE:
|
||||||
|
@ -808,7 +808,7 @@ void D_Display ()
|
||||||
// [ZZ] execute event hook that we just started the frame
|
// [ZZ] execute event hook that we just started the frame
|
||||||
//E_RenderFrame();
|
//E_RenderFrame();
|
||||||
//
|
//
|
||||||
Renderer->RenderView(&players[consoleplayer], nowtime);
|
Renderer->RenderView(&players[consoleplayer]);
|
||||||
|
|
||||||
if ((hw2d = screen->Begin2D(viewactive)))
|
if ((hw2d = screen->Begin2D(viewactive)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -783,7 +783,7 @@ void GetPackets (void)
|
||||||
// [RH] Get "ping" times - totally useless, since it's bound to the frequency
|
// [RH] Get "ping" times - totally useless, since it's bound to the frequency
|
||||||
// packets go out at.
|
// packets go out at.
|
||||||
lastrecvtime[netconsole] = currrecvtime[netconsole];
|
lastrecvtime[netconsole] = currrecvtime[netconsole];
|
||||||
currrecvtime[netconsole] = I_MSTime ();
|
currrecvtime[netconsole] = I_FPSTime ();
|
||||||
|
|
||||||
// check for exiting the game
|
// check for exiting the game
|
||||||
if (netbuffer[0] & NCMD_EXIT)
|
if (netbuffer[0] & NCMD_EXIT)
|
||||||
|
|
|
@ -55,7 +55,6 @@
|
||||||
#include "gl/gl_functions.h"
|
#include "gl/gl_functions.h"
|
||||||
|
|
||||||
GLRenderSettings glset;
|
GLRenderSettings glset;
|
||||||
long gl_frameMS;
|
|
||||||
|
|
||||||
EXTERN_CVAR(Int, gl_lightmode)
|
EXTERN_CVAR(Int, gl_lightmode)
|
||||||
EXTERN_CVAR(Bool, gl_brightfog)
|
EXTERN_CVAR(Bool, gl_brightfog)
|
||||||
|
|
|
@ -65,6 +65,4 @@ void gl_InitPortals();
|
||||||
void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, const DVector2 &displacement);
|
void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, const DVector2 &displacement);
|
||||||
void gl_InitData();
|
void gl_InitData();
|
||||||
|
|
||||||
extern long gl_frameMS;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
|
|
||||||
static inline float GetTimeFloat()
|
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)
|
CVAR(Bool, gl_interpolate_model_frames, true, CVAR_ARCHIVE)
|
||||||
|
|
|
@ -171,7 +171,7 @@ public:
|
||||||
unsigned char *GetTextureBuffer(FTexture *tex, int &w, int &h);
|
unsigned char *GetTextureBuffer(FTexture *tex, int &w, int &h);
|
||||||
void SetupLevel();
|
void SetupLevel();
|
||||||
|
|
||||||
void RenderView(player_t* player, unsigned int nowtime);
|
void RenderView(player_t* player);
|
||||||
|
|
||||||
void RenderScreenQuad();
|
void RenderScreenQuad();
|
||||||
void PostProcessScene(int fixedcm);
|
void PostProcessScene(int fixedcm);
|
||||||
|
|
|
@ -161,7 +161,7 @@ bool FRenderState::ApplyShader()
|
||||||
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
|
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
|
||||||
activeShader->muClipHeight.Set(mClipHeight);
|
activeShader->muClipHeight.Set(mClipHeight);
|
||||||
activeShader->muClipHeightDirection.Set(mClipHeightDirection);
|
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->muAlphaThreshold.Set(mAlphaThreshold);
|
||||||
activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now
|
activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now
|
||||||
activeShader->muClipSplit.Set(mClipSplit);
|
activeShader->muClipSplit.Set(mClipSplit);
|
||||||
|
|
|
@ -785,7 +785,7 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
|
||||||
GLRenderer->mSceneClearColor[0] = 0.0f;
|
GLRenderer->mSceneClearColor[0] = 0.0f;
|
||||||
GLRenderer->mSceneClearColor[1] = 0.0f;
|
GLRenderer->mSceneClearColor[1] = 0.0f;
|
||||||
GLRenderer->mSceneClearColor[2] = 0.0f;
|
GLRenderer->mSceneClearColor[2] = 0.0f;
|
||||||
R_SetupFrame (r_viewpoint, r_viewwindow, camera, gl_frameMS);
|
R_SetupFrame (r_viewpoint, r_viewwindow, camera);
|
||||||
SetViewArea();
|
SetViewArea();
|
||||||
|
|
||||||
GLRenderer->mGlobVis = R_GetGlobVis(r_viewwindow, r_visibility);
|
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;
|
GLRenderer->mAngles.Roll.Degrees = r_viewpoint.Angles.Roll.Degrees;
|
||||||
|
|
||||||
// Scroll the sky
|
// Scroll the sky
|
||||||
GLRenderer->mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f;
|
GLRenderer->mSky1Pos = (float)fmod(screen->FrameTime * level.skyspeed1, 1024.f) * 90.f/256.f;
|
||||||
GLRenderer->mSky2Pos = (float)fmod(gl_frameMS * level.skyspeed2, 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();
|
checkBenchActive();
|
||||||
|
|
||||||
|
@ -891,7 +891,6 @@ void FGLRenderer::RenderView (player_t* player, unsigned int nowtime)
|
||||||
// Get this before everything else
|
// Get this before everything else
|
||||||
if (cl_capfps || r_NoInterpolate) r_viewpoint.TicFrac = 1.;
|
if (cl_capfps || r_NoInterpolate) r_viewpoint.TicFrac = 1.;
|
||||||
else r_viewpoint.TicFrac = I_GetTimeFrac (&r_viewpoint.FrameTime);
|
else r_viewpoint.TicFrac = I_GetTimeFrac (&r_viewpoint.FrameTime);
|
||||||
gl_frameMS = nowtime;
|
|
||||||
|
|
||||||
P_FindParticleSubsectors ();
|
P_FindParticleSubsectors ();
|
||||||
|
|
||||||
|
@ -984,7 +983,7 @@ void GLSceneDrawer::WriteSavePic (player_t *player, FileWriter *file, int width,
|
||||||
struct FGLInterface : public FRenderer
|
struct FGLInterface : public FRenderer
|
||||||
{
|
{
|
||||||
void Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitlist) override;
|
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 WriteSavePic (player_t *player, FileWriter *file, int width, int height) override;
|
||||||
void StartSerialize(FSerializer &arc) override;
|
void StartSerialize(FSerializer &arc) override;
|
||||||
void EndSerialize(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
void CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);
|
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);
|
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 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);
|
void DrawPSprite(player_t * player, DPSprite *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture);
|
||||||
|
|
|
@ -12,7 +12,6 @@ class FHardwareTexture;
|
||||||
class FSimpleVertexBuffer;
|
class FSimpleVertexBuffer;
|
||||||
class FGLDebug;
|
class FGLDebug;
|
||||||
|
|
||||||
extern long gl_frameMS;
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
class OpenGLFrameBuffer : public Win32GLFrameBuffer
|
class OpenGLFrameBuffer : public Win32GLFrameBuffer
|
||||||
{
|
{
|
||||||
|
|
|
@ -115,7 +115,7 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
||||||
|
|
||||||
DontMapLines = dontmaplines;
|
DontMapLines = dontmaplines;
|
||||||
|
|
||||||
R_SetupFrame(Viewpoint, Viewwindow, actor, swrenderer::renderTime);
|
R_SetupFrame(Viewpoint, Viewwindow, actor);
|
||||||
P_FindParticleSubsectors();
|
P_FindParticleSubsectors();
|
||||||
PO_LinkToSubsectors();
|
PO_LinkToSubsectors();
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ struct TimedUpdater
|
||||||
{
|
{
|
||||||
explicit TimedUpdater(const Function& function)
|
explicit TimedUpdater(const Function& function)
|
||||||
{
|
{
|
||||||
const unsigned int currentTime = I_MSTime();
|
const unsigned int currentTime = I_FPSTime();
|
||||||
|
|
||||||
if (currentTime - m_previousTime > interval)
|
if (currentTime - m_previousTime > interval)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct FRenderer
|
||||||
virtual void Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitlist) = 0;
|
virtual void Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitlist) = 0;
|
||||||
|
|
||||||
// render 3D view
|
// render 3D view
|
||||||
virtual void RenderView(player_t *player, unsigned int nowtime) = 0;
|
virtual void RenderView(player_t *player) = 0;
|
||||||
|
|
||||||
// Remap voxel palette
|
// Remap voxel palette
|
||||||
virtual void RemapVoxels() {}
|
virtual void RemapVoxels() {}
|
||||||
|
|
|
@ -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)
|
if (actor == NULL)
|
||||||
{
|
{
|
||||||
|
@ -982,7 +982,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
||||||
|
|
||||||
if (hom == 3)
|
if (hom == 3)
|
||||||
{
|
{
|
||||||
hom = ((renderTime / 128) & 1) + 1;
|
hom = ((screen->FrameTime / 128) & 1) + 1;
|
||||||
}
|
}
|
||||||
if (hom == 1)
|
if (hom == 1)
|
||||||
{
|
{
|
||||||
|
@ -994,7 +994,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
||||||
}
|
}
|
||||||
else if (hom == 4)
|
else if (hom == 4)
|
||||||
{
|
{
|
||||||
color = (renderTime / 32) & 255;
|
color = (screen->FrameTime / 32) & 255;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,7 +111,7 @@ void R_ClearInterpolationPath();
|
||||||
void R_AddInterpolationPoint(const DVector3a &vec);
|
void R_AddInterpolationPoint(const DVector3a &vec);
|
||||||
void R_SetViewSize (int blocks);
|
void R_SetViewSize (int blocks);
|
||||||
void R_SetFOV (FRenderViewpoint &viewpoint, DAngle fov);
|
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);
|
void R_SetViewAngle (FRenderViewpoint &viewpoint, const FViewWindow &viewwindow);
|
||||||
|
|
||||||
// Called by startup code.
|
// Called by startup code.
|
||||||
|
|
|
@ -64,7 +64,6 @@ namespace swrenderer
|
||||||
int fuzzoffset[FUZZTABLE + 1];
|
int fuzzoffset[FUZZTABLE + 1];
|
||||||
int fuzzpos;
|
int fuzzpos;
|
||||||
int fuzzviewheight;
|
int fuzzviewheight;
|
||||||
unsigned int renderTime;
|
|
||||||
|
|
||||||
int fuzz_random_x_offset[FUZZ_RANDOM_X_SIZE] =
|
int fuzz_random_x_offset[FUZZ_RANDOM_X_SIZE] =
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,6 @@ namespace swrenderer
|
||||||
extern FDynamicColormap ShadeFakeColormap[16];
|
extern FDynamicColormap ShadeFakeColormap[16];
|
||||||
extern uint8_t identitymap[256];
|
extern uint8_t identitymap[256];
|
||||||
extern FDynamicColormap identitycolormap;
|
extern FDynamicColormap identitycolormap;
|
||||||
extern unsigned int renderTime;
|
|
||||||
|
|
||||||
// Constant arrays used for psprite clipping and initializing clipping.
|
// Constant arrays used for psprite clipping and initializing clipping.
|
||||||
extern short zeroarray[MAXWIDTH];
|
extern short zeroarray[MAXWIDTH];
|
||||||
|
|
|
@ -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)
|
if (r_polyrenderer)
|
||||||
{
|
{
|
||||||
PolyRenderer::Instance()->Viewpoint = r_viewpoint;
|
PolyRenderer::Instance()->Viewpoint = r_viewpoint;
|
||||||
|
|
|
@ -13,7 +13,7 @@ struct FSoftwareRenderer : public FRenderer
|
||||||
void Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitlist) override;
|
void Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitlist) override;
|
||||||
|
|
||||||
// render 3D view
|
// render 3D view
|
||||||
void RenderView(player_t *player, unsigned int nowtime) override;
|
void RenderView(player_t *player) override;
|
||||||
|
|
||||||
// Remap voxel palette
|
// Remap voxel palette
|
||||||
void RemapVoxels() override;
|
void RemapVoxels() override;
|
||||||
|
|
|
@ -136,7 +136,7 @@ namespace swrenderer
|
||||||
MaskedCycles.Reset();
|
MaskedCycles.Reset();
|
||||||
DrawerWaitCycles.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;
|
if (APART(R_OldBlend)) NormalLight.Maps = realcolormaps.Maps;
|
||||||
else NormalLight.Maps = realcolormaps.Maps + NUMCOLORMAPS * 256 * R_OldBlend;
|
else NormalLight.Maps = realcolormaps.Maps + NUMCOLORMAPS * 256 * R_OldBlend;
|
||||||
|
|
|
@ -135,7 +135,7 @@ namespace swrenderer
|
||||||
int voxelspin = (thing->flags & MF_DROPPED) ? voxel->DroppedSpin : voxel->PlacedSpin;
|
int voxelspin = (thing->flags & MF_DROPPED) ? voxel->DroppedSpin : voxel->PlacedSpin;
|
||||||
if (voxelspin != 0)
|
if (voxelspin != 0)
|
||||||
{
|
{
|
||||||
DAngle ang = double(renderTime) * voxelspin / 1000;
|
DAngle ang = double(screen->FrameTime) * voxelspin / 1000;
|
||||||
vis->Angle -= ang;
|
vis->Angle -= ang;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -870,7 +870,7 @@ void DFrameBuffer::DrawRateStuff ()
|
||||||
// Draws frame time and cumulative fps
|
// Draws frame time and cumulative fps
|
||||||
if (vid_fps)
|
if (vid_fps)
|
||||||
{
|
{
|
||||||
uint32_t ms = I_FPSTime();
|
uint32_t ms = screen->FrameTime;
|
||||||
uint32_t howlong = ms - LastMS;
|
uint32_t howlong = ms - LastMS;
|
||||||
if ((signed)howlong >= 0)
|
if ((signed)howlong >= 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -453,6 +453,7 @@ public:
|
||||||
// The original size of the framebuffer as selected in the video menu.
|
// The original size of the framebuffer as selected in the video menu.
|
||||||
int VideoWidth = 0;
|
int VideoWidth = 0;
|
||||||
int VideoHeight = 0;
|
int VideoHeight = 0;
|
||||||
|
uint32_t FrameTime = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DrawRateStuff ();
|
void DrawRateStuff ();
|
||||||
|
|
Loading…
Reference in a new issue