]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
cl_capturevideo: fix extremely slow demo capture perf
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 25 Aug 2024 16:20:45 +0000 (02:20 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 12 Sep 2024 13:51:12 +0000 (23:51 +1000)
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 <bones_was_here@xonotic.au>
cl_main.c
cl_screen.c

index fce987867c73a8075dd8a267862f0c6fc74aabf5..d8d7b7d52c6a3cdcaec9cce8fe234972745694d8 100644 (file)
--- 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;
 
index 1ded3749ab7c332215a0699cb46e5da1d9de8292..9df7e9010746f62e3bf09f770e099b13bd4df7a9 100644 (file)
@@ -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);