diff --git a/src/c_bind.cpp b/src/c_bind.cpp index cbc65868f..b1a557514 100644 --- a/src/c_bind.cpp +++ b/src/c_bind.cpp @@ -744,7 +744,7 @@ 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_FPSTime(); + nowtime = I_msTime(); if (doublebinds != NULL && int(DClickTime[ev->data1] - nowtime) > 0 && ev->type == EV_KeyDown) { // Key pressed for a double click diff --git a/src/d_main.cpp b/src/d_main.cpp index 6afa74c33..540b002b3 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -779,7 +779,7 @@ void D_Display () { - screen->FrameTime = I_FPSTime(); + screen->FrameTime = I_msTime(); TexMan.UpdateAnimations(screen->FrameTime); R_UpdateSky(screen->FrameTime); switch (gamestate) @@ -945,7 +945,7 @@ void D_Display () I_FreezeTime(true); screen->WipeEndScreen (); - wipestart = I_FPSTime(); + wipestart = I_msTime(); NetUpdate(); // send out any new accumulation do @@ -953,7 +953,7 @@ void D_Display () do { I_WaitVBL(2); - nowtime = I_FPSTime(); + nowtime = I_msTime(); diff = (nowtime - wipestart) * 40 / 1000; // Using 35 here feels too slow. } while (diff < 1); wipestart = nowtime; diff --git a/src/d_net.cpp b/src/d_net.cpp index 95765e84c..ba1262025 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -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_FPSTime (); + currrecvtime[netconsole] = I_msTime (); // check for exiting the game if (netbuffer[0] & NCMD_EXIT) diff --git a/src/dobject.cpp b/src/dobject.cpp index 299486de9..9046d7337 100644 --- a/src/dobject.cpp +++ b/src/dobject.cpp @@ -615,7 +615,7 @@ void DObject::CheckIfSerialized () const DEFINE_ACTION_FUNCTION(DObject, MSTime) { - ACTION_RETURN_INT(I_FPSTime()); + ACTION_RETURN_INT(I_msTime()); } void *DObject::ScriptVar(FName field, PType *type) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index c1351001d..92d378521 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -890,7 +890,7 @@ void FGLRenderer::RenderView (player_t* player) // Get this before everything else if (cl_capfps || r_NoInterpolate) r_viewpoint.TicFrac = 1.; - else r_viewpoint.TicFrac = I_GetTimeFrac (&r_viewpoint.FrameTime); + else r_viewpoint.TicFrac = I_GetTimeFrac (); P_FindParticleSubsectors (); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index f45a702b9..53d22f857 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -320,10 +320,10 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla // need to do software warping FWarpTexture *wt = static_cast(tex); unsigned char *warpbuffer = new unsigned char[w*h*4]; - WarpBuffer((uint32_t*)warpbuffer, (const uint32_t*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, r_viewpoint.FrameTime, wt->Speed, tex->bWarped); + WarpBuffer((uint32_t*)warpbuffer, (const uint32_t*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, screen->FrameTime, wt->Speed, tex->bWarped); delete[] buffer; buffer = warpbuffer; - wt->GenTime = r_viewpoint.FrameTime; + wt->GenTime = screen->FrameTime; } tex->ProcessData(buffer, w, h, false); } diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index a67df0234..8ad3b1cc8 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -188,7 +188,7 @@ ADD_STAT(rendertimes) { static FString buff; static int lasttime=0; - int t=I_FPSTime(); + int t=I_msTime(); if (t-lasttime>1000) { buff.Truncate(0); @@ -226,7 +226,7 @@ void CheckBench() { // if we started the FPS counter ourselves or ran from the console // we need to wait for it to stabilize before using it. - if (waitstart > 0 && I_FPSTime() - waitstart < 5000) return; + if (waitstart > 0 && I_msTime() - waitstart < 5000) return; FString compose; @@ -257,12 +257,12 @@ CCMD(bench) if (vid_fps == 0) { vid_fps = 1; - waitstart = I_FPSTime(); + waitstart = I_msTime(); switchfps = true; } else { - if (ConsoleState == c_up) waitstart = I_FPSTime(); + if (ConsoleState == c_up) waitstart = I_msTime(); switchfps = false; } C_HideConsole (); diff --git a/src/i_time.cpp b/src/i_time.cpp index a8e30747a..050bb1ebc 100644 --- a/src/i_time.cpp +++ b/src/i_time.cpp @@ -120,14 +120,14 @@ int I_WaitForTic(int prevtic) return time; } -uint64_t I_FPSTimeNS() +uint64_t I_nsTime() { return GetClockTimeNS(); } -unsigned int I_FPSTime() +unsigned int I_msTime() { - return NSToMS(I_FPSTimeNS()); + return NSToMS(I_nsTime()); } int I_GetTime() @@ -135,15 +135,12 @@ int I_GetTime() return NSToTic(CurrentFrameStartTime - FirstFrameStartTime) + 1; } -double I_GetTimeFrac(uint32_t *ms) +double I_GetTimeFrac() { int currentTic = NSToTic(CurrentFrameStartTime - FirstFrameStartTime); uint64_t ticStartTime = FirstFrameStartTime + TicToNS(currentTic); uint64_t ticNextTime = FirstFrameStartTime + TicToNS(currentTic + 1); - if (ms) - *ms = currentTic + 1; - return (CurrentFrameStartTime - ticStartTime) / (double)(ticNextTime - ticStartTime); } diff --git a/src/i_time.h b/src/i_time.h index 95f07a490..160596969 100644 --- a/src/i_time.h +++ b/src/i_time.h @@ -8,7 +8,7 @@ void I_SetFrameTime(); // Called by D_DoomLoop, returns current time in tics. int I_GetTime(); -double I_GetTimeFrac(uint32_t *ms); +double I_GetTimeFrac(); // like I_GetTime, except it waits for a new tic before returning int I_WaitForTic(int); @@ -20,7 +20,7 @@ int I_WaitForTic(int); void I_FreezeTime(bool frozen); // [RH] Returns millisecond-accurate time -unsigned int I_FPSTime(); +unsigned int I_msTime(); // Nanosecond-accurate time -uint64_t I_FPSTimeNS(); +uint64_t I_nsTime(); diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 3559887fa..bac573565 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -957,7 +957,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime) // none found - we have to build new ones! unsigned int startTime, endTime; - startTime = I_FPSTime (); + startTime = I_msTime (); TArray polyspots, anchors; P_GetPolySpots (map, polyspots, anchors); FNodeBuilder::FLevel leveldata = @@ -971,7 +971,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime) FNodeBuilder builder (leveldata, polyspots, anchors, true); builder.Extract (level); - endTime = I_FPSTime (); + endTime = I_msTime (); DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%u segs)\n", (endTime - startTime) * 0.001, level.segs.Size()); buildtime = endTime - startTime; } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index fb2f1cdb7..02522d3df 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3938,7 +3938,7 @@ void P_SetupLevel (const char *lumpname, int position) { BuildGLNodes = RequireGLNodes || multiplayer || demoplayback || demorecording || genglnodes; - startTime = I_FPSTime (); + startTime = I_msTime (); TArray polyspots, anchors; P_GetPolySpots (map, polyspots, anchors); FNodeBuilder::FLevel leveldata = @@ -3954,7 +3954,7 @@ void P_SetupLevel (const char *lumpname, int position) // if the different machines' am_textured setting differs. FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes); builder.Extract (level); - endTime = I_FPSTime (); + endTime = I_msTime (); DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, level.segs.Size()); oldvertextable = builder.GetOldVertexTable(); reloop = true; diff --git a/src/posix/cocoa/st_console.mm b/src/posix/cocoa/st_console.mm index bf08c27eb..dd876c378 100644 --- a/src/posix/cocoa/st_console.mm +++ b/src/posix/cocoa/st_console.mm @@ -200,7 +200,7 @@ struct TimedUpdater { explicit TimedUpdater(const Function& function) { - const unsigned int currentTime = I_FPSTime(); + const unsigned int currentTime = I_msTime(); if (currentTime - m_previousTime > interval) { diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 77e747007..fc3e963c7 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -831,7 +831,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor iview->otic = nowtic; } - viewpoint.TicFrac = I_GetTimeFrac (&viewpoint.FrameTime); + viewpoint.TicFrac = I_GetTimeFrac (); if (cl_capfps || r_NoInterpolate) { viewpoint.TicFrac = 1.; diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index 1de8624fe..43a215a2b 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -40,6 +40,7 @@ #include "textures/textures.h" #include "warpbuffer.h" #include "v_palette.h" +#include "v_video.h" FWarpTexture::FWarpTexture (FTexture *source, int warptype) @@ -80,12 +81,12 @@ void FWarpTexture::Unload () bool FWarpTexture::CheckModified () { - return r_viewpoint.FrameTime != GenTime; + return screen->FrameTime != GenTime; } const uint8_t *FWarpTexture::GetPixels () { - uint32_t time = r_viewpoint.FrameTime; + uint32_t time = screen->FrameTime; if (Pixels == NULL || time != GenTime) { @@ -96,7 +97,7 @@ const uint8_t *FWarpTexture::GetPixels () const uint32_t *FWarpTexture::GetPixelsBgra() { - uint32_t time = r_viewpoint.FrameTime; + uint32_t time = screen->FrameTime; if (Pixels == NULL || time != GenTime) MakeTexture(time); @@ -118,7 +119,7 @@ const uint32_t *FWarpTexture::GetPixelsBgra() const uint8_t *FWarpTexture::GetColumn (unsigned int column, const Span **spans_out) { - uint32_t time = r_viewpoint.FrameTime; + uint32_t time =screen->FrameTime; if (Pixels == NULL || time != GenTime) {