From b18fff6439532a4c2367b5a6add942dede6f6429 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Fri, 13 Nov 2026 19:44:35 -0500 Subject: [PATCH] Count a frame's bookkeeping that a submission runs for an earlier present as that thread's replay time. The review of cd2fd454 found that vk_sync.c submit calls vk_present_frames_owed before its replay timing starts (t0 = perf_begin), so the owed bookkeeping a submitting thread runs was timed nowhere: a DLSS release in vk_dlaa_frame (16 to 45 ms, F-4-02) would have shown as unattributed time in the frame-time and slow-frame lines, where the design counts it as that thread's replay time. vk_present_frames_owed now times the frames it runs and adds them with perf_replay. The present thread's catch-up before a blit (present_frame_closed) is not replay: it shows in the present thread's own blit time and in the frame bookkeeping line. Checks that passed: pass_cc_check of vk_backend.c with no new -Wall -Wextra warnings. Co-Authored-By: Claude Opus 5.5 --- runtime/vk_backend.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/runtime/vk_backend.c b/runtime/vk_backend.c index 20a955aa..83d1385b 100644 --- a/runtime/vk_backend.c +++ b/runtime/vk_backend.c @@ -331,9 +331,14 @@ static int fo_try(void *arg) { return vk_sync_try_locked(fo_here); } -// vk_sync.c submit, sub_lock held, before its replay: the frames presented while another thread held the lock. +// vk_sync.c submit, sub_lock held, before its replay: the frames presented while another thread held the lock. Their +// time counts as this thread's replay time (perf_replay), as submit's own timing starts after this call: a DLSS release +// in vk_dlaa_frame (tens of milliseconds) then shows as replay in the frame-time and slow-frame lines, not unattributed. void vk_present_frames_owed(void) { - if (fo_waiting(&FO)) __atomic_add_fetch(&fo_late_n, fo_run(&FO, fo_end, NULL), __ATOMIC_RELAXED); + if (!fo_waiting(&FO)) return; + uint64_t t0 = perf_begin(); + __atomic_add_fetch(&fo_late_n, fo_run(&FO, fo_end, NULL), __ATOMIC_RELAXED); + perf_replay(t0); } // The present thread, before it uses frame (present_main): frame_end of a frame the presenting thread left owed has run