- rename I_FPSTime function.

- now that the frame buffer stores its render time, the 'ms' return from I_GetTimeFrac is not needed anymore, we may just as well use the globally stored value instead.

The only feature this value was ever used for was texture warping.
This commit is contained in:
Christoph Oelckers 2017-11-13 00:54:32 +01:00
parent 96e9eadd97
commit 0323f54384
14 changed files with 31 additions and 33 deletions

View file

@ -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

View file

@ -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;

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_FPSTime ();
currrecvtime[netconsole] = I_msTime ();
// check for exiting the game
if (netbuffer[0] & NCMD_EXIT)

View file

@ -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)

View file

@ -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 ();

View file

@ -320,10 +320,10 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
// need to do software warping
FWarpTexture *wt = static_cast<FWarpTexture*>(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);
}

View file

@ -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 ();

View file

@ -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);
}

View file

@ -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();

View file

@ -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<FNodeBuilder::FPolyStart> 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;
}

View file

@ -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<FNodeBuilder::FPolyStart> 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;

View file

@ -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)
{

View file

@ -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.;

View file

@ -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)
{