Frame clock: fire events due at the same point; build a waited-for queued pipeline at once #165
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!165
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/165/head"
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?
@KnucklesB on GitHub · 2026-11-23 18:05 UTC · original
KnucklesB:main→main· +113 −46 · 2 files · 2 commits · closed without mergingTwo fixes found while bringing up the retail title on
mainas ofdb5dc26. Each comes with a test that fails without it.1. Frame clock: fire every event type due at the same point (
frame.rs)The clock thread picked one event per deadline (
min_by_keyreturns the first one). The retail title schedules frame event types 0 and 2 both at offset 0 µs, so they share every deadline: type 0 always won, type 2 was recomputed for the next frame each time and never fired. The title waits for type 2 with an infinite timeout (WaitFrameEventX(2, INFINITE)fromgame+0x2482405), so its frame loop stopped after a few frames. After that the activity log showed only0 presents, 0 submits, 0 frame-event waits.Now every event due at the earliest deadline fires in that tick.
Test:
events_at_the_same_offset_all_fire. Types 0 and 2 at offset 0 both reach their waiters.2. Background pipelines: a waited-for pipeline still in the queue is built by the waiter (
pso_async.rs)A compute pipeline is waited for at its first bind, but its build sat in the FIFO behind everything submitted before it. The retail title queues thousands of graphics pipelines while loading (5000+), so one bind waited for the whole queue. The build is now taken by whoever gets to it first: a worker, or the waiting thread. The waiting thread runs it on a thread with the workers' 64 MiB stack, because translation recurses deeply.
Test:
a_waited_pipeline_does_not_wait_for_the_queue. A pipeline waited for behind 2× the worker count of slow builds is ready at once.cargo test -p xcl --lib: 537 passed, 19 ignored. Tested on an NVIDIA GPU (Windows 11).With both fixes the title gets past its first frames (2 → 16 presented). It then still stops in loading on another issue, unrelated to these two.
@Kalmarv on GitHub · 2026-11-23 20:41 UTC · original
Both new tests distinguish the PR from its fork point, and both already pass on current main. I ran the PR head directly and carried the two tests verbatim to each control. Windows x64 MSVC, Rust 1.99.0, two pipeline workers. These tests exercise Windows events and synthetic pipeline jobs.
db5dc26cba45278948dca2549b15ae53b9435d89956a476bf738a098f39df4f4c8acef682e43030f6c88c8a19b31ee016069760a20c53cd7494d6c8eThe PR head passed all 55 D3D12.X tests. On main, the first module run had 55 passes and one failure in the existing origin-statistics test: timestamps went backwards by 74 QPC ticks. A rerun passed all 56. The frame module alone subsequently passed 48/48 test invocations on each revision (12 fresh processes each).
There is a matching ordering gap on both revisions. On the PR head,
crates/xcl/src/hle/d3d12x/frame.rs:453wakes an origin waiter before taking the queue lock and publishing its timestamp. A waiter can acquire the lock first at line 322, find the queue empty and take a fresh QPC reading. The next waiter can then consume the older queued timestamp. Holding the origin-queue lock across the semaphore release and timestamp insertion would close that window. This interleaving explains the observed ordering; the failing run did not trace lock acquisition.Current main covers both tested behaviors. The two regression tests can be carried independently. No retail timing, driver compilation, or merge build. AI-assisted review.
@ivall on GitHub · 2026-11-23 20:52 UTC · original
Closing: both halves are on main now. The frame clock fires every event type due at one deadline (
956a476), and a waited-for pipeline that has not started is built by the waiter (pso_async::resolve_wait). The branch also conflicts with main in 2 files. Thanks for the work!Pull request closed