d3d12: page mappings done behind the call (LEONIDA_ALIAS_LATER) can reach submissions queued before them #3329
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-12-03T12:38:19Z.
queue.rsdocumentsalias_behind(LEONIDA_ALIAS_LATER, on by default with the line of submissions) as: "Submissions already in the line run before it, as on the console's queue." The code orders only one direction.What the code does (main
ba9e65cec, paths undercrates/leonida-gpu/src/):queue.rscopy_page_mappingsresolves the source pages in the title's call, then callsbehind::alias_later(this, later(&gathered)).queue/behind.rsalias_laterpushes the work onto theleonida-aliasthread's own deque and notifies it, then appendsJob::Alias(number)to the queue's lane.alias_workerpops the work and runs it at once. Nothing there looks at the lane, so the unmap and remap can happen while older jobs of the same queue are still in the lane.Job::Alias(Ask::Alias,alias_wait) makes the jobs after it wait forALIAS_DONE >= number. The jobs before it are not held back from seeing the new mapping.Run/Joinedjob held at the head of its queue, for example by a fence wait, prepares later: deferred operations, copy refreshes and texture upload preludes read title memory then (host.rsexecute_parts/send_lateand the refresh paths). A read that starts after the remap sees the new pages.Interleaving: the title queues a wait on a fence, then a submission whose texture refresh reads page P. While the fence is pending, it asks for P to show other physical pages. The alias thread remaps P. The fence is signalled, and the older submission uploads from the new pages, not the ones it was recorded against. On the console the mapping is a queue operation and that submission would read the old pages.
Expected effect: rare one-frame wrong texture or buffer contents during heavy streaming (driving), only when a submission sits behind an unmet wait while the title remaps. I have not reproduced a visible case yet; this is from reading the code.
LEONIDA_ALIAS_LATER=0gives the in-call ordering.Possible fix: keep the resolved closure in the lane entry and hand it to the worker only when
Job::Aliasreaches the head of its queue (the worker keeps the call's cost off the title's thread; the lane already waits for it). The fallbacks that run it in place (no worker thread) should go through the same point.AI-assisted: found by Codex (GPT) in a read-only audit and checked against the source with Claude Opus 5.5 (Claude Code); no runtime change made.