Repository navigation
Conversation
… (DM_NVN_ACQ_NEXT)
|
This looks fixed for my XC3 Colony 9 repro on Mac. I manually played XC3 2.2.1 with #3372 enabled in a normal window, without scripted input or capture options, and didn't see the corruption recur. I also tested PR head
|
|
Quick XC2 follow-up: I briefly played XC2 3.0.0 from the Central Exchange save on the same M4 Mac after locally merging |
On Horizon, an acquired swapchain image is returned once the compositor has replaced it with the next present, so the GPU has completed that successor frame. Previously, the host waited only on the image's own previous present plus a racy mtl_last_fence() snapshot taken at acquire time, allowing two-image games that pace per-frame constants on the acquire sync alone (Xenoblade DE Switch 2, Xenoblade Chronicles 3 #3296) to overwrite live constants when nq_worker trailed, and causing three-image swapchains to over-wait on frame N-1 once replayed. Track each slot's successor present receipt directly in win_t.next_ticket[4] (via last_pres), atomically hand both receipts to nvnWindowAcquireTexture, wait on the successor's replay publication and GPU fence (without blocking on its display/snapshot release), snapshot both receipts in nvnQueueWaitSync / nvnCommandBufferWaitSync, and drop the racy mtl_last_fence() fallback under default DM_NVN_ACQ_NEXT=1 (superseding PR #1847's own-present fence). DM_NVN_ACQ_NEXT=0 restores the legacy acquire wait for A/B isolation. Co-authored-by: Will Varner <37232968+willv678@users.noreply.github.com>
|
Thank you @willv678 for tracking down the acquire-sync race, isolating it on Xenoblade DE Switch 2, and validating Donkey Kong Bananza alongside it. This landed on A few adjustments went in on the way to
Checked: Still open: retesting Xenoblade DE Switch 2, Xenoblade Chronicles 3 (#3296), Xenoblade Chronicles 2 (#3346), and Donkey Kong Bananza on |
|
Thanks for landing it and for hardening it. The per-slot successor and the queue-side waits are better than what I had. And thanks @FantasyGmm for checking XC3 and XC2, glad it was the same race. Retested Xenoblade DE Switch 2 on main at e8ac733 (M2 Pro, docked, MetalFX on): the intro run had no flat frames, same as with my branch. |
… translation caches): closed; on main in its own form as 473c90d (mesh pipeline and run-twin cache) and 1999cbd (seedds#3372: the acquire sync waits for the successor present), with main's own store-witness growth and command-buffer growth; the GPU clock keeper (DM_GPU_KEEP) was declined upstream and goes too, as does the ubd_conflict_sh cache
What and why
On Horizon, a window image comes back to the game once the compositor has taken the next present, so the GPU has finished the frame after that image's last one. The host gave it back one frame earlier, once its own present's copy had run, and the fence the acquire waited on is the replay's newest, which can trail what the game has submitted.
Most games don't notice. Xenoblade Chronicles DE (Switch 2 Edition) does: two images, it waits only on the acquire sync (every
nvnSyncWaitin the intro is on it, infinite timeout), and it keeps its per-frame constants in two slots that alternate by frame. It wrote frame N+1's constants into the slot frame N-1 was still drawing with. Its 1x1 exposure texture went NaN and the tone mapping multiplied the whole picture by it: flat blue/purple frames with only the subtitles on top, plus streaks. Xenoblade 3's world streaks (#3296) have the same shape and might be the same thing.The fix keeps each image's present order.
nvnWindowAcquireTexturetakes a reference to the ticket of the present after the acquired image's last one, and the acquire's wait (innvnSyncWait, at the next acquire, or immediately without a sync) waits until that present has been replayed and the GPU is past the fence it ended at. With two images that's the frame before; with three, the one before that, same as Horizon.DM_NVN_ACQ_NEXT=0turns it off.About #1847: that PR moves the acquire sync the other way for DK Bananza (to the image's own release, because fencing it on every submission made DK wait on the frame it just submitted). The two don't conflict on the main point, both stop waiting on the newest submission, but #1847's fence is the image's own present, which is one frame too early for a game like Xenoblade. I ran DK on this branch to check it doesn't cost DK anything (below). Happy to rebase on whichever lands first, or talk it through on #1847.
Checked
t_nvnsection 6a (new): with two images, the image presented before a present the queue holds behind an unsignaled event comes back next, its acquire'snvnSyncWaittimes out while the event is unsignaled and is signaled once the held present has run. It fails withDM_NVN_ACQ_NEXT=0.t_nvn541/541,t_perf_order,t_reorder_chain,t_feedback,t_dlss_scalerpass.0400FF500E34A001, 2.0.0, local profile, there's none in the repo yet): the intro had flat frames in 35 of 46 sampled frames before, none after.DM_NVN_MAGSCANfound NaN in 553 frames of a 150 s run before, 0 after.040074A01BF12000, v458752) on main vs this branch, the same scripted run from a new save through the intro into the mining tunnel (about 7 minutes each): identical frame times in every 300-frame window (60 fps intro, 30 at the first punch prompt, 20 fps in the tunnel with the GPU at about 43 ms on this M2 Pro, which is the same on main), no new red lines, and the tunnel draws correctly.regress.py: DK has no smoke route on main (games: boot smoke routes for Donkey Kong Bananza, Welcome Tour and Xenoblade Chronicles 3 #3189's needs the bench save), so I ran it by hand as above. Xenoblade has no profile on main.Docs
docs/reference/frame-rate.md: "An acquired image comes back once the present after it has run";docs/env_switches.tsvrow; symptom index regenerated