mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 20:09:57 -04:00
Time the hand-off to the present thread, the present call and other threads' acquire waits, and count the acquire's GPU wait once.
The perf lines could not see pacing. In the 0.10.0 fresh session (nx2navi.1.log, 7,974,927 bytes) all 666 windows read "pacing 0%" and "bound: cpu" and all 70 slow-frame lines "pacing 0.0 drain 0.0", while 610 windows had a 16.x ms interval at fps_limit 60 under the game's own limiter. The pacer's wait happened where perf does not count it: vk_backend.c present_image's wait for the present thread to take the previous picture was untimed, perf_end drops waits on any thread but the presenting and replay ones (a game may acquire its window image on another), and the acquire's GPU wait was counted twice, as pacing around b->fence_wait and as a fence wait inside vk_sync_fence_wait (F-7-04). - host.h: PERF_HANDOFF, the presenting thread's wait to hand the present thread the next picture, timed in present_image from under pl (where pending is read) and kept in PresentJob.handoff_ns. perf_end_any counts a wait on any other guest thread into a sum that perf_present adds to the frame before ft_frame reads its parts. - nvn_api_obj.c nvnWindowAcquireTexture: the pacer's sleep is timed with perf_end_any; the GPU wait counts only as the fence wait it is; one line names the threads that acquire and present once the first present is known. - vk_backend.c present_main: the TRACE=present line adds the present call's time (vkQueuePresentKHR, under the queue lock, where an overlay's frame limiter sleeps) and the job's hand-off wait; with trace=perf, a line per 60 presents gives the present thread's blit and submit, paced wait, present call (avg, max), time past target and the hand-off. - perf.c: "handoff" in the window line's shares and the slow-frame line, "hand-off" in the worst-frame lines and as a cause of its own for frames over 25 ms and the stutter map. The "bound:" rule stays as it is until play-test numbers exist. - The cause list changes together: perf.c FT_C_* and ft_cause_name, stutter_map.c SM_CAUSES and cause_short, tests/stutter_hitch_check.c names[] (now sized from SM_CAUSES), and tools/stutter_map.py, whose cause and hitch patterns now take a hyphen. flight.c's frames.tsv gets a handoff_ms column (blocked_names checked against PERF_N), and tools/flight_view.py lists it. - tools/perf_summary.py reads the hand-off share, the present-thread lines and the TRACE=present lines, and prints percentiles of the present interval, paced wait, time past target, present call and hand-off. New tests/perf_summary_check.py makes lines with the runtime's format strings (checked against the C sources) and checks the percentiles, the window averages and the hand-off share, and that older lines without these fields still parse; tests/stutter_map_check.py gets a hand-off hitch and area cause, which the old patterns dropped. Diagnostics only: no wait, pacing or presentation change. Not reproduced before the change (it needs a game run with trace=perf). perf_summary_check, stutter_map_check, stutter_hitch_check, flight_flash_check and frame_step_check pass; every runtime file compiles with the dev flags after the host.h change, and the changed files add no -Wall -Wextra warnings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "nvn_api.h"
|
||||
#include "nvn_hmap.h"
|
||||
#include "nvn_tex.h"
|
||||
#include "prof.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
// ---------- Descriptor pools
|
||||
@@ -827,11 +828,19 @@ NVN_API(nvnWindowAcquireTexture) {
|
||||
NVN_BLOCKING();
|
||||
int idx = o->active ? o->next++ % o->active : 0;
|
||||
*out = idx;
|
||||
// The frame timing's waits count on the presenting thread (perf.c perf_end); a game may acquire on another, whose
|
||||
// wait here perf_end_any adds to the next present. One line names both threads once the first present is known.
|
||||
static volatile int32_t named;
|
||||
if (prof_render_tid && !named && !plat_xchg32(&named, 1)) {
|
||||
uint32_t tid = plat_thread_id();
|
||||
rt_log("nvn: the game acquires its window images on thread %u and presents on thread %u%s", tid,
|
||||
prof_render_tid, tid == prof_render_tid ? "" : ": the acquire's waits count for the next present");
|
||||
}
|
||||
uint64_t at = idx < 4 ? o->avail[idx] : 0;
|
||||
if (at) {
|
||||
uint64_t p0 = perf_begin();
|
||||
sleep_until(at);
|
||||
perf_end(PERF_PACE, p0);
|
||||
perf_end_any(PERF_PACE, p0);
|
||||
}
|
||||
// On the Switch the image comes back only after the display has shown it, which needs the GPU to have finished the
|
||||
// frame drawn into it, so the CPU never runs more than the swapchain's depth ahead of the GPU. Here the pacer frees
|
||||
@@ -846,13 +855,9 @@ NVN_API(nvnWindowAcquireTexture) {
|
||||
}
|
||||
uint64_t *fe = img_fence_of(o, idx), want = fe ? *fe : 0;
|
||||
if (acq_wait == 2) want = last_present_fence;
|
||||
if (acq_wait && want) {
|
||||
if (acq_wait && want) { // the back end's wait counts it as a fence wait (vk_sync.c vk_sync_fence_wait), not pacing
|
||||
const GfxBackend *b = gfx_backend();
|
||||
if (b->fence_done() < want) {
|
||||
uint64_t p0 = perf_begin();
|
||||
b->fence_wait(want, UINT64_MAX);
|
||||
perf_end(PERF_PACE, p0);
|
||||
}
|
||||
if (b->fence_done() < want) b->fence_wait(want, UINT64_MAX);
|
||||
}
|
||||
if (gfx_backend()->frame_start) gfx_backend()->frame_start(); // the frame's work starts here
|
||||
// The sync means "the display no longer reads this image". Presents are copies queued in submit order, so it is
|
||||
|
||||
Reference in New Issue
Block a user