ffx: the upscaler's jitter phase count is never 0 (FFX-JITTER-NEVER-ZERO) #3443
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
2 participants
Due date
No due date set.
Reference
leonida/mandy!3443
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/ffx-jitter-never-zero"
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?
Pull request successfully merged and closed
Change
The 0xC0000094 (integer division by zero right after the first upscale) is still reported after #3022 (RTX 5070 Ti,
Series S, DLSS performance). Hypothesis (not measured): the title's upscaler refuses the context, the title keeps a null
context, its jitter phase count query answers 0 and it divides by it.
context of ours (non-null, result 0).
ffxQuery,ffxDestroyContextandffxConfigureare bound to ours while thedispatch is ours, so the stand-in never reaches the title's DLL; our DLSS/stretch upscale still draws.
is the public FSR 2 formula
ceil(8 * (display/render)^2), min 1, max 4096 (720->1080 = 18, 540->1080 = 32,1080->1080 = 8). The jitter offset on a stand-in is the public Halton (2,3) sequence.
LEONIDA_FFX_SAFE_JITTER=0gives back the previous behaviour.switches.mdregenerated; note infindings.md.Tests
cargo test -p leonida-hle --locked: 284 passed (new: refused/absent create gives a non-null stand-in and safedispatch/configure/destroy; made context kept; phase formula 18/32/8; phases >= 1 for zero and absurd sizes; query
never answers 0 with a stand-in, a zero, an error or no DLL function; good DLL answers untouched).
cargo check -p leonida --tests,python -I tests/test_d3d12_switches.py,scripts/check_no_game_data.pyon the touched files.In-game run
Game gate (
scripts/game-gate.ps1) on a test branch that merges four changes over maina558375458: this PR together with the FFX jitter, XMem low window and descriptor-record changes and a periodic preload save.-SeriesS -PrecompileUsed, RTX 4060 8 GB, driver 32.0.16.1088, Windows 11, build with diagnostics. PASS, 314 s in the world, no device loss, median 17.7 fps, VRAM peak 6 390 MB for a 6 776 MB budget. Warningfault_after_stop(access violations in the runtime after the gate stopped the run, clean exit): the same 8 faults appear on a run of another branch, so most likely not from this change (not yet compared with main).cargo test --locked -p leonida-gpu -p leonidaon that test branch: 742 + 62 + 5 passed, 0 failed.On this NVIDIA card the upscaler's context was made normally (no "stand-in context" or "phase count is made here" line), so the fallback this PR adds was not exercised: it needs a card where the 0xC0000094 crash happens today (reports are mostly AMD). Testers with such a card are welcome (docs/game_gate.md).
AI-assisted
Written with Claude Opus 5.5 (Claude Code); reviewed by a separate Claude Opus 5.5 reviewer instance, whose findings (query numbers and widths) are fixed. The query structure layouts are the public
ffx_upscale.hones.🤖 Generated with Claude Code
Thanks, here are the results.
scripts/game-gate.ps1 run ... -PlayArgs '-SeriesS', 300 s target, defaultLEONIDA_THIN=1(6 threads), RX 6800 XT, driver 32.0.21045.29003. Same data folder and caches for both runs, warmed first by a 60 s gate run on main withLEONIDA_THIN=0(PASS, 29.5 fps median).68427be7edevice_lost,world_not_reached)290bf3dc2device_lost,world_not_reached)This is the RDNA 2
LEONIDA_THIN=1reset from #3264 (0x887A0007, game exit0x887A0005,device-removed data; none), not the0xC0000094: no access violation or division by zero in either run. So these runs can't confirm or rule out the fix on this card.What #3443's code did before the reset: the upscale context was created (
render=[1280, 720] upscale=[1920, 1080],amd_fidelityfx_upscaler_xbox.dllrefused by the host policy as on main), and four upscale dispatches ran, as on main. Neither of the PR's warnings appears (no stand-in context, no phase count made by the fallback). I can run it again withLEONIDA_THIN=0to get past world entry, if that helps.The gate run folders (
summary.json,run.json,events.jsonl,memory.csv,leonida.log), with the Windows user and PC names replaced:mandy-gate-main-rx6800xt.zip,mandy-gate-pr3443-rx6800xt.zip.AI-assisted: log analysis and write-up with Claude Opus 5.5 (High).
Merging, with Moon's written OK as maintainer (only two maintainers: the CONTRIBUTING rule against merging one's own PR is waived for this series). Branch updated with main
5e7d6cfcc1(conflict inrun.rswith #3447 resolved: the three FFX bindings kept, thensay!). The merged tree (22490c84) is the one tested locally:cargo test --locked -p leonida-gpu -p leonida -p leonida-hleall passed,tests/test_d3d12_switches.pyOK. In-game gate in the description (PASS, 314 s, no device loss). AI-assisted (Claude Opus 5.5).Thanks @MoonEyes, here are the results.
Same gate recipe as above (
-PlayArgs '-SeriesS', 300 s), this time with theLEONIDA_THIN=0workaround so the runs get past world entry. Same data folder and caches, one run per build.68427be7e290bf3dc2The mean fps is the gate's frame count divided by the time it covers (the world minus its first 60 s); the other columns are the gate's own. Both runs stopped cleanly on the target, cache saved, no crash, no
ERRORline, no missed pipeline wait, video memory under budget the whole time. One run each, played freely rather than on a fixed route, so the fps gap is within what I'd expect from that. The gate'sunder_2_at_sis 200 s on main and 371 s on #3443 (one second with fewer than 2 frames each; the longest gaps with no frame were 1.4 s and 2.5 s).No
0xC0000094and no access violation on either build. But on this card the path #3443 changes is barely used: as on main, the run made one upscale context (1280×720 to 1920×1080) and four upscale dispatches in total, and neither of the PR's warnings appears (no stand-in context, no phase count made by the fallback). So this run shows #3443 does no harm here, but it can't show the fix, since the crash was reported with DLSS on an RTX 5070 Ti.With the default
THIN=1the device is still lost at world entry with #3443 as on main (my results above, #3264); #3031 avoids it on this card.Logs:
mandy-gate-pr3443-thin0-rx6800xt.zip(Windows user and PC names replaced). The main run's logs are under the #3439 comment.AI-assisted: log analysis and write-up with Claude Opus 5.5 (High).