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

Open
Doffi4 wants to merge 1 commit from upstream-pr/3378 into main
Doffi4 commented 2026-12-03 18:01:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Doffi4 on 2026-12-03T18:01:18Z.


Claimed in the coordination issue as: D3D12-DLSS-MV-JITTERED (https://github.com/ProjectLeonida/mandy/issues/3312#issuecomment-7387426972)

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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5632105943 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3378). Originally posted by [Doffi4](https://github.com/Doffi4) on 2026-12-03T18:01:18Z. --- Claimed in the coordination issue as: D3D12-DLSS-MV-JITTERED (https://github.com/ProjectLeonida/mandy/issues/3312#issuecomment-7387426972) ### 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)
merzleckeier commented 2026-12-03 18:08:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T18:08:08Z.


[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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7387665431 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3378#issuecomment-7387665431). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T18:08:08Z. --- **[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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3378:upstream-pr/3378'
git switch 'upstream-pr/3378'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3378'
git switch 'upstream-pr/3378'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3378'
git switch 'upstream-pr/3378'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3378'
git switch 'main'
git merge --squash 'upstream-pr/3378'
git switch 'main'
git merge --ff-only 'upstream-pr/3378'
git switch 'main'
git merge 'upstream-pr/3378'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
ProjectLeonida/mandy!3378
No description provided.