mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 23:49:56 -04:00
Test held work against the event's value now when another thread asks without the submission lock, and read the held count and the submission count as atomics there.
vk_exec_held_ready runs without sub_lock (vk_backend.c held_resume, submit_sync). It decided from the published copy
since 688b2506, but tested the wait with vk_exec_event_met, which compares at the copy point of the submission being
recorded (vk_exec_xfer.c ev_mem, ev_sync_seq). That point is set by whichever thread holds the lock, so a thread asking
while another one recorded tested "at sync" against that other submission's copies. Its question is whether held work
can go on in a submission of its own, which takes its copies later: vk_exec_event_met_now tests the value in memory now
or the signals replayed so far. Under the lock nothing changes: evo_resume and cont_ready keep the copy-point test, and
vk_exec_record asks right after its own copy point, where the two agree.
evo_pending and vk_exec_submit_seq are written under the lock and were read as plain values by vk_exec_held,
vk_exec_held_ready and the held present's since and PH_MAX checks; they are now stored and loaded as atomics
(vk_exec_submit_seq_now), so the compiler cannot keep a stale copy in an unlocked reader.
Not reproduced before the change. Checks that passed: pass_cc_check on every runtime file (a header changed), no new
-Wall -Wextra warnings in vk_exec.c, vk_exec_xfer.c and vk_backend.c, evo_peek_check, target_frames_check and
oq_hold_check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -505,7 +505,7 @@ static void ph_flush(uint64_t *why) {
|
||||
if (PH.logged < 16)
|
||||
PH.logged++, rt_log("vk: the present of frame %llu went out %llu submission(s) after the game's present call, %d "
|
||||
"held submissions left (%s)", (unsigned long long)PH.frame,
|
||||
(unsigned long long)(vk_exec_submit_seq - PH.since), vk_exec_held(),
|
||||
(unsigned long long)(vk_exec_submit_seq_now() - PH.since), vk_exec_held(),
|
||||
why == &PH.after ? "the held work was replayed" : why == &PH.capped ? "PH_MAX reached"
|
||||
: "the next present came");
|
||||
present_image(PH.t, PH.has_crop ? PH.crop : NULL, PH.at_ns, PH.queued, PH.frame, 0);
|
||||
@@ -532,7 +532,7 @@ static uint64_t submit_sync(const uint64_t *handles, int n) {
|
||||
if (n && vk_exec_event_at_sync() && vk_exec_held() && vk_exec_held_ready()) f = submit_sync(NULL, 0);
|
||||
if (PH.on && n) {
|
||||
if (!vk_exec_held()) ph_flush(&PH.after);
|
||||
else if (vk_exec_submit_seq - PH.since >= PH_MAX) ph_flush(&PH.capped);
|
||||
else if (vk_exec_submit_seq_now() - PH.since >= PH_MAX) ph_flush(&PH.capped);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
@@ -718,7 +718,7 @@ static void vk_be_present(const tex_t *t, const int crop[4], uint64_t at_ns) {
|
||||
if (vk_exec_held()) {
|
||||
PH.on = 1, PH.t = t, PH.has_crop = crop != NULL, PH.at_ns = at_ns, PH.queued = queued, PH.frame = frame;
|
||||
if (crop) memcpy(PH.crop, crop, sizeof PH.crop);
|
||||
PH.since = vk_exec_submit_seq, PH.waited++;
|
||||
PH.since = vk_exec_submit_seq_now(), PH.waited++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user