mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 23:33:00 +00:00
- 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:
parent
96e9eadd97
commit
0323f54384
14 changed files with 31 additions and 33 deletions
|
@ -744,7 +744,7 @@ 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_FPSTime();
|
nowtime = I_msTime();
|
||||||
if (doublebinds != NULL && int(DClickTime[ev->data1] - nowtime) > 0 && 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
|
||||||
|
|
|
@ -779,7 +779,7 @@ void D_Display ()
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
screen->FrameTime = I_FPSTime();
|
screen->FrameTime = I_msTime();
|
||||||
TexMan.UpdateAnimations(screen->FrameTime);
|
TexMan.UpdateAnimations(screen->FrameTime);
|
||||||
R_UpdateSky(screen->FrameTime);
|
R_UpdateSky(screen->FrameTime);
|
||||||
switch (gamestate)
|
switch (gamestate)
|
||||||
|
@ -945,7 +945,7 @@ void D_Display ()
|
||||||
I_FreezeTime(true);
|
I_FreezeTime(true);
|
||||||
screen->WipeEndScreen ();
|
screen->WipeEndScreen ();
|
||||||
|
|
||||||
wipestart = I_FPSTime();
|
wipestart = I_msTime();
|
||||||
NetUpdate(); // send out any new accumulation
|
NetUpdate(); // send out any new accumulation
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -953,7 +953,7 @@ void D_Display ()
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
I_WaitVBL(2);
|
I_WaitVBL(2);
|
||||||
nowtime = I_FPSTime();
|
nowtime = I_msTime();
|
||||||
diff = (nowtime - wipestart) * 40 / 1000; // Using 35 here feels too slow.
|
diff = (nowtime - wipestart) * 40 / 1000; // Using 35 here feels too slow.
|
||||||
} while (diff < 1);
|
} while (diff < 1);
|
||||||
wipestart = nowtime;
|
wipestart = nowtime;
|
||||||
|
|
|
@ -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_FPSTime ();
|
currrecvtime[netconsole] = I_msTime ();
|
||||||
|
|
||||||
// check for exiting the game
|
// check for exiting the game
|
||||||
if (netbuffer[0] & NCMD_EXIT)
|
if (netbuffer[0] & NCMD_EXIT)
|
||||||
|
|
|
@ -615,7 +615,7 @@ void DObject::CheckIfSerialized () const
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DObject, MSTime)
|
DEFINE_ACTION_FUNCTION(DObject, MSTime)
|
||||||
{
|
{
|
||||||
ACTION_RETURN_INT(I_FPSTime());
|
ACTION_RETURN_INT(I_msTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void *DObject::ScriptVar(FName field, PType *type)
|
void *DObject::ScriptVar(FName field, PType *type)
|
||||||
|
|
|
@ -890,7 +890,7 @@ void FGLRenderer::RenderView (player_t* player)
|
||||||
|
|
||||||
// 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 ();
|
||||||
|
|
||||||
P_FindParticleSubsectors ();
|
P_FindParticleSubsectors ();
|
||||||
|
|
||||||
|
|
|
@ -320,10 +320,10 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
|
||||||
// need to do software warping
|
// need to do software warping
|
||||||
FWarpTexture *wt = static_cast<FWarpTexture*>(tex);
|
FWarpTexture *wt = static_cast<FWarpTexture*>(tex);
|
||||||
unsigned char *warpbuffer = new unsigned char[w*h*4];
|
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;
|
delete[] buffer;
|
||||||
buffer = warpbuffer;
|
buffer = warpbuffer;
|
||||||
wt->GenTime = r_viewpoint.FrameTime;
|
wt->GenTime = screen->FrameTime;
|
||||||
}
|
}
|
||||||
tex->ProcessData(buffer, w, h, false);
|
tex->ProcessData(buffer, w, h, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ ADD_STAT(rendertimes)
|
||||||
{
|
{
|
||||||
static FString buff;
|
static FString buff;
|
||||||
static int lasttime=0;
|
static int lasttime=0;
|
||||||
int t=I_FPSTime();
|
int t=I_msTime();
|
||||||
if (t-lasttime>1000)
|
if (t-lasttime>1000)
|
||||||
{
|
{
|
||||||
buff.Truncate(0);
|
buff.Truncate(0);
|
||||||
|
@ -226,7 +226,7 @@ void CheckBench()
|
||||||
{
|
{
|
||||||
// if we started the FPS counter ourselves or ran from the console
|
// if we started the FPS counter ourselves or ran from the console
|
||||||
// we need to wait for it to stabilize before using it.
|
// 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;
|
FString compose;
|
||||||
|
|
||||||
|
@ -257,12 +257,12 @@ CCMD(bench)
|
||||||
if (vid_fps == 0)
|
if (vid_fps == 0)
|
||||||
{
|
{
|
||||||
vid_fps = 1;
|
vid_fps = 1;
|
||||||
waitstart = I_FPSTime();
|
waitstart = I_msTime();
|
||||||
switchfps = true;
|
switchfps = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ConsoleState == c_up) waitstart = I_FPSTime();
|
if (ConsoleState == c_up) waitstart = I_msTime();
|
||||||
switchfps = false;
|
switchfps = false;
|
||||||
}
|
}
|
||||||
C_HideConsole ();
|
C_HideConsole ();
|
||||||
|
|
|
@ -120,14 +120,14 @@ int I_WaitForTic(int prevtic)
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t I_FPSTimeNS()
|
uint64_t I_nsTime()
|
||||||
{
|
{
|
||||||
return GetClockTimeNS();
|
return GetClockTimeNS();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int I_FPSTime()
|
unsigned int I_msTime()
|
||||||
{
|
{
|
||||||
return NSToMS(I_FPSTimeNS());
|
return NSToMS(I_nsTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
int I_GetTime()
|
int I_GetTime()
|
||||||
|
@ -135,15 +135,12 @@ int I_GetTime()
|
||||||
return NSToTic(CurrentFrameStartTime - FirstFrameStartTime) + 1;
|
return NSToTic(CurrentFrameStartTime - FirstFrameStartTime) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double I_GetTimeFrac(uint32_t *ms)
|
double I_GetTimeFrac()
|
||||||
{
|
{
|
||||||
int currentTic = NSToTic(CurrentFrameStartTime - FirstFrameStartTime);
|
int currentTic = NSToTic(CurrentFrameStartTime - FirstFrameStartTime);
|
||||||
uint64_t ticStartTime = FirstFrameStartTime + TicToNS(currentTic);
|
uint64_t ticStartTime = FirstFrameStartTime + TicToNS(currentTic);
|
||||||
uint64_t ticNextTime = FirstFrameStartTime + TicToNS(currentTic + 1);
|
uint64_t ticNextTime = FirstFrameStartTime + TicToNS(currentTic + 1);
|
||||||
|
|
||||||
if (ms)
|
|
||||||
*ms = currentTic + 1;
|
|
||||||
|
|
||||||
return (CurrentFrameStartTime - ticStartTime) / (double)(ticNextTime - ticStartTime);
|
return (CurrentFrameStartTime - ticStartTime) / (double)(ticNextTime - ticStartTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ void I_SetFrameTime();
|
||||||
// Called by D_DoomLoop, returns current time in tics.
|
// Called by D_DoomLoop, returns current time in tics.
|
||||||
int I_GetTime();
|
int I_GetTime();
|
||||||
|
|
||||||
double I_GetTimeFrac(uint32_t *ms);
|
double I_GetTimeFrac();
|
||||||
|
|
||||||
// like I_GetTime, except it waits for a new tic before returning
|
// like I_GetTime, except it waits for a new tic before returning
|
||||||
int I_WaitForTic(int);
|
int I_WaitForTic(int);
|
||||||
|
@ -20,7 +20,7 @@ int I_WaitForTic(int);
|
||||||
void I_FreezeTime(bool frozen);
|
void I_FreezeTime(bool frozen);
|
||||||
|
|
||||||
// [RH] Returns millisecond-accurate time
|
// [RH] Returns millisecond-accurate time
|
||||||
unsigned int I_FPSTime();
|
unsigned int I_msTime();
|
||||||
|
|
||||||
// Nanosecond-accurate time
|
// Nanosecond-accurate time
|
||||||
uint64_t I_FPSTimeNS();
|
uint64_t I_nsTime();
|
||||||
|
|
|
@ -957,7 +957,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
||||||
// none found - we have to build new ones!
|
// none found - we have to build new ones!
|
||||||
unsigned int startTime, endTime;
|
unsigned int startTime, endTime;
|
||||||
|
|
||||||
startTime = I_FPSTime ();
|
startTime = I_msTime ();
|
||||||
TArray<FNodeBuilder::FPolyStart> polyspots, anchors;
|
TArray<FNodeBuilder::FPolyStart> polyspots, anchors;
|
||||||
P_GetPolySpots (map, polyspots, anchors);
|
P_GetPolySpots (map, polyspots, anchors);
|
||||||
FNodeBuilder::FLevel leveldata =
|
FNodeBuilder::FLevel leveldata =
|
||||||
|
@ -971,7 +971,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
||||||
FNodeBuilder builder (leveldata, polyspots, anchors, true);
|
FNodeBuilder builder (leveldata, polyspots, anchors, true);
|
||||||
|
|
||||||
builder.Extract (level);
|
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());
|
DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%u segs)\n", (endTime - startTime) * 0.001, level.segs.Size());
|
||||||
buildtime = endTime - startTime;
|
buildtime = endTime - startTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3938,7 +3938,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
||||||
{
|
{
|
||||||
BuildGLNodes = RequireGLNodes || multiplayer || demoplayback || demorecording || genglnodes;
|
BuildGLNodes = RequireGLNodes || multiplayer || demoplayback || demorecording || genglnodes;
|
||||||
|
|
||||||
startTime = I_FPSTime ();
|
startTime = I_msTime ();
|
||||||
TArray<FNodeBuilder::FPolyStart> polyspots, anchors;
|
TArray<FNodeBuilder::FPolyStart> polyspots, anchors;
|
||||||
P_GetPolySpots (map, polyspots, anchors);
|
P_GetPolySpots (map, polyspots, anchors);
|
||||||
FNodeBuilder::FLevel leveldata =
|
FNodeBuilder::FLevel leveldata =
|
||||||
|
@ -3954,7 +3954,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
||||||
// if the different machines' am_textured setting differs.
|
// if the different machines' am_textured setting differs.
|
||||||
FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes);
|
FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes);
|
||||||
builder.Extract (level);
|
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());
|
DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, level.segs.Size());
|
||||||
oldvertextable = builder.GetOldVertexTable();
|
oldvertextable = builder.GetOldVertexTable();
|
||||||
reloop = true;
|
reloop = true;
|
||||||
|
|
|
@ -200,7 +200,7 @@ struct TimedUpdater
|
||||||
{
|
{
|
||||||
explicit TimedUpdater(const Function& function)
|
explicit TimedUpdater(const Function& function)
|
||||||
{
|
{
|
||||||
const unsigned int currentTime = I_FPSTime();
|
const unsigned int currentTime = I_msTime();
|
||||||
|
|
||||||
if (currentTime - m_previousTime > interval)
|
if (currentTime - m_previousTime > interval)
|
||||||
{
|
{
|
||||||
|
|
|
@ -831,7 +831,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
||||||
iview->otic = nowtic;
|
iview->otic = nowtic;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewpoint.TicFrac = I_GetTimeFrac (&viewpoint.FrameTime);
|
viewpoint.TicFrac = I_GetTimeFrac ();
|
||||||
if (cl_capfps || r_NoInterpolate)
|
if (cl_capfps || r_NoInterpolate)
|
||||||
{
|
{
|
||||||
viewpoint.TicFrac = 1.;
|
viewpoint.TicFrac = 1.;
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "textures/textures.h"
|
#include "textures/textures.h"
|
||||||
#include "warpbuffer.h"
|
#include "warpbuffer.h"
|
||||||
#include "v_palette.h"
|
#include "v_palette.h"
|
||||||
|
#include "v_video.h"
|
||||||
|
|
||||||
|
|
||||||
FWarpTexture::FWarpTexture (FTexture *source, int warptype)
|
FWarpTexture::FWarpTexture (FTexture *source, int warptype)
|
||||||
|
@ -80,12 +81,12 @@ void FWarpTexture::Unload ()
|
||||||
|
|
||||||
bool FWarpTexture::CheckModified ()
|
bool FWarpTexture::CheckModified ()
|
||||||
{
|
{
|
||||||
return r_viewpoint.FrameTime != GenTime;
|
return screen->FrameTime != GenTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t *FWarpTexture::GetPixels ()
|
const uint8_t *FWarpTexture::GetPixels ()
|
||||||
{
|
{
|
||||||
uint32_t time = r_viewpoint.FrameTime;
|
uint32_t time = screen->FrameTime;
|
||||||
|
|
||||||
if (Pixels == NULL || time != GenTime)
|
if (Pixels == NULL || time != GenTime)
|
||||||
{
|
{
|
||||||
|
@ -96,7 +97,7 @@ const uint8_t *FWarpTexture::GetPixels ()
|
||||||
|
|
||||||
const uint32_t *FWarpTexture::GetPixelsBgra()
|
const uint32_t *FWarpTexture::GetPixelsBgra()
|
||||||
{
|
{
|
||||||
uint32_t time = r_viewpoint.FrameTime;
|
uint32_t time = screen->FrameTime;
|
||||||
if (Pixels == NULL || time != GenTime)
|
if (Pixels == NULL || time != GenTime)
|
||||||
MakeTexture(time);
|
MakeTexture(time);
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ const uint32_t *FWarpTexture::GetPixelsBgra()
|
||||||
|
|
||||||
const uint8_t *FWarpTexture::GetColumn (unsigned int column, const Span **spans_out)
|
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)
|
if (Pixels == NULL || time != GenTime)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue