FidelityFX: a stand-in context where the title's own could not be made (DLSS on), no divide by zero at the first upscaling (#3885) #4410

Closed
github-bot wants to merge 11 commits from github-bot/gh-4409 into main AGit
Owner

@⁠davemathews12 on GitHub · 2026-11-30 19:56 UTC · original
davemathews12:fix/ffx-stand-in-context → main · +1066 −823 · 33 files · 11 commits · closed without merging

Fixes #3885 (and #170, closed for its old version)

What it changes

The crash. 0xC0000094 (integer divide by zero) at victory-image-…dll+0x28f03e8, in the prologue's prestream, before the first frame of play.

Why. With DLSS taking the upscalings, fidelityfx.rs makes the title's FidelityFX upscaler at the size its shipping FSR4 accepts. On some PCs even that creation fails. #3885's play log shows:

asked_render=[960, 540] asked_output=[1920, 1080] made_render=[1280, 720] made_output=[1920, 1080] code=2

The title never checks the result. It then asks the jitter-phase-count query (0x1_0004) of the context it thinks it has, writing the answer straight into its upscaler object and ignoring the return code. Every frame, it computes a jitter index as counter % phase_count. With the query failed, the phase count is still 0 and the title divides by it. Checked against the 1.0.2.1 executable: the field divided by at +0x28f03e8 is the one the phase-count query writes, and the same object fills the jitter-offset query (0x1_0005) with it.

The fix. When creation fails and DLSS is upscaling, the title gets a stand-in context:

  • Queries are answered as the SDK answers them: the phase count 8 × (display / render)² (32 for 960 → 1920, never 0), Halton(2, 3) jitter offsets, and zero GPU memory (the title adds up the total it's given).
  • Upscale dispatches go to DLSS. If DLSS refuses one, it goes to the existing plain bilinear upscaling, the same path a context made smaller than asked (clamped) uses.
  • Nothing reaches the title's DLL with the stand-in handle: configure, other dispatches and destroy are handled here.
  • The failure is logged as an error. Today the log line reads "made at a size its shipping FSR4 accepts" even when code=2.

What doesn't change: a creation that succeeds, and every path without DLSS.

How it was tested

  • GPU and profile: not run on a card. The scenario is #3885's: Series S, 960x540 → 1920x1080, DLSS Performance, RTX 5060 Ti 8 GB.
  • Before: crash at +0x28f03e8 (#3885 and #170, the same signature on several versions).
  • After: the title's queries get a non-zero phase count, so the division is safe. I couldn't run the game, so whether the picture then comes through DLSS needs a run on an affected PC. @⁠yasui-i, could you try this branch?
  • New tests in fidelityfx.rs:
    • the query layouts at the offsets the title's code uses;
    • the phase count against the SDK formula (never 0);
    • the Halton offsets against reference values;
    • the three queries answered, while unknown queries are refused with their outputs untouched;
    • a stand-in made and let go.
  • cargo clippy -p victory-hle --all-targets --target x86_64-pc-windows-msvc is clean. mimalloc's C++ build needs the Windows SDK, so for this check it was swapped for a system-allocator stub through --config patch…; nothing committed. The pure functions' tests also pass on Linux.
  • For shader changes, the wave sizes tested: n/a.
  • cargo test passed for the crates it touches: the new tests are Windows-only, like the module, so they run in CI. Not run locally.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: none fixes this. Searched #3885, "phase count", "jitter fidelityfx", "0x28f03e8", "divide by zero", and the FidelityFX PRs (#3857, #3728, #2248, #3011, #2642). docs/dlss.md and the SHIPPING_MAX_* comment describe the same divide-by-zero for creations that fail at other sizes; this covers the case where the shipping-size creation fails too.
**@⁠davemathews12** on GitHub · 2026-11-30 19:56 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4409) `davemathews12:fix/ffx-stand-in-context` → `main` · +1066 −823 · 33 files · 11 commits · closed without merging Fixes #3885 (and #170, closed for its old version) ## What it changes **The crash.** `0xC0000094` (integer divide by zero) at `victory-image-…dll+0x28f03e8`, in the prologue's prestream, before the first frame of play. **Why.** With DLSS taking the upscalings, `fidelityfx.rs` makes the title's FidelityFX upscaler at the size its shipping FSR4 accepts. On some PCs even that creation fails. #3885's play log shows: ``` asked_render=[960, 540] asked_output=[1920, 1080] made_render=[1280, 720] made_output=[1920, 1080] code=2 ``` The title never checks the result. It then asks the jitter-phase-count query (`0x1_0004`) of the context it thinks it has, writing the answer straight into its upscaler object and ignoring the return code. Every frame, it computes a jitter index as `counter % phase_count`. With the query failed, the phase count is still 0 and the title divides by it. Checked against the 1.0.2.1 executable: the field divided by at `+0x28f03e8` is the one the phase-count query writes, and the same object fills the jitter-offset query (`0x1_0005`) with it. **The fix.** When creation fails and DLSS is upscaling, the title gets a stand-in context: - **Queries** are answered as the SDK answers them: the phase count `8 × (display / render)²` (32 for 960 → 1920, never 0), Halton(2, 3) jitter offsets, and zero GPU memory (the title adds up the total it's given). - **Upscale dispatches** go to DLSS. If DLSS refuses one, it goes to the existing plain bilinear upscaling, the same path a context made smaller than asked (`clamped`) uses. - **Nothing reaches the title's DLL with the stand-in handle:** configure, other dispatches and destroy are handled here. - **The failure is logged as an error.** Today the log line reads "made at a size its shipping FSR4 accepts" even when `code=2`. **What doesn't change:** a creation that succeeds, and every path without DLSS. ## How it was tested - GPU and profile: not run on a card. The scenario is #3885's: Series S, 960x540 → 1920x1080, DLSS Performance, RTX 5060 Ti 8 GB. - Before: crash at `+0x28f03e8` (#3885 and #170, the same signature on several versions). - After: the title's queries get a non-zero phase count, so the division is safe. I couldn't run the game, so whether the picture then comes through DLSS needs a run on an affected PC. @⁠yasui-i, could you try this branch? - New tests in `fidelityfx.rs`: - the query layouts at the offsets the title's code uses; - the phase count against the SDK formula (never 0); - the Halton offsets against reference values; - the three queries answered, while unknown queries are refused with their outputs untouched; - a stand-in made and let go. - `cargo clippy -p victory-hle --all-targets --target x86_64-pc-windows-msvc` is clean. `mimalloc`'s C++ build needs the Windows SDK, so for this check it was swapped for a system-allocator stub through `--config patch…`; nothing committed. The pure functions' tests also pass on Linux. - For shader changes, the wave sizes tested: n/a. - `cargo test` passed for the crates it touches: the new tests are Windows-only, like the module, so they run in CI. Not run locally. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: none fixes this. Searched #3885, "phase count", "jitter fidelityfx", "0x28f03e8", "divide by zero", and the FidelityFX PRs (#3857, #3728, #2248, #3011, #2642). `docs/dlss.md` and the `SHIPPING_MAX_*` comment describe the same divide-by-zero for creations that fail at other sizes; this covers the case where the shipping-size creation fails too.
With DLSS taking the upscalings the title's upscaler is made at the size its
shipping FSR4 accepts, but on some PCs that creation still fails: #3885's
play log has `asked_render=[960, 540] asked_output=[1920, 1080]
made_render=[1280, 720] made_output=[1920, 1080] code=2` (Series S, DLSS
Performance, RTX 5060 Ti). The title does not look at the result. It
queries the jitter phase count of the context it believes it has
(`0x1_0004`, writing straight into its object, return code unread), and
that count, left at 0, is the divisor of its per-frame jitter index:
`0xC0000094` at `+0x28f03e8` in the prologue's prestream (#3885, #170).

When the creation fails with DLSS upscaling, the title now gets a stand-in
context. Its queries are answered as the SDK answers them: the phase count
8 * (display / render)^2 (32 for 960 to 1920), Halton(2, 3) offsets, and
no GPU memory (the title adds up the total it is told). Its upscale
dispatches go to DLSS or, refused, to the plain upscaling (as a context
made smaller than asked does: it is `clamped`), and nothing of it reaches
the title's DLL: other dispatches, configurations and destruction are ours.
The failure is logged as an error. A creation that succeeds, and every
path without DLSS, are as before.

The query layouts are the ones the title's code fills (checked against
1.0.2.1's executable). Tests: the layouts, the phase count (never 0) and
Halton offsets against the SDK's values, the three queries answered and
others refused with their outputs left alone, and a stand-in made and let
go. Checked: `cargo clippy -p victory-hle --all-targets` for
x86_64-pc-windows-msvc (mimalloc replaced locally for the check only), the
pure functions and their tests on Linux. Not run on Windows or a card.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 19:57:09 +00:00
github-bot changed title from FidelityFX: a stand-in context where the title's own could not be mad… to FidelityFX: a stand-in context where the title's own could not be made (DLSS on), no divide by zero at the first upscaling (#3885) 2026-11-30 20:02:35 +00:00
github-bot closed this pull request 2026-12-01 18:43:43 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:41 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4409#issuecomment-7321367741) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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/trustno1-coder--VIctory-NVIDIA!4410
No description provided.