Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
SRB2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
260
Issues
260
List
Board
Labels
Milestones
Merge Requests
67
Merge Requests
67
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
STJr
SRB2
Commits
2ab71571
Commit
2ab71571
authored
Dec 10, 2020
by
James R.
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'high-resolution-timer-2' into next
parents
d004515d
c0dbc562
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
122 additions
and
209 deletions
+122
-209
d_clisrv.c
src/d_clisrv.c
+2
-2
d_main.c
src/d_main.c
+7
-7
doomtype.h
src/doomtype.h
+4
-0
hw_batching.c
src/hardware/hw_batching.c
+4
-4
hw_main.c
src/hardware/hw_main.c
+19
-19
hw_main.h
src/hardware/hw_main.h
+7
-7
i_system.h
src/i_system.h
+7
-1
lua_hooklib.c
src/lua_hooklib.c
+3
-3
m_anigif.c
src/m_anigif.c
+6
-6
m_perfstats.c
src/m_perfstats.c
+0
-0
m_perfstats.h
src/m_perfstats.h
+7
-7
p_tick.c
src/p_tick.c
+9
-9
r_main.c
src/r_main.c
+20
-20
r_main.h
src/r_main.h
+9
-9
i_system.c
src/sdl/i_system.c
+18
-115
No files found.
src/d_clisrv.c
View file @
2ab71571
...
...
@@ -4847,14 +4847,14 @@ void TryRunTics(tic_t realtics)
{
DEBFILE
(
va
(
"============ Running tic %d (local %d)
\n
"
,
gametic
,
localgametic
));
ps_tictime
=
I_Get
TimeMicros
();
ps_tictime
=
I_Get
PreciseTime
();
G_Ticker
((
gametic
%
NEWTICRATERATIO
)
==
0
);
ExtraDataTicker
();
gametic
++
;
consistancy
[
gametic
%
BACKUPTICS
]
=
Consistancy
();
ps_tictime
=
I_Get
TimeMicros
()
-
ps_tictime
;
ps_tictime
=
I_Get
PreciseTime
()
-
ps_tictime
;
// Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame.
if
(
client
&&
gamestate
==
GS_LEVEL
&&
leveltime
>
3
&&
neededtic
<=
gametic
+
cv_netticbuffer
.
value
)
...
...
src/d_main.c
View file @
2ab71571
...
...
@@ -413,7 +413,7 @@ static void D_Display(void)
if
(
!
automapactive
&&
!
dedicated
&&
cv_renderview
.
value
)
{
ps_rendercalltime
=
I_Get
TimeMicros
();
ps_rendercalltime
=
I_Get
PreciseTime
();
if
(
players
[
displayplayer
].
mo
||
players
[
displayplayer
].
playerstate
==
PST_DEAD
)
{
topleft
=
screens
[
0
]
+
viewwindowy
*
vid
.
width
+
viewwindowx
;
...
...
@@ -460,7 +460,7 @@ static void D_Display(void)
if
(
postimgtype2
)
V_DoPostProcessor
(
1
,
postimgtype2
,
postimgparam2
);
}
ps_rendercalltime
=
I_Get
TimeMicros
()
-
ps_rendercalltime
;
ps_rendercalltime
=
I_Get
PreciseTime
()
-
ps_rendercalltime
;
}
if
(
lastdraw
)
...
...
@@ -474,7 +474,7 @@ static void D_Display(void)
lastdraw
=
false
;
}
ps_uitime
=
I_Get
TimeMicros
();
ps_uitime
=
I_Get
PreciseTime
();
if
(
gamestate
==
GS_LEVEL
)
{
...
...
@@ -487,7 +487,7 @@ static void D_Display(void)
}
else
{
ps_uitime
=
I_Get
TimeMicros
();
ps_uitime
=
I_Get
PreciseTime
();
}
}
...
...
@@ -529,7 +529,7 @@ static void D_Display(void)
CON_Drawer
();
ps_uitime
=
I_Get
TimeMicros
()
-
ps_uitime
;
ps_uitime
=
I_Get
PreciseTime
()
-
ps_uitime
;
//
// wipe update
...
...
@@ -615,9 +615,9 @@ static void D_Display(void)
M_DrawPerfStats
();
}
ps_swaptime
=
I_Get
TimeMicros
();
ps_swaptime
=
I_Get
PreciseTime
();
I_FinishUpdate
();
// page flip or blit buffer
ps_swaptime
=
I_Get
TimeMicros
()
-
ps_swaptime
;
ps_swaptime
=
I_Get
PreciseTime
()
-
ps_swaptime
;
}
}
...
...
src/doomtype.h
View file @
2ab71571
...
...
@@ -379,4 +379,8 @@ Needed for some lua shenanigans.
#define FIELDFROM( type, field, have, want ) \
(void *)((intptr_t)(field) - offsetof (type, have) + offsetof (type, want))
#ifdef HAVE_SDL
typedef
UINT64
precise_t
;
#endif
#endif //__DOOMTYPE__
src/hardware/hw_batching.c
View file @
2ab71571
...
...
@@ -248,12 +248,12 @@ void HWR_RenderBatches(void)
}
// sort polygons
ps_hw_batchsorttime
=
I_Get
TimeMicros
();
ps_hw_batchsorttime
=
I_Get
PreciseTime
();
if
(
cv_glshaders
.
value
&&
gl_shadersavailable
)
qsort
(
polygonIndexArray
,
polygonArraySize
,
sizeof
(
unsigned
int
),
comparePolygons
);
else
qsort
(
polygonIndexArray
,
polygonArraySize
,
sizeof
(
unsigned
int
),
comparePolygonsNoShaders
);
ps_hw_batchsorttime
=
I_Get
TimeMicros
()
-
ps_hw_batchsorttime
;
ps_hw_batchsorttime
=
I_Get
PreciseTime
()
-
ps_hw_batchsorttime
;
// sort order
// 1. shader
// 2. texture
...
...
@@ -261,7 +261,7 @@ void HWR_RenderBatches(void)
// 4. colors + light level
// not sure about what order of the last 2 should be, or if it even matters
ps_hw_batchdrawtime
=
I_Get
TimeMicros
();
ps_hw_batchdrawtime
=
I_Get
PreciseTime
();
currentShader
=
polygonArray
[
polygonIndexArray
[
0
]].
shader
;
currentTexture
=
polygonArray
[
polygonIndexArray
[
0
]].
texture
;
...
...
@@ -446,7 +446,7 @@ void HWR_RenderBatches(void)
polygonArraySize
=
0
;
unsortedVertexArraySize
=
0
;
ps_hw_batchdrawtime
=
I_Get
TimeMicros
()
-
ps_hw_batchdrawtime
;
ps_hw_batchdrawtime
=
I_Get
PreciseTime
()
-
ps_hw_batchdrawtime
;
}
...
...
src/hardware/hw_main.c
View file @
2ab71571
...
...
@@ -147,11 +147,11 @@ static angle_t gl_aimingangle;
static
void
HWR_SetTransformAiming
(
FTransform
*
trans
,
player_t
*
player
,
boolean
skybox
);
// Render stats
in
t
ps_hw_skyboxtime
=
0
;
in
t
ps_hw_nodesorttime
=
0
;
in
t
ps_hw_nodedrawtime
=
0
;
in
t
ps_hw_spritesorttime
=
0
;
in
t
ps_hw_spritedrawtime
=
0
;
precise_
t
ps_hw_skyboxtime
=
0
;
precise_
t
ps_hw_nodesorttime
=
0
;
precise_
t
ps_hw_nodedrawtime
=
0
;
precise_
t
ps_hw_spritesorttime
=
0
;
precise_
t
ps_hw_spritedrawtime
=
0
;
// Render stats for batching
int
ps_hw_numpolys
=
0
;
...
...
@@ -161,8 +161,8 @@ int ps_hw_numshaders = 0;
int
ps_hw_numtextures
=
0
;
int
ps_hw_numpolyflags
=
0
;
int
ps_hw_numcolors
=
0
;
in
t
ps_hw_batchsorttime
=
0
;
in
t
ps_hw_batchdrawtime
=
0
;
precise_
t
ps_hw_batchsorttime
=
0
;
precise_
t
ps_hw_batchdrawtime
=
0
;
boolean
gl_init
=
false
;
boolean
gl_maploaded
=
false
;
...
...
@@ -4654,7 +4654,7 @@ static void HWR_CreateDrawNodes(void)
// that is already lying around. This should all be in some sort of linked list or lists.
sortindex
=
Z_Calloc
(
sizeof
(
size_t
)
*
(
numplanes
+
numpolyplanes
+
numwalls
),
PU_STATIC
,
NULL
);
ps_hw_nodesorttime
=
I_Get
TimeMicros
();
ps_hw_nodesorttime
=
I_Get
PreciseTime
();
for
(
i
=
0
;
i
<
numplanes
;
i
++
,
p
++
)
{
...
...
@@ -4709,9 +4709,9 @@ static void HWR_CreateDrawNodes(void)
}
}
ps_hw_nodesorttime
=
I_Get
TimeMicros
()
-
ps_hw_nodesorttime
;
ps_hw_nodesorttime
=
I_Get
PreciseTime
()
-
ps_hw_nodesorttime
;
ps_hw_nodedrawtime
=
I_Get
TimeMicros
();
ps_hw_nodedrawtime
=
I_Get
PreciseTime
();
// Okay! Let's draw it all! Woo!
HWD
.
pfnSetTransform
(
&
atransform
);
...
...
@@ -4748,7 +4748,7 @@ static void HWR_CreateDrawNodes(void)
}
}
ps_hw_nodedrawtime
=
I_Get
TimeMicros
()
-
ps_hw_nodedrawtime
;
ps_hw_nodedrawtime
=
I_Get
PreciseTime
()
-
ps_hw_nodedrawtime
;
numwalls
=
0
;
numplanes
=
0
;
...
...
@@ -6017,10 +6017,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
if
(
viewnumber
==
0
)
// Only do it if it's the first screen being rendered
HWD
.
pfnClearBuffer
(
true
,
false
,
&
ClearColor
);
// Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs.
ps_hw_skyboxtime
=
I_Get
TimeMicros
();
ps_hw_skyboxtime
=
I_Get
PreciseTime
();
if
(
skybox
&&
drawsky
)
// If there's a skybox and we should be drawing the sky, draw the skybox
HWR_RenderSkyboxView
(
viewnumber
,
player
);
// This is drawn before everything else so it is placed behind
ps_hw_skyboxtime
=
I_Get
TimeMicros
()
-
ps_hw_skyboxtime
;
ps_hw_skyboxtime
=
I_Get
PreciseTime
()
-
ps_hw_skyboxtime
;
{
// do we really need to save player (is it not the same)?
...
...
@@ -6132,7 +6132,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
ps_numbspcalls
=
0
;
ps_numpolyobjects
=
0
;
ps_bsptime
=
I_Get
TimeMicros
();
ps_bsptime
=
I_Get
PreciseTime
();
validcount
++
;
...
...
@@ -6170,7 +6170,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
}
#endif
ps_bsptime
=
I_Get
TimeMicros
()
-
ps_bsptime
;
ps_bsptime
=
I_Get
PreciseTime
()
-
ps_bsptime
;
if
(
cv_glbatching
.
value
)
HWR_RenderBatches
();
...
...
@@ -6186,12 +6186,12 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
// Draw MD2 and sprites
ps_numsprites
=
gl_visspritecount
;
ps_hw_spritesorttime
=
I_Get
TimeMicros
();
ps_hw_spritesorttime
=
I_Get
PreciseTime
();
HWR_SortVisSprites
();
ps_hw_spritesorttime
=
I_Get
TimeMicros
()
-
ps_hw_spritesorttime
;
ps_hw_spritedrawtime
=
I_Get
TimeMicros
();
ps_hw_spritesorttime
=
I_Get
PreciseTime
()
-
ps_hw_spritesorttime
;
ps_hw_spritedrawtime
=
I_Get
PreciseTime
();
HWR_DrawSprites
();
ps_hw_spritedrawtime
=
I_Get
TimeMicros
()
-
ps_hw_spritedrawtime
;
ps_hw_spritedrawtime
=
I_Get
PreciseTime
()
-
ps_hw_spritedrawtime
;
#ifdef NEWCORONAS
//Hurdler: they must be drawn before translucent planes, what about gl fog?
...
...
src/hardware/hw_main.h
View file @
2ab71571
...
...
@@ -116,11 +116,11 @@ extern FTransform atransform;
// Render stats
extern
in
t
ps_hw_skyboxtime
;
extern
in
t
ps_hw_nodesorttime
;
extern
in
t
ps_hw_nodedrawtime
;
extern
in
t
ps_hw_spritesorttime
;
extern
in
t
ps_hw_spritedrawtime
;
extern
precise_
t
ps_hw_skyboxtime
;
extern
precise_
t
ps_hw_nodesorttime
;
extern
precise_
t
ps_hw_nodedrawtime
;
extern
precise_
t
ps_hw_spritesorttime
;
extern
precise_
t
ps_hw_spritedrawtime
;
// Render stats for batching
extern
int
ps_hw_numpolys
;
...
...
@@ -130,8 +130,8 @@ extern int ps_hw_numshaders;
extern
int
ps_hw_numtextures
;
extern
int
ps_hw_numpolyflags
;
extern
int
ps_hw_numcolors
;
extern
in
t
ps_hw_batchsorttime
;
extern
in
t
ps_hw_batchdrawtime
;
extern
precise_
t
ps_hw_batchsorttime
;
extern
precise_
t
ps_hw_batchdrawtime
;
extern
boolean
gl_init
;
extern
boolean
gl_maploaded
;
...
...
src/i_system.h
View file @
2ab71571
...
...
@@ -46,7 +46,13 @@ UINT32 I_GetFreeMem(UINT32 *total);
*/
tic_t
I_GetTime
(
void
);
int
I_GetTimeMicros
(
void
);
// provides microsecond counter for render stats
/** \brief Returns precise time value for performance measurement.
*/
precise_t
I_GetPreciseTime
(
void
);
/** \brief Returns the difference between precise times as microseconds.
*/
int
I_PreciseToMicros
(
precise_t
);
/** \brief The I_Sleep function
...
...
src/lua_hooklib.c
View file @
2ab71571
...
...
@@ -25,7 +25,7 @@
#include "m_perfstats.h"
#include "d_netcmd.h" // for cv_perfstats
#include "i_system.h" // I_Get
TimeMicros
#include "i_system.h" // I_Get
PreciseTime
static
UINT8
hooksAvailable
[(
hook_MAX
/
8
)
+
1
];
...
...
@@ -481,7 +481,7 @@ void LUAh_ThinkFrame(void)
continue
;
if
(
cv_perfstats
.
value
==
3
)
time_taken
=
I_Get
TimeMicros
();
time_taken
=
I_Get
PreciseTime
();
PushHook
(
gL
,
hookp
);
if
(
lua_pcall
(
gL
,
0
,
0
,
1
))
{
if
(
!
hookp
->
error
||
cv_debug
&
DBG_LUA
)
...
...
@@ -492,7 +492,7 @@ void LUAh_ThinkFrame(void)
if
(
cv_perfstats
.
value
==
3
)
{
lua_Debug
ar
;
time_taken
=
I_Get
TimeMicros
()
-
time_taken
;
time_taken
=
I_Get
PreciseTime
()
-
time_taken
;
// we need the function, let's just retrieve it again
PushHook
(
gL
,
hookp
);
lua_getinfo
(
gL
,
">S"
,
&
ar
);
...
...
src/m_anigif.c
View file @
2ab71571
...
...
@@ -18,7 +18,7 @@
#include "z_zone.h"
#include "v_video.h"
#include "i_video.h"
#include "i_system.h" // I_Get
TimeMicros
#include "i_system.h" // I_Get
PreciseTime
#include "m_misc.h"
#include "st_stuff.h" // st_palette
...
...
@@ -53,8 +53,8 @@ static RGBA_t *gif_framepalette = NULL;
static
FILE
*
gif_out
=
NULL
;
static
INT32
gif_frames
=
0
;
static
UINT32
gif_prevframeus
=
0
;
// "us" is microseconds
static
UINT32
gif_delayus
=
0
;
static
precise_t
gif_prevframetime
=
0
;
static
UINT32
gif_delayus
=
0
;
// "us" is microseconds
static
UINT8
gif_writeover
=
0
;
...
...
@@ -608,7 +608,7 @@ static void GIF_framewrite(void)
{
// golden's attempt at creating a "dynamic delay"
UINT16
mingifdelay
=
10
;
// minimum gif delay in milliseconds (keep at 10 because gifs can't get more precise).
gif_delayus
+=
(
I_GetTimeMicros
()
-
gif_prevframeus
);
// increase delay by how much time was spent between last measurement
gif_delayus
+=
I_PreciseToMicros
(
I_GetPreciseTime
()
-
gif_prevframetime
);
// increase delay by how much time was spent between last measurement
if
(
gif_delayus
/
1000
>=
mingifdelay
)
// delay is big enough to be able to effect gif frame delay?
{
...
...
@@ -711,7 +711,7 @@ static void GIF_framewrite(void)
}
fwrite
(
gifframe_data
,
1
,
(
p
-
gifframe_data
),
gif_out
);
++
gif_frames
;
gif_prevframe
us
=
I_GetTimeMicros
();
gif_prevframe
time
=
I_GetPreciseTime
();
}
...
...
@@ -739,7 +739,7 @@ INT32 GIF_open(const char *filename)
GIF_headwrite
();
gif_frames
=
0
;
gif_prevframe
us
=
I_GetTimeMicros
();
gif_prevframe
time
=
I_GetPreciseTime
();
gif_delayus
=
0
;
return
1
;
}
...
...
src/m_perfstats.c
View file @
2ab71571
This diff is collapsed.
Click to expand it.
src/m_perfstats.h
View file @
2ab71571
...
...
@@ -16,17 +16,17 @@
#include "lua_script.h"
#include "p_local.h"
extern
in
t
ps_tictime
;
extern
precise_
t
ps_tictime
;
extern
in
t
ps_playerthink_time
;
extern
in
t
ps_thinkertime
;
extern
precise_
t
ps_playerthink_time
;
extern
precise_
t
ps_thinkertime
;
extern
in
t
ps_thlist_times
[];
extern
precise_
t
ps_thlist_times
[];
extern
int
ps_checkposition_calls
;
extern
int
ps_checkposition_calls
;
extern
in
t
ps_lua_thinkframe_time
;
extern
int
ps_lua_mobjhooks
;
extern
precise_
t
ps_lua_thinkframe_time
;
extern
int
ps_lua_mobjhooks
;
typedef
struct
{
...
...
src/p_tick.c
View file @
2ab71571
...
...
@@ -22,7 +22,7 @@
#include "lua_script.h"
#include "lua_hook.h"
#include "m_perfstats.h"
#include "i_system.h" // I_Get
TimeMicros
#include "i_system.h" // I_Get
PreciseTime
// Object place
#include "m_cheat.h"
...
...
@@ -323,7 +323,7 @@ static inline void P_RunThinkers(void)
size_t
i
;
for
(
i
=
0
;
i
<
NUM_THINKERLISTS
;
i
++
)
{
ps_thlist_times
[
i
]
=
I_Get
TimeMicros
();
ps_thlist_times
[
i
]
=
I_Get
PreciseTime
();
for
(
currentthinker
=
thlist
[
i
].
next
;
currentthinker
!=
&
thlist
[
i
];
currentthinker
=
currentthinker
->
next
)
{
#ifdef PARANOIA
...
...
@@ -331,7 +331,7 @@ static inline void P_RunThinkers(void)
#endif
currentthinker
->
function
.
acp1
(
currentthinker
);
}
ps_thlist_times
[
i
]
=
I_Get
TimeMicros
()
-
ps_thlist_times
[
i
];
ps_thlist_times
[
i
]
=
I_Get
PreciseTime
()
-
ps_thlist_times
[
i
];
}
}
...
...
@@ -658,11 +658,11 @@ void P_Ticker(boolean run)
LUAh_PreThinkFrame
();
ps_playerthink_time
=
I_Get
TimeMicros
();
ps_playerthink_time
=
I_Get
PreciseTime
();
for
(
i
=
0
;
i
<
MAXPLAYERS
;
i
++
)
if
(
playeringame
[
i
]
&&
players
[
i
].
mo
&&
!
P_MobjWasRemoved
(
players
[
i
].
mo
))
P_PlayerThink
(
&
players
[
i
]);
ps_playerthink_time
=
I_Get
TimeMicros
()
-
ps_playerthink_time
;
ps_playerthink_time
=
I_Get
PreciseTime
()
-
ps_playerthink_time
;
}
// Keep track of how long they've been playing!
...
...
@@ -677,18 +677,18 @@ void P_Ticker(boolean run)
if
(
run
)
{
ps_thinkertime
=
I_Get
TimeMicros
();
ps_thinkertime
=
I_Get
PreciseTime
();
P_RunThinkers
();
ps_thinkertime
=
I_Get
TimeMicros
()
-
ps_thinkertime
;
ps_thinkertime
=
I_Get
PreciseTime
()
-
ps_thinkertime
;
// Run any "after all the other thinkers" stuff
for
(
i
=
0
;
i
<
MAXPLAYERS
;
i
++
)
if
(
playeringame
[
i
]
&&
players
[
i
].
mo
&&
!
P_MobjWasRemoved
(
players
[
i
].
mo
))
P_PlayerAfterThink
(
&
players
[
i
]);
ps_lua_thinkframe_time
=
I_Get
TimeMicros
();
ps_lua_thinkframe_time
=
I_Get
PreciseTime
();
LUAh_ThinkFrame
();
ps_lua_thinkframe_time
=
I_Get
TimeMicros
()
-
ps_lua_thinkframe_time
;
ps_lua_thinkframe_time
=
I_Get
PreciseTime
()
-
ps_lua_thinkframe_time
;
}
// Run shield positioning
...
...
src/r_main.c
View file @
2ab71571
...
...
@@ -34,7 +34,7 @@
#include "m_random.h" // quake camera shake
#include "r_portal.h"
#include "r_main.h"
#include "i_system.h" // I_Get
TimeMicros
#include "i_system.h" // I_Get
PreciseTime
#ifdef HWRENDER
#include "hardware/hw_main.h"
...
...
@@ -100,17 +100,17 @@ lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
extracolormap_t
*
extra_colormaps
=
NULL
;
// Render stats
in
t
ps_prevframetime
=
0
;
in
t
ps_rendercalltime
=
0
;
in
t
ps_uitime
=
0
;
in
t
ps_swaptime
=
0
;
precise_
t
ps_prevframetime
=
0
;
precise_
t
ps_rendercalltime
=
0
;
precise_
t
ps_uitime
=
0
;
precise_
t
ps_swaptime
=
0
;
in
t
ps_bsptime
=
0
;
precise_
t
ps_bsptime
=
0
;
in
t
ps_sw_spritecliptime
=
0
;
in
t
ps_sw_portaltime
=
0
;
in
t
ps_sw_planetime
=
0
;
in
t
ps_sw_maskedtime
=
0
;
precise_
t
ps_sw_spritecliptime
=
0
;
precise_
t
ps_sw_portaltime
=
0
;
precise_
t
ps_sw_planetime
=
0
;
precise_
t
ps_sw_maskedtime
=
0
;
int
ps_numbspcalls
=
0
;
int
ps_numsprites
=
0
;
...
...
@@ -1498,9 +1498,9 @@ void R_RenderPlayerView(player_t *player)
ProfZeroTimer
();
#endif
ps_numbspcalls
=
ps_numpolyobjects
=
ps_numdrawnodes
=
0
;
ps_bsptime
=
I_Get
TimeMicros
();
ps_bsptime
=
I_Get
PreciseTime
();
R_RenderBSPNode
((
INT32
)
numnodes
-
1
);
ps_bsptime
=
I_Get
TimeMicros
()
-
ps_bsptime
;
ps_bsptime
=
I_Get
PreciseTime
()
-
ps_bsptime
;
ps_numsprites
=
visspritecount
;
#ifdef TIMING
RDMSR
(
0x10
,
&
mycount
);
...
...
@@ -1511,9 +1511,9 @@ void R_RenderPlayerView(player_t *player)
//profile stuff ---------------------------------------------------------
Mask_Post
(
&
masks
[
nummasks
-
1
]);
ps_sw_spritecliptime
=
I_Get
TimeMicros
();
ps_sw_spritecliptime
=
I_Get
PreciseTime
();
R_ClipSprites
(
drawsegs
,
NULL
);
ps_sw_spritecliptime
=
I_Get
TimeMicros
()
-
ps_sw_spritecliptime
;
ps_sw_spritecliptime
=
I_Get
PreciseTime
()
-
ps_sw_spritecliptime
;
// Add skybox portals caused by sky visplanes.
...
...
@@ -1521,7 +1521,7 @@ void R_RenderPlayerView(player_t *player)
Portal_AddSkyboxPortals
();
// Portal rendering. Hijacks the BSP traversal.
ps_sw_portaltime
=
I_Get
TimeMicros
();
ps_sw_portaltime
=
I_Get
PreciseTime
();
if
(
portal_base
)
{
portal_t
*
portal
;
...
...
@@ -1561,17 +1561,17 @@ void R_RenderPlayerView(player_t *player)
Portal_Remove
(
portal
);
}
}
ps_sw_portaltime
=
I_Get
TimeMicros
()
-
ps_sw_portaltime
;
ps_sw_portaltime
=
I_Get
PreciseTime
()
-
ps_sw_portaltime
;
ps_sw_planetime
=
I_Get
TimeMicros
();
ps_sw_planetime
=
I_Get
PreciseTime
();
R_DrawPlanes
();
ps_sw_planetime
=
I_Get
TimeMicros
()
-
ps_sw_planetime
;
ps_sw_planetime
=
I_Get
PreciseTime
()
-
ps_sw_planetime
;
// draw mid texture and sprite
// And now 3D floors/sides!
ps_sw_maskedtime
=
I_Get
TimeMicros
();
ps_sw_maskedtime
=
I_Get
PreciseTime
();
R_DrawMasked
(
masks
,
nummasks
);
ps_sw_maskedtime
=
I_Get
TimeMicros
()
-
ps_sw_maskedtime
;
ps_sw_maskedtime
=
I_Get
PreciseTime
()
-
ps_sw_maskedtime
;
free
(
masks
);
}
...
...
src/r_main.h
View file @
2ab71571
...
...
@@ -78,17 +78,17 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe
// Render stats
extern
in
t
ps_prevframetime
;
// time when previous frame was rendered
extern
in
t
ps_rendercalltime
;
extern
in
t
ps_uitime
;
extern
in
t
ps_swaptime
;
extern
precise_
t
ps_prevframetime
;
// time when previous frame was rendered
extern
precise_
t
ps_rendercalltime
;
extern
precise_
t
ps_uitime
;
extern
precise_
t
ps_swaptime
;
extern
in
t
ps_bsptime
;
extern
precise_
t
ps_bsptime
;
extern
in
t
ps_sw_spritecliptime
;
extern
in
t
ps_sw_portaltime
;
extern
in
t
ps_sw_planetime
;
extern
in
t
ps_sw_maskedtime
;
extern
precise_
t
ps_sw_spritecliptime
;
extern
precise_
t
ps_sw_portaltime
;
extern
precise_
t
ps_sw_planetime
;
extern
precise_
t
ps_sw_maskedtime
;
extern
int
ps_numbspcalls
;
extern
int
ps_numsprites
;
...
...
src/sdl/i_system.c
View file @
2ab71571
...
...
@@ -54,12 +54,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <fcntl.h>
#endif
#if defined (_WIN32)
DWORD
TimeFunction
(
int
requested_frequency
);
#else
int
TimeFunction
(
int
requested_frequency
);
#endif
#include <stdio.h>
#ifdef _WIN32
#include <conio.h>
...
...
@@ -2044,112 +2038,36 @@ ticcmd_t *I_BaseTiccmd2(void)
return
&
emptycmd2
;
}
#if defined (_WIN32)
static
HMODULE
winmm
=
NULL
;
static
DWORD
starttickcount
=
0
;
// hack for win2k time bug
static
p_timeGetTime
pfntimeGetTime
=
NULL
;
// ---------
// I_GetTime
// Use the High Resolution Timer if available,
// else use the multimedia timer which has 1 millisecond precision on Windowz 95,
// but lower precision on Windows NT
// ---------
DWORD
TimeFunction
(
int
requested_frequency
)
{
DWORD
newtics
=
0
;
// this var acts as a multiplier if sub-millisecond precision is asked but is not available
int
excess_frequency
=
requested_frequency
/
1000
;
if
(
!
starttickcount
)
// high precision timer
{
LARGE_INTEGER
currtime
;
// use only LowPart if high resolution counter is not available
static
LARGE_INTEGER
basetime
=
{{
0
,
0
}};
// use this if High Resolution timer is found
static
LARGE_INTEGER
frequency
;
if
(
!
basetime
.
LowPart
)
{
if
(
!
QueryPerformanceFrequency
(
&
frequency
))
frequency
.
QuadPart
=
0
;
else
QueryPerformanceCounter
(
&
basetime
);
}
if
(
frequency
.
LowPart
&&
QueryPerformanceCounter
(
&
currtime
))
{
newtics
=
(
INT32
)((
currtime
.
QuadPart
-
basetime
.
QuadPart
)
*
requested_frequency
/
frequency
.
QuadPart
);
}
else
if
(
pfntimeGetTime
)
{
currtime
.
LowPart
=
pfntimeGetTime
();
if
(
!
basetime
.
LowPart
)
basetime
.
LowPart
=
currtime
.
LowPart
;
if
(
requested_frequency
>
1000
)
newtics
=
currtime
.
LowPart
-
basetime
.
LowPart
*
excess_frequency
;
else
newtics
=
(
currtime
.
LowPart
-
basetime
.
LowPart
)
/
(
1000
/
requested_frequency
);
}
}
else
{
if
(
requested_frequency
>
1000
)
newtics
=
(
GetTickCount
()
-
starttickcount
)
*
excess_frequency
;
else
newtics
=
(
GetTickCount
()
-
starttickcount
)
/
(
1000
/
requested_frequency
);
}
return
newtics
;
}
static
void
I_ShutdownTimer
(
void
)
{
pfntimeGetTime
=
NULL
;
if
(
winmm
)
{
p_timeEndPeriod
pfntimeEndPeriod
=
(
p_timeEndPeriod
)(
LPVOID
)
GetProcAddress
(
winmm
,
"timeEndPeriod"
);
if
(
pfntimeEndPeriod
)
pfntimeEndPeriod
(
1
);
FreeLibrary
(
winmm
);
winmm
=
NULL
;
}
}
#else
//
// I_GetTime
// returns time in 1/TICRATE second tics
//
// millisecond precision only
int
TimeFunction
(
int
requested_frequency
)
{
static
Uint64
basetime
=
0
;
Uint64
ticks
=
SDL_GetTicks
();
static
Uint64
timer_frequency
;
if
(
!
basetime
)
basetime
=
ticks
;
static
double
tic_frequency
;
static
Uint64
tic_epoch
;
ticks
-=
basetime
;
tic_t
I_GetTime
(
void
)
{
static
double
elapsed
;
ticks
=
(
ticks
*
requested_frequency
);
const
Uint64
now
=
SDL_GetPerformanceCounter
(
);
ticks
=
(
ticks
/
1000
);
elapsed
+=
(
now
-
tic_epoch
)
/
tic_frequency
;
tic_epoch
=
now
;
// moving epoch
return
ticks
;
return
(
tic_t
)
elapsed
;
}
#endif
tic_t
I_Get
Time
(
void
)
precise_t
I_GetPrecise
Time
(
void
)
{
return
TimeFunction
(
NEWTICRATE
);
return
SDL_GetPerformanceCounter
(
);
}
int
I_
GetTimeMicros
(
voi
d
)
int
I_
PreciseToMicros
(
precise_t
d
)
{
return
TimeFunction
(
1000000
);
return
(
int
)(
d
/
(
timer_frequency
/
1000000
.
0
)
);
}
//
...
...
@@ -2157,26 +2075,11 @@ int I_GetTimeMicros(void)
//
void
I_StartupTimer
(
void
)
{
#ifdef _WIN32
// for win2k time bug
if
(
M_CheckParm
(
"-gettickcount"
))
{
starttickcount
=
GetTickCount
();
CONS_Printf
(
"%s"
,
M_GetText
(
"Using GetTickCount()
\n
"
));
}
winmm
=
LoadLibraryA
(
"winmm.dll"
);
if
(
winmm
)
{
p_timeEndPeriod
pfntimeBeginPeriod
=
(
p_timeEndPeriod
)(
LPVOID
)
GetProcAddress
(
winmm
,
"timeBeginPeriod"
);
if
(
pfntimeBeginPeriod
)
pfntimeBeginPeriod
(
1
);
pfntimeGetTime
=
(
p_timeGetTime
)(
LPVOID
)
GetProcAddress
(
winmm
,
"timeGetTime"
);
}
I_AddExitFunc
(
I_ShutdownTimer
);
#endif
}
timer_frequency
=
SDL_GetPerformanceFrequency
();
tic_epoch
=
SDL_GetPerformanceCounter
();
tic_frequency
=
timer_frequency
/
(
double
)
NEWTICRATE
;
}
void
I_Sleep
(
void
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment