d3d12: honor FidelityFX mv_jittered flag in DLSS and Frame Generation #3378

Open
github-bot wants to merge 1 commit from github-bot/gh-3378 into main AGit
Owner

@⁠Doffi4 on GitHub · 2026-12-03 18:01 UTC · original
Doffi4:fix/dlss-mv-jittered → main · +123 −15 · 5 files · 1 commits · open

Claimed in the coordination issue as: D3D12-DLSS-MV-JITTERED (#3312)

What and why

dlss::record hardcoded FLAG_MV_JITTERED in DLSS.Feature.Create.Flags and fg::constants hardcoded motionVectorsJittered = sl::Boolean::eTrue, ignoring whether the title actually created its FidelityFX upscaler with FFX_UPSCALE_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION (bit 2, 0x04).

When the title supplies unjittered motion vectors (bit 2 unset in the FidelityFX creation flags), telling NGX DLSS and Streamline Frame Generation that the motion vectors are jittered causes them to subtract camera jitter a second time, producing a persistent high-frequency micro-shake on stationary scenes.

This PR propagates the FidelityFX jitter-cancellation flag end-to-end:

  • d3d12/crates/leonida-hle/src/modules/ffx.rs: reads bit 2 (FLAG_MV_JITTER_CANCELLATION) from the FidelityFX upscale creation flags (including after sizes_to_stand_in re-read) and passes mv_jittered to leonida_gpu::list::upscale.
  • d3d12/crates/leonida-gpu/src/list.rs: packs mv_jittered into bit 2 of Upscale wire word w[10] for thin-list replay and passes it to dlss::Inputs.
  • d3d12/crates/leonida-gpu/src/dlss.rs: extracts feature_flags() to set FLAG_MV_JITTERED only when mv_jittered is true (with LEONIDA_DLSS_MV_JITTERED=0|1 override), logs mv_jittered on feature creation, and forwards the effective flag to fg::tag.
  • d3d12/crates/leonida-gpu/src/fg.rs: stores mv_jittered in Latest and sets sl::Constants::motionVectorsJittered accordingly (eTrue / eFalse).
  • d3d12/docs/switches.md: regenerated via python -I tools/d3d12_switches.py --out d3d12/docs/switches.md to catalog LEONIDA_DLSS_MV_JITTERED.

Tested

  • python -I scripts/check_no_game_data.py on all 5 changed files: exit 0.
  • python -I tests/test_d3d12_switches.py: 21/21 OK.
  • cargo check -p leonida-gpu --locked (without dlss / diagnostics): pass.
  • cargo test -p leonida-hle --locked -- ffx::: 6 passed, 0 failed (includes new creation_flags_record_whether_motion_vectors_are_jittered).
  • cargo test -p leonida-gpu --features "dlss diagnostics" --lib --locked -- dlss::tests::feature_flags_honor_mv_jittered fg:: an_upscale_keeps: 23 passed, 0 failed (includes new dlss::tests::feature_flags_honor_mv_jittered and fg::defer_enable_tests::constants_follow_mv_jittered, which fails on main where motionVectorsJittered was hardcoded eTrue).
  • In-game verification: stationary-scene camera micro-shake under DLSS + Frame Generation is eliminated when FidelityFX bit 2 is unset (mv_jittered=false).
  • Audited by a separate read-only reviewer agent (PASS).

GPUs tested: NVIDIA GeForce RTX 5060 Laptop GPU (8 GB), driver 621.40, Windows 11 (26200).

AI-assisted: yes (Gemini Neon — coding agent + separate read-only reviewer agent).

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A — D3D12 runtime only)
**@⁠Doffi4** on GitHub · 2026-12-03 18:01 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3378) `Doffi4:fix/dlss-mv-jittered` → `main` · +123 −15 · 5 files · 1 commits · open Claimed in the coordination issue as: D3D12-DLSS-MV-JITTERED (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/3312) ### What and why `dlss::record` hardcoded `FLAG_MV_JITTERED` in `DLSS.Feature.Create.Flags` and `fg::constants` hardcoded `motionVectorsJittered = sl::Boolean::eTrue`, ignoring whether the title actually created its FidelityFX upscaler with `FFX_UPSCALE_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION` (bit 2, `0x04`). When the title supplies unjittered motion vectors (bit 2 unset in the FidelityFX creation flags), telling NGX DLSS and Streamline Frame Generation that the motion vectors are jittered causes them to subtract camera jitter a second time, producing a persistent high-frequency micro-shake on stationary scenes. This PR propagates the FidelityFX jitter-cancellation flag end-to-end: - `d3d12/crates/leonida-hle/src/modules/ffx.rs`: reads bit 2 (`FLAG_MV_JITTER_CANCELLATION`) from the FidelityFX upscale creation flags (including after `sizes_to_stand_in` re-read) and passes `mv_jittered` to `leonida_gpu::list::upscale`. - `d3d12/crates/leonida-gpu/src/list.rs`: packs `mv_jittered` into bit 2 of `Upscale` wire word `w[10]` for thin-list replay and passes it to `dlss::Inputs`. - `d3d12/crates/leonida-gpu/src/dlss.rs`: extracts `feature_flags()` to set `FLAG_MV_JITTERED` only when `mv_jittered` is true (with `LEONIDA_DLSS_MV_JITTERED=0|1` override), logs `mv_jittered` on feature creation, and forwards the effective flag to `fg::tag`. - `d3d12/crates/leonida-gpu/src/fg.rs`: stores `mv_jittered` in `Latest` and sets `sl::Constants::motionVectorsJittered` accordingly (`eTrue` / `eFalse`). - `d3d12/docs/switches.md`: regenerated via `python -I tools/d3d12_switches.py --out d3d12/docs/switches.md` to catalog `LEONIDA_DLSS_MV_JITTERED`. ### Tested - `python -I scripts/check_no_game_data.py` on all 5 changed files: exit 0. - `python -I tests/test_d3d12_switches.py`: 21/21 OK. - `cargo check -p leonida-gpu --locked` (without `dlss` / `diagnostics`): pass. - `cargo test -p leonida-hle --locked -- ffx::`: 6 passed, 0 failed (includes new `creation_flags_record_whether_motion_vectors_are_jittered`). - `cargo test -p leonida-gpu --features "dlss diagnostics" --lib --locked -- dlss::tests::feature_flags_honor_mv_jittered fg:: an_upscale_keeps`: 23 passed, 0 failed (includes new `dlss::tests::feature_flags_honor_mv_jittered` and `fg::defer_enable_tests::constants_follow_mv_jittered`, which fails on `main` where `motionVectorsJittered` was hardcoded `eTrue`). - In-game verification: stationary-scene camera micro-shake under DLSS + Frame Generation is eliminated when FidelityFX bit 2 is unset (`mv_jittered=false`). - Audited by a separate read-only reviewer agent (`PASS`). GPUs tested: NVIDIA GeForce RTX 5060 Laptop GPU (8 GB), driver 621.40, Windows 11 (26200). AI-assisted: yes (Gemini Neon — coding agent + separate read-only reviewer agent). ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (N/A — D3D12 runtime only)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 18:05:19 +00:00
Author
Owner

@⁠merzleckeier on GitHub · 2026-12-03 18:08 UTC · original

[P2] Read the jitter flag from the context passed to ffxDispatch. The atomic records the most recent creation attempt for the entire process. Creating context B with bit 2 clear makes a subsequent dispatch on the still-live context A report mv_jittered=false, even though A was created with bit 2 set. A rejected creation also changes the flag because the hook stores it before the provider returns. Both paths can give DLSS and Frame Generation the wrong jitter mode. Dispatch read · Global write during creation

I cross-compiled the exact FFX wrapper for Windows and ran it under Wine with a fake provider and an upscale recorder. Six existing wrapper tests passed. The two added regressions reproduced the issues. After successful creations, dispatching A and B forwarded (false, false) instead of (true, false). A rejected second creation also flipped A from true to false.

Please associate the flag with the handle returned on successful creation and look it up for the handle supplied to dispatch. Retire that association with the context so handle reuse cannot inherit stale flags. FidelityFX context API

AI-assisted with OpenAI Codex. Synthetic contexts only, no GPU or game run.

**@⁠merzleckeier** on GitHub · 2026-12-03 18:08 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3378#issuecomment-7387665431) **[P2] Read the jitter flag from the context passed to `ffxDispatch`.** The atomic records the most recent creation attempt for the entire process. Creating context B with bit 2 clear makes a subsequent dispatch on the still-live context A report `mv_jittered=false`, even though A was created with bit 2 set. A rejected creation also changes the flag because the hook stores it before the provider returns. Both paths can give DLSS and Frame Generation the wrong jitter mode. [Dispatch read](https://github.com/ProjectLeonida/mandy/blob/60916154fef9de681dc6ca169e9ded1b98fd4127/d3d12/crates/leonida-hle/src/modules/ffx.rs#L178-L181) · [Global write during creation](https://github.com/ProjectLeonida/mandy/blob/60916154fef9de681dc6ca169e9ded1b98fd4127/d3d12/crates/leonida-hle/src/modules/ffx.rs#L297-L312) I cross-compiled the exact FFX wrapper for Windows and ran it under Wine with a fake provider and an upscale recorder. Six existing wrapper tests passed. The two added regressions reproduced the issues. After successful creations, dispatching A and B forwarded `(false, false)` instead of `(true, false)`. A rejected second creation also flipped A from true to false. Please associate the flag with the handle returned on successful creation and look it up for the handle supplied to dispatch. Retire that association with the context so handle reuse cannot inherit stale flags. [FidelityFX context API](https://gpuopen.com/manuals/fsr_sdk/getting-started/ffx-api/) AI-assisted with OpenAI Codex. Synthetic contexts only, no GPU or game run.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3378/head:github-bot/gh-3378'
git switch 'github-bot/gh-3378'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3378'
git switch 'github-bot/gh-3378'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3378'
git switch 'github-bot/gh-3378'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3378'
git switch 'main'
git merge --squash 'github-bot/gh-3378'
git switch 'main'
git merge --ff-only 'github-bot/gh-3378'
git switch 'main'
git merge 'github-bot/gh-3378'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/ubiquitarianism--leonida!3378
No description provided.