Reflex: one present ID per frame from its start to its present; mode again on a new swapchain; presentId feature

The latency markers and the present carried different present IDs: g_reflex_present_id went up only in flip_locked, so
frame k's simulation, input and submits had ID k and its present k+1 (and with frame_queue or replay_async frames could
share one). Each frame now gets its ID once, when the game acquires its window texture (SIMULATION_START,
vk_reflex_frame_begin), and carries it: INPUT_SAMPLE and SIMULATION_END take the game's current frame, a submission
the frame of the thread that submits it (the game thread's, or the one the replay thread got with its ReplayItem, or
the present thread's from its PresentJob), and the present the frame of its blit (PresentJob.pid -> g_flip_pid). A
present without a frame ID takes the next value, as present IDs must grow on a swapchain.

From the review: a new swapchain sets the sleep mode again (it starts with low latency off), Reflex is off without the
presentId feature, REFLEX sorted in known[], and the ru and pt-BR descriptions name the Boost option as the menu does.

TOTK_TRACE=perf logs every 600 presents the frame start to present time, and with Reflex on how many of the driver's
reports (vkGetLatencyTimingsNV) came back with every marker and their simulation start to GPU render end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
itaskaev2andClaude Opus 5.5 committed 2026-11-10 18:20:16 +01:00
1 parent 41623cec85
commit 6d6b66461b
9 files changed
+123 -31

No files matched your search

+5 -3
View File
@@ -19,7 +19,9 @@
#include "nvn_tex.h"
#include "platform/platform.h"
void vk_reflex_marker(int marker);
void vk_reflex_marker(int marker, uint64_t present_id);
uint64_t vk_reflex_frame_begin(void);
uint64_t vk_reflex_frame(void);
void vk_reflex_sleep(void);
// ---------- Descriptor pools
@@ -691,7 +693,7 @@ NVN_API(nvnWindowAcquireTexture) {
perf_end(PERF_PACE, p0);
}
vk_reflex_sleep();
vk_reflex_marker(0); // VK_LATENCY_MARKER_SIMULATION_START_NV
vk_reflex_marker(0, vk_reflex_frame_begin()); // VK_LATENCY_MARKER_SIMULATION_START_NV: a new frame and its ID
// The sync means "the display no longer reads this image". Presents are copies queued in submit order, so it is
// already satisfied: fenced = 3 with fence 0.
if (s) {
@@ -715,7 +717,7 @@ NVN_API(nvnQueuePresentTexture) {
if (o->magic != NVN_WIN_MAGIC || idx < 0 || idx >= o->ntex || idx >= 4 || !o->tex[idx])
rt_fatal("nvn: QueuePresentTexture of image %d on window %p", idx, (void *)o);
o->presents++;
vk_reflex_marker(1); // VK_LATENCY_MARKER_SIMULATION_END_NV
vk_reflex_marker(1, vk_reflex_frame()); // VK_LATENCY_MARKER_SIMULATION_END_NV
const tex_t *t = (const tex_t *)o->tex[idx];
uint64_t period = present_period(o), now = kern_now_ns();
uint64_t slot = now + pace(&o->pace, now, period);