mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-03-17 00:11:05 +00:00
Merge remote-tracking branch 'gzdoom/newtimercode4'
This commit is contained in:
commit
cccd19485a
21 changed files with 60 additions and 48 deletions
|
@ -941,7 +941,7 @@ void D_Display ()
|
|||
else
|
||||
{
|
||||
// wipe update
|
||||
unsigned int wipestart, nowtime, diff;
|
||||
uint64_t wipestart, nowtime, diff;
|
||||
bool done;
|
||||
|
||||
GSnd->SetSfxPaused(true, 1);
|
||||
|
|
|
@ -113,9 +113,9 @@ bool remoteresend[MAXNETNODES]; // set when local needs tics
|
|||
int resendto[MAXNETNODES]; // set when remote needs tics
|
||||
int resendcount[MAXNETNODES];
|
||||
|
||||
unsigned int lastrecvtime[MAXPLAYERS]; // [RH] Used for pings
|
||||
unsigned int currrecvtime[MAXPLAYERS];
|
||||
unsigned int lastglobalrecvtime; // Identify the last time a packet was received.
|
||||
uint64_t lastrecvtime[MAXPLAYERS]; // [RH] Used for pings
|
||||
uint64_t currrecvtime[MAXPLAYERS];
|
||||
uint64_t lastglobalrecvtime; // Identify the last time a packet was received.
|
||||
bool hadlate;
|
||||
int netdelay[MAXNETNODES][BACKUPTICS]; // Used for storing network delay times.
|
||||
int lastaverage;
|
||||
|
|
|
@ -615,7 +615,7 @@ void DObject::CheckIfSerialized () const
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DObject, MSTime)
|
||||
{
|
||||
ACTION_RETURN_INT(I_msTime());
|
||||
ACTION_RETURN_INT((uint32_t)I_msTime());
|
||||
}
|
||||
|
||||
void *DObject::ScriptVar(FName field, PType *type)
|
||||
|
|
|
@ -362,7 +362,7 @@ struct level_info_t
|
|||
int outsidefogdensity;
|
||||
int skyfog;
|
||||
float pixelstretch;
|
||||
|
||||
|
||||
// Redirection: If any player is carrying the specified item, then
|
||||
// you go to the RedirectMap instead of this one.
|
||||
FName RedirectType;
|
||||
|
|
|
@ -67,6 +67,8 @@ struct FLevelLocals
|
|||
FString F1Pic;
|
||||
EMapType maptype;
|
||||
|
||||
uint64_t ShaderStartTime = 0; // tell the shader system when we started the level (forces a timer restart)
|
||||
|
||||
TArray<vertex_t> vertexes;
|
||||
TArray<sector_t> sectors;
|
||||
TArray<line_t*> linebuffer; // contains the line lists for the sectors.
|
||||
|
|
|
@ -53,9 +53,9 @@
|
|||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/shaders/gl_shader.h"
|
||||
|
||||
static inline float GetTimeFloat()
|
||||
static inline double GetTimeFloat()
|
||||
{
|
||||
return (float)screen->FrameTime * (float)TICRATE / 1000.0f;
|
||||
return (double)screen->FrameTime * (double)TICRATE / 1000.;
|
||||
}
|
||||
|
||||
CVAR(Bool, gl_interpolate_model_frames, true, CVAR_ARCHIVE)
|
||||
|
@ -890,7 +890,7 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf,
|
|||
// [BB] In case the tic counter is frozen we have to leave ticFraction at zero.
|
||||
if ( ConsoleState == c_up && menuactive != MENU_On && !(level.flags2 & LEVEL2_FROZEN) )
|
||||
{
|
||||
float time = GetTimeFloat();
|
||||
double time = GetTimeFloat();
|
||||
ticFraction = (time - static_cast<int>(time));
|
||||
}
|
||||
inter = static_cast<double>(curState->Tics - curTics - ticFraction)/static_cast<double>(curState->Tics);
|
||||
|
@ -999,8 +999,8 @@ void gl_RenderModel(GLSprite * spr)
|
|||
|
||||
if( smf->flags & MDL_ROTATING )
|
||||
{
|
||||
const float time = smf->rotationSpeed*GetTimeFloat()/200.f;
|
||||
rotateOffset = float((time - xs_FloorToInt(time)) *360.f );
|
||||
const double time = smf->rotationSpeed*GetTimeFloat()/200.;
|
||||
rotateOffset = double((time - xs_FloorToInt(time)) *360. );
|
||||
}
|
||||
|
||||
// Added MDL_USEACTORPITCH and MDL_USEACTORROLL flags processing.
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "gl/renderer/gl_colormap.h"
|
||||
#include "gl/dynlights//gl_lightbuffer.h"
|
||||
#include "gl/renderer/gl_renderbuffers.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
void gl_SetTextureMode(int type);
|
||||
|
||||
|
@ -118,6 +119,12 @@ void FRenderState::Reset()
|
|||
|
||||
bool FRenderState::ApplyShader()
|
||||
{
|
||||
static uint64_t firstFrame = 0;
|
||||
// if firstFrame is not yet initialized, initialize it to current time
|
||||
// if we're going to overflow a float (after ~4.6 hours, or 24 bits), re-init to regain precision
|
||||
if ((firstFrame == 0) || (screen->FrameTime - firstFrame >= 1<<24) || level.ShaderStartTime >= firstFrame)
|
||||
firstFrame = screen->FrameTime;
|
||||
|
||||
static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f };
|
||||
if (mSpecialEffect > EFF_NONE)
|
||||
{
|
||||
|
@ -161,7 +168,7 @@ bool FRenderState::ApplyShader()
|
|||
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
|
||||
activeShader->muClipHeight.Set(mClipHeight);
|
||||
activeShader->muClipHeightDirection.Set(mClipHeightDirection);
|
||||
activeShader->muTimer.Set(screen->FrameTime * mShaderTimer / 1000.f);
|
||||
activeShader->muTimer.Set((double)(screen->FrameTime - firstFrame) * mShaderTimer / 1000.f);
|
||||
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
|
||||
activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now
|
||||
activeShader->muClipSplit.Set(mClipSplit);
|
||||
|
|
|
@ -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(screen->FrameTime * level.skyspeed1, 1024.f) * 90.f/256.f;
|
||||
GLRenderer->mSky2Pos = (float)fmod(screen->FrameTime * level.skyspeed2, 1024.f) * 90.f/256.f;
|
||||
GLRenderer->mSky1Pos = (double)fmod(screen->FrameTime * level.skyspeed1, 1024.f) * 90./256.;
|
||||
GLRenderer->mSky2Pos = (double)fmod(screen->FrameTime * level.skyspeed2, 1024.f) * 90./256.;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -187,8 +187,8 @@ static void AppendLightStats(FString &out)
|
|||
ADD_STAT(rendertimes)
|
||||
{
|
||||
static FString buff;
|
||||
static int lasttime=0;
|
||||
int t=I_msTime();
|
||||
static int64_t lasttime=0;
|
||||
int64_t t=I_msTime();
|
||||
if (t-lasttime>1000)
|
||||
{
|
||||
buff.Truncate(0);
|
||||
|
@ -217,7 +217,7 @@ void AppendMissingTextureStats(FString &out);
|
|||
|
||||
static int printstats;
|
||||
static bool switchfps;
|
||||
static unsigned int waitstart;
|
||||
static uint64_t waitstart;
|
||||
EXTERN_CVAR(Bool, vid_fps)
|
||||
|
||||
void CheckBench()
|
||||
|
|
|
@ -60,9 +60,9 @@ static uint64_t MSToNS(unsigned int ms)
|
|||
return static_cast<uint64_t>(ms) * 1'000'000;
|
||||
}
|
||||
|
||||
static uint32_t NSToMS(uint64_t ns)
|
||||
static uint64_t NSToMS(uint64_t ns)
|
||||
{
|
||||
return static_cast<uint32_t>(ns / 1'000'000);
|
||||
return static_cast<uint64_t>(ns / 1'000'000);
|
||||
}
|
||||
|
||||
static int NSToTic(uint64_t ns)
|
||||
|
@ -125,7 +125,7 @@ uint64_t I_nsTime()
|
|||
return GetClockTimeNS();
|
||||
}
|
||||
|
||||
unsigned int I_msTime()
|
||||
uint64_t I_msTime()
|
||||
{
|
||||
return NSToMS(I_nsTime());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ int I_WaitForTic(int);
|
|||
void I_FreezeTime(bool frozen);
|
||||
|
||||
// [RH] Returns millisecond-accurate time
|
||||
unsigned int I_msTime();
|
||||
uint64_t I_msTime();
|
||||
|
||||
// Nanosecond-accurate time
|
||||
uint64_t I_nsTime();
|
||||
|
|
|
@ -955,7 +955,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
|||
if (!loaded)
|
||||
{
|
||||
// none found - we have to build new ones!
|
||||
unsigned int startTime, endTime;
|
||||
uint64_t startTime, endTime;
|
||||
|
||||
startTime = I_msTime ();
|
||||
TArray<FNodeBuilder::FPolyStart> polyspots, anchors;
|
||||
|
@ -973,7 +973,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
|||
builder.Extract (level);
|
||||
endTime = I_msTime ();
|
||||
DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%u segs)\n", (endTime - startTime) * 0.001, level.segs.Size());
|
||||
buildtime = endTime - startTime;
|
||||
buildtime = (int32_t)(endTime - startTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3627,6 +3627,8 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
bool buildmap;
|
||||
const int *oldvertextable = NULL;
|
||||
|
||||
level.ShaderStartTime = I_msTime(); // indicate to the shader system that the level just started
|
||||
|
||||
// This is motivated as follows:
|
||||
|
||||
bool RequireGLNodes = Renderer->RequireGLNodes() || am_textured;
|
||||
|
@ -3931,7 +3933,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
}
|
||||
else reloop = true;
|
||||
|
||||
unsigned int startTime=0, endTime=0;
|
||||
uint64_t startTime=0, endTime=0;
|
||||
|
||||
bool BuildGLNodes;
|
||||
if (ForceNodeBuild)
|
||||
|
@ -3988,7 +3990,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
// If the original nodes being loaded are not GL nodes they will be kept around for
|
||||
// use in P_PointInSubsector to avoid problems with maps that depend on the specific
|
||||
// nodes they were built with (P:AR E1M3 is a good example for a map where this is the case.)
|
||||
reloop |= P_CheckNodes(map, BuildGLNodes, endTime - startTime);
|
||||
reloop |= P_CheckNodes(map, BuildGLNodes, (uint32_t)(endTime - startTime));
|
||||
hasglnodes = true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -165,7 +165,7 @@ void R_InitSkyMap ()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void R_UpdateSky (uint32_t mstime)
|
||||
void R_UpdateSky (uint64_t mstime)
|
||||
{
|
||||
// Scroll the sky
|
||||
double ms = (double)mstime * FRACUNIT;
|
||||
|
|
|
@ -44,6 +44,6 @@ extern int freelookviewheight;
|
|||
|
||||
// Called whenever the sky changes.
|
||||
void R_InitSkyMap ();
|
||||
void R_UpdateSky (uint32_t mstime);
|
||||
void R_UpdateSky (uint64_t mstime);
|
||||
|
||||
#endif //__R_SKY_H__
|
||||
|
|
|
@ -876,7 +876,7 @@ FDoorAnimation *FTextureManager::FindAnimatedDoor (FTextureID picnum)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FAnimDef::SetSwitchTime (uint32_t mstime)
|
||||
void FAnimDef::SetSwitchTime (uint64_t mstime)
|
||||
{
|
||||
int speedframe = bDiscrete ? CurFrame : 0;
|
||||
|
||||
|
@ -917,7 +917,7 @@ void FTextureManager::SetTranslation (FTextureID fromtexnum, FTextureID totexnum
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FTextureManager::UpdateAnimations (uint32_t mstime)
|
||||
void FTextureManager::UpdateAnimations (uint64_t mstime)
|
||||
{
|
||||
for (unsigned int j = 0; j < mAnimations.Size(); ++j)
|
||||
{
|
||||
|
|
|
@ -90,7 +90,7 @@ struct FAnimDef
|
|||
uint16_t CurFrame;
|
||||
uint8_t AnimType;
|
||||
bool bDiscrete; // taken out of AnimType to have better control
|
||||
uint32_t SwitchTime; // Time to advance to next frame
|
||||
uint64_t SwitchTime; // Time to advance to next frame
|
||||
struct FAnimFrame
|
||||
{
|
||||
uint32_t SpeedMin; // Speeds are in ms, not tics
|
||||
|
@ -106,7 +106,7 @@ struct FAnimDef
|
|||
ANIM_Random
|
||||
};
|
||||
|
||||
void SetSwitchTime (uint32_t mstime);
|
||||
void SetSwitchTime (uint64_t mstime);
|
||||
};
|
||||
|
||||
struct FSwitchDef
|
||||
|
@ -505,7 +505,7 @@ public:
|
|||
|
||||
int NumTextures () const { return (int)Textures.Size(); }
|
||||
|
||||
void UpdateAnimations (uint32_t mstime);
|
||||
void UpdateAnimations (uint64_t mstime);
|
||||
int GuesstimateNumTextures ();
|
||||
|
||||
FSwitchDef *FindSwitch (FTextureID texture);
|
||||
|
@ -604,8 +604,8 @@ public:
|
|||
void SetSpeed(float fac) { Speed = fac; }
|
||||
FTexture *GetRedirect(bool wantwarped);
|
||||
|
||||
uint32_t GenTime;
|
||||
uint32_t GenTimeBgra;
|
||||
uint64_t GenTime;
|
||||
uint64_t GenTimeBgra;
|
||||
float Speed;
|
||||
int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd]
|
||||
protected:
|
||||
|
@ -613,7 +613,7 @@ protected:
|
|||
uint8_t *Pixels;
|
||||
Span **Spans;
|
||||
|
||||
virtual void MakeTexture (uint32_t time);
|
||||
virtual void MakeTexture (uint64_t time);
|
||||
int NextPo2 (int v); // [mxd]
|
||||
void SetupMultipliers (int width, int height); // [mxd]
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "textures/textures.h"
|
||||
|
||||
template<class TYPE>
|
||||
void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, unsigned time, float Speed, int warptype)
|
||||
void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, uint64_t time, float Speed, int warptype)
|
||||
{
|
||||
int ymask = height - 1;
|
||||
int x, y;
|
||||
|
|
|
@ -86,7 +86,7 @@ bool FWarpTexture::CheckModified ()
|
|||
|
||||
const uint8_t *FWarpTexture::GetPixels ()
|
||||
{
|
||||
uint32_t time = screen->FrameTime;
|
||||
uint64_t time = screen->FrameTime;
|
||||
|
||||
if (Pixels == NULL || time != GenTime)
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ const uint8_t *FWarpTexture::GetPixels ()
|
|||
|
||||
const uint32_t *FWarpTexture::GetPixelsBgra()
|
||||
{
|
||||
uint32_t time = screen->FrameTime;
|
||||
uint64_t time = screen->FrameTime;
|
||||
if (Pixels == NULL || time != GenTime)
|
||||
MakeTexture(time);
|
||||
|
||||
|
@ -119,7 +119,7 @@ const uint32_t *FWarpTexture::GetPixelsBgra()
|
|||
|
||||
const uint8_t *FWarpTexture::GetColumn (unsigned int column, const Span **spans_out)
|
||||
{
|
||||
uint32_t time =screen->FrameTime;
|
||||
uint64_t time =screen->FrameTime;
|
||||
|
||||
if (Pixels == NULL || time != GenTime)
|
||||
{
|
||||
|
@ -148,7 +148,7 @@ const uint8_t *FWarpTexture::GetColumn (unsigned int column, const Span **spans_
|
|||
}
|
||||
|
||||
|
||||
void FWarpTexture::MakeTexture(uint32_t time)
|
||||
void FWarpTexture::MakeTexture(uint64_t time)
|
||||
{
|
||||
const uint8_t *otherpix = SourcePic->GetPixels();
|
||||
|
||||
|
|
|
@ -870,8 +870,8 @@ void DFrameBuffer::DrawRateStuff ()
|
|||
// Draws frame time and cumulative fps
|
||||
if (vid_fps)
|
||||
{
|
||||
uint32_t ms = screen->FrameTime;
|
||||
uint32_t howlong = ms - LastMS;
|
||||
uint64_t ms = screen->FrameTime;
|
||||
uint64_t howlong = ms - LastMS;
|
||||
if ((signed)howlong >= 0)
|
||||
{
|
||||
char fpsbuff[40];
|
||||
|
@ -888,7 +888,7 @@ void DFrameBuffer::DrawRateStuff ()
|
|||
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
||||
DTA_KeepRatio, true, TAG_DONE);
|
||||
|
||||
uint32_t thisSec = ms/1000;
|
||||
uint32_t thisSec = (uint32_t)(ms/1000);
|
||||
if (LastSec < thisSec)
|
||||
{
|
||||
LastCount = FrameCount / (thisSec - LastSec);
|
||||
|
@ -903,8 +903,8 @@ void DFrameBuffer::DrawRateStuff ()
|
|||
// draws little dots on the bottom of the screen
|
||||
if (ticker)
|
||||
{
|
||||
int i = I_GetTime();
|
||||
int tics = i - LastTic;
|
||||
int64_t i = I_GetTime();
|
||||
int64_t tics = i - LastTic;
|
||||
uint8_t *buffer = GetBuffer();
|
||||
|
||||
LastTic = i;
|
||||
|
@ -931,6 +931,7 @@ void DFrameBuffer::DrawRateStuff ()
|
|||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < tics*2; i += 2) Clear(i, Height-1, i+1, Height, 255, 0);
|
||||
for ( ; i < 20*2; i += 2) Clear(i, Height-1, i+1, Height, 0, 0);
|
||||
}
|
||||
|
|
|
@ -442,7 +442,7 @@ public:
|
|||
|
||||
virtual void ScaleCoordsFromWindow(int16_t &x, int16_t &y) {}
|
||||
|
||||
uint32_t GetLastFPS() const { return LastCount; }
|
||||
uint64_t GetLastFPS() const { return LastCount; }
|
||||
|
||||
#ifdef _WIN32
|
||||
virtual void PaletteChanged () = 0;
|
||||
|
@ -453,7 +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;
|
||||
uint64_t FrameTime = 0;
|
||||
|
||||
protected:
|
||||
void DrawRateStuff ();
|
||||
|
@ -463,7 +463,7 @@ protected:
|
|||
DFrameBuffer () {}
|
||||
|
||||
private:
|
||||
uint32_t LastMS, LastSec, FrameCount, LastCount, LastTic;
|
||||
uint64_t LastMS, LastSec, FrameCount, LastCount, LastTic;
|
||||
bool isIn2D = false;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue