From: bones_was_here Date: Sun, 25 Aug 2024 16:20:45 +0000 (+1000) Subject: cl_capturevideo: fix extremely slow demo capture perf X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ef764984a324c18e7c37562cb5388b24cec1c9b0;p=xonotic%2Fdarkplaces.git cl_capturevideo: fix extremely slow demo capture perf If the recording started before the playdemo, or in the same command string, most of the CPU time was spent sleeping. Also fixes a stall when starting the recording. Minor cleanup. Signed-off-by: bones_was_here --- diff --git a/cl_main.c b/cl_main.c index fce98786..d8d7b7d5 100644 --- a/cl_main.c +++ b/cl_main.c @@ -2814,18 +2814,15 @@ double CL_Frame (double time) * run the frame. Everything that happens before this * point will happen even if we're sleeping this frame. */ - if((cl_timer += time) < 0) - return cl_timer; // limit the frametime steps to no more than 100ms each - if (cl_timer > 0.1) - cl_timer = 0.1; + cl_timer = min(cl_timer + time, 0.1); // Run at full speed when querying servers, compared to waking up early to parse // this is simpler and gives pings more representative of what can be expected when playing. maxfps = (vid_activewindow || serverlist_querystage ? cl_maxfps : cl_maxidlefps).value; - if (cls.state != ca_dedicated && (cl_timer > 0 || cls.timedemo || maxfps <= 0)) + if (cls.state != ca_dedicated && (cl_timer > 0 || host.restless || maxfps <= 0)) { R_TimeReport("---"); Collision_Cache_NewFrame(); @@ -2876,9 +2873,6 @@ double CL_Frame (double time) clframetime = 0; } - if (cls.timedemo) - clframetime = cl.realframetime = cl_timer; - // deduct the frame time from the accumulator cl_timer -= cl.realframetime; diff --git a/cl_screen.c b/cl_screen.c index 1ded3749..9df7e901 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -1083,6 +1083,9 @@ static void SCR_CaptureVideo_BeginVideo(void) dpsnprintf(cls.capturevideo.basename, sizeof(cls.capturevideo.basename), "video/%s%03i", timestring, cl_capturevideo_number.integer); Cvar_SetValueQuick(&cl_capturevideo_number, cl_capturevideo_number.integer + 1); + // capture demos as fast as possible + host.restless = !cls.capturevideo.realtime; + /* for (i = 0;i < 256;i++) { @@ -1155,6 +1158,7 @@ void SCR_CaptureVideo_EndVideo(void) if (!cls.capturevideo.active) return; cls.capturevideo.active = false; + host.restless = false; Con_Printf("Finishing capture of %s.%s (%d frames, %d audio frames)\n", cls.capturevideo.basename, cls.capturevideo.formatextension, cls.capturevideo.frame, cls.capturevideo.soundsampleframe);