Skip to content

Add experimental PC FSR upscaling - #1284

Closed
AwkGrep256 wants to merge 4 commits into
Marvisak:mainfrom
AwkGrep256:pc-fsr
Closed

AwkGrep256 wants to merge 4 commits into
Marvisak:mainfrom
AwkGrep256:pc-fsr

Conversation

@AwkGrep256

@AwkGrep256 AwkGrep256 commented Nov 24, 2026 •

Copy link
Copy Markdown

Adds AMD’s PC FidelityFX upscaler to VIctory’s D3D12 path. Set VICTORY_FFX_DIR to the SDK 2.4 Kits\FidelityFX\signedbin directory to enable it. Series S selects FSR by default. For Series X title 1.0.2.1, use a diagnostics build with VICTORY_UPSCALER=7E93F0 and VICTORY_FFX_SCALE=0.5 for 1080p → 4K.

PC FSR progress

Area Status Evidence
Native Windows context and render scale ✅ Verified Series X creates a 1920×1080 → 3840×2160 context. Series S creates a 1280×720 → 1920×1080 context.
Native Windows upscale dispatch ✅ Verified on RX 9070 XT FSR 4.1.2 accepted in-game dispatches on Series X and Series S. The host uses native RGB9E5 (format=67, packed=false).
Slot 6 fallback ✅ GPU regression passed When the host lacks writable RGB9E5, FSR writes into an FP16 scratch texture. VIctory packs and copies the result back into the title’s RGB9E5 output. A second shader read back the expected HDR colors in the synthetic test.
Windows 10 / RTX 4070 SUPER ⏳ Retest pending Bittertea’s earlier build stopped before SDK dispatch because slot 6 had no host texture. The fallback is in bea3a58 and needs an in-game retest on that setup. Original report · Retest request
In-game image 🔍 First frame measured A native Windows Series S run on the companion branch (#1287), with framegen off, captured the first FSR dispatch and the next present. The input was already nearly black, the FSR output was nearly black, and the presented frame was black. The run reached the 145-second cutoff without a GPU reset.
Windows checks ✅ Passed Workspace tests (343 passed, 6 ignored), both Clippy configurations, asset policy, and the diagnostics GPU regression.

Next I’ll compare later Series S world frames to see whether the lit HDR input ever contains the scene, then trace the passes that write it if it stays dark. The first captured frame establishes where that frame was already dark. Image quality and the RTX fallback still need in-game validation.

Related discussion: #730. Frame generation and first-dispatch capture diagnostics are in #1287.

…(D3D12)

With VICTORY_FFX_DIR pointing at the FidelityFX SDK's signedbin, the five
ffx* exports of amd_fidelityfx_loader_xbox.dll and
amd_fidelityfx_upscaler_xbox.dll are served by AMD's PC loader for D3D12
on the host device. The console structures have the PC layouts; the
backend description, command list and textures are swapped for the
host's, and the list's cached bindings are dropped after the upscaler
records.

The console upscaler only has the fixed 1920x1080 Quality tables, so a
Series X configuration that picks it (3840x2160) fails at context
creation. The PC upscaler takes any size.

Diagnostics: VICTORY_UPSCALER=<rva>[,<kind>] makes the title's upscaler
picker return <kind> (1.0.2.1: 7E93F0, 4 direct calls; 7 is FSR, 6 the
title's own).
…R path

The title's FSR render-size method (1.0.2.1: 28EF680) takes 2/3 on
Series S and 1.0 on Series X, so Series X with FSR forced on renders at
full 4K and overflows its memory plan (a 32 MiB surface in its third
graphics pool, then the transient heap). With VICTORY_FFX_SCALE=0.6667
it renders 2560x1440 and FSR upscales to 3840x2160; 0.5 gives 1080p.

Both scale loads of that method are pointed at our constant in the
padding after it, after checking the code there.
The create-description walk and the render-scale patch are split out so
they can be tested on synthetic data: the upscale description is taken
only beside the console backend description, and both scale loads end
up pointing at the constant, with other code left alone.

README: VICTORY_FFX_DIR under getting started, VICTORY_UPSCALER and
VICTORY_FFX_SCALE in the diagnostics table.
simnJS added a commit to MiamiGame/XTP that referenced this pull request Nov 24, 2026
Series S: BTP 6 runs AMD's FidelityFX upscaler (FSR4), whose console
compute programs XTP cannot translate (20 refused, "no DXIL part"); with
its DLLs refused the title divides by zero at title+0x28f03e8.

xtp-hle `ffx` stands in for amd_fidelityfx_loader_xbox.dll and
amd_fidelityfx_upscaler_xbox.dll unless XTP_FSR4=1. From the title's own
calls (title+0x28ef2cc, +0x28ef30f, +0x28ef625, +0x28f03db, +0x28f0651):
- create (upscale 0x10000 + console backend + version chain): a context;
- query 0x10004: the jitter phase count, 8 x (display / render)^2, 18 for
  720p -> 1080p (the divisor at title+0x28f03e8);
- query 0x10005: AMD's Halton (2, 3) jitter offsets, written into the
  title's uninitialised locals;
- query 0x10008: the upscaler's GPU memory, 0 (the title adds it to a
  memory total, again from uninitialised locals);
- dispatch 0x10001: xtp_gpu::list::upscale, a bilinear compute pass of
  XTP's own from the colour input to the output, the jitter taken back
  as FidelityFX places its samples, clamped to the rendered region.
No AMD code runs.

xtp-gpu list slots 0x1a8/0x1b0, ClearUnorderedAccessViewUint/Float. The
two handles are console descriptor slots holding XTP's view records;
the host gets its own descriptors of the same view: a dynamic slot of
XTP's view heap (bound for the clear) and a CPU-only slot. Texture
views move to unordered access, buffer views write their host copy,
copied back to title memory after the submission. Float clears of raw
and structured buffer views are refused, as the host would (#948's
review).

Outside the task's files, granted by the orchestrator:
- draw.rs: State::forget_host, so the title's pipeline, root signature
  and heaps go back on the host list after the upscale or a clear;
- descriptor/host.rs: make_view (a view into a CPU-only heap) and
  make_at says whether it made the view.
Mechanical: modules/mod.rs, the `ffx` module line and its registration.

Tests: phase count, Halton offsets, the three queries and the create
chain as the title lays them out, a dispatch description read at the
title's offsets; on WARP, the upscale (bilinear, jitter, regions) and
UAV clears of a texture and a buffer through console handles.

Ported from Marvisak/VIctory#1284 (head f96ad82) by AwkGrep256: the
module standing in for both DLLs, its exports, the description layouts,
unknown types logged once. Not taken: its passing on to AMD's PC loader,
the picker and scale patches (Series X diagnostics).
UAV clears after Marvisak/VIctory#948 (head 35802af) by Sakura-Byte,
reimplemented on XTP's descriptors; the handle translation is the idea
of xcl-dev/xcl#1291 (GPL-2.0-only, no code taken).

Co-authored-by: AwkGrep256 <AwkGrep256@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@marquezinii

Copy link
Copy Markdown
Contributor

Native Windows on NVIDIA, without the title. RTX 5070 (Blackwell), driver 621.40, Windows 11 26300, head bea3a58. AMD's signed DLLs from SDK v2.4.0 Kits/FidelityFX/signedbin.

  • cargo test -p victory-gpu --features diagnostics --locked: 55 passed, 1 ignored, including packs_hdr_pixels_into_a_sampleable_rgb9e5_texture.
  • RGB9E5 on this card: the format support query for DXGI_FORMAT_R9G9B9E5_SHAREDEXP gives Support1=0x8013f0, Support2=0x200: no render target, no typed UAV, no typed UAV store. So on NVIDIA the slot 6 fallback is the path that runs, and its test passes here.
  • Context creation: a throwaway test (not pushed) called this branch's ffxCreateContext with the title's chain shape (the upscale description, then the console backend). Series X sizes (1920x1080 → 3840x2160) and Series S sizes (1280x720 → 1920x1080) both return 0 with a context. The loader's version query on this card lists upscalers 3.1.6 and 2.3.4 and no FSR 4, so NVIDIA gets FSR 3.1.6.

Not checked: a dispatch with real inputs, and anything in game; I have no copy of the title.

@AwkGrep256

Copy link
Copy Markdown
Author

Main now does the core of this PR (0b35b7f), so I reworked the parts it doesn't have on top of main's fidelityfx module in #1793: the Series X switches and the RGB9E5 output. Leaving this one open until it's clear which way the maintainer wants it, since #1704 and #1715 are stacked on it.

@marquezinii

Copy link
Copy Markdown
Contributor

@AwkGrep256 thanks for the note. #1704 and #1715 are now rebuilt on main's fidelityfx module and no longer depend on this PR. #1704 routes to DLSS from the same place main routes to AMD's DLL, and it writes the title's RGB9E5 output through an FP16 texture and a packing pass where the host can't store RGB9E5 through a UAV (NVIDIA: the title-shaped test there passes on an RTX 5070). Nothing keeps this one open on our side.

@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Main serves the title's FidelityFX calls with the PC upscaler DLL already (victory-hle modules/fidelityfx.rs, VICTORY_FIDELITYFX_DIR, decision of 2026-11-24).

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
@AwkGrep256

Copy link
Copy Markdown
Author

What was missed: the Series X part. On Series X the title's upscaler picker returns its own upscaler, so VICTORY_FIDELITYFX_DIR alone does nothing there, and with FidelityFX forced on it renders native 4K and overflows its memory plan. #1284's VICTORY_UPSCALER and VICTORY_FFX_SCALE cover that, and main has neither. Closing this is right otherwise. The Series X part is reworked onto main's fidelityfx module in #1793, verified in the title on an RX 9070 XT (FSR 4.1.2, 1080p to 4K, Series X).

AwkGrep256 added a commit to AwkGrep256/VIctory that referenced this pull request Nov 25, 2026
The host FidelityFX path (VICTORY_FIDELITYFX_DIR) only runs when the
title picks FidelityFX, which it does on Series S. Two diagnostics
switches make Series X use it too:

- VICTORY_UPSCALER=<rva>[,<kind>] makes the title's upscaler picker
  return kind (default 7, FidelityFX). In 1.0.2.1 the picker is at
  7E93F0, reached by 4 direct calls; it returns 6 (the title's own
  upscaler) outside Series S.
- VICTORY_FFX_SCALE=<scale>[,<rva>] sets the render scale of that
  path. Its method (1.0.2.1: 28EF680) takes 2/3 on Series S and 1.0 on
  Series X, so Series X with FidelityFX renders at native 4K and
  overflows its memory plan. 0.5 renders 1080p, 0.6667 1440p.

Both check the code first and leave other builds alone: the picker must
have direct calls, the scale method its two vmovss loads and its int3
padding where the constant goes. They live in title_patch.rs with
shared helpers; VirtualProtect failures are reported instead of
ignored.

Reworked from Marvisak#1284 onto main's fidelityfx module.
AwkGrep256 added a commit to AwkGrep256/VIctory that referenced this pull request Nov 25, 2026
The host FidelityFX path (VICTORY_FIDELITYFX_DIR) only runs when the
title picks FidelityFX, which it does on Series S. Two diagnostics
switches make Series X use it too:

- VICTORY_UPSCALER=<rva>[,<kind>] makes the title's upscaler picker
  return kind (default 7, FidelityFX). In 1.0.2.1 the picker is at
  7E93F0, reached by 4 direct calls; it returns 6 (the title's own
  upscaler) outside Series S.
- VICTORY_FFX_SCALE=<scale>[,<rva>] sets the render scale of that
  path. Its method (1.0.2.1: 28EF680) takes 2/3 on Series S and 1.0 on
  Series X, so Series X with FidelityFX renders at native 4K and
  overflows its memory plan. 0.5 renders 1080p, 0.6667 1440p.

Both check the code first and leave other builds alone: the picker must
have direct calls, the scale method its two vmovss loads and its int3
padding where the constant goes. They live in title_patch.rs with
shared helpers; VirtualProtect failures are reported instead of
ignored.

Reworked from Marvisak#1284 onto main's fidelityfx module.
AwkGrep256 added a commit to AwkGrep256/VIctory that referenced this pull request Nov 25, 2026
The host FidelityFX path (VICTORY_FIDELITYFX_DIR) only runs when the
title picks FidelityFX, which it does on Series S. Two diagnostics
switches make Series X use it too:

- VICTORY_UPSCALER=<rva>[,<kind>] makes the title's upscaler picker
  return kind (default 7, FidelityFX). In 1.0.2.1 the picker is at
  7E93F0, reached by 4 direct calls; it returns 6 (the title's own
  upscaler) outside Series S.
- VICTORY_FFX_SCALE=<scale>[,<rva>] sets the render scale of that
  path. Its method (1.0.2.1: 28EF680) takes 2/3 on Series S and 1.0 on
  Series X, so Series X with FidelityFX renders at native 4K and
  overflows its memory plan. 0.5 renders 1080p, 0.6667 1440p.

Both check the code first and leave other builds alone: the picker must
have direct calls, the scale method its two vmovss loads and its int3
padding where the constant goes. They live in title_patch.rs with
shared helpers; VirtualProtect failures are reported instead of
ignored.

Reworked from Marvisak#1284 onto main's fidelityfx module.
AwkGrep256 added a commit to AwkGrep256/victory-fork that referenced this pull request Nov 25, 2026
Port Marvisak/VIctory#1284 (bea3a58) and keep lazy host texture allocation.
AwkGrep256 added a commit to AwkGrep256/VIctory that referenced this pull request Nov 25, 2026
The host FidelityFX path (VICTORY_FIDELITYFX_DIR) only runs when the
title picks FidelityFX, which it does on Series S. Two diagnostics
switches make Series X use it too:

- VICTORY_UPSCALER=<kind> makes the title's upscaler picker return kind
  (7, FidelityFX); on Series X it picks the title's own upscaler.
- VICTORY_FFX_SCALE=<scale> sets the render scale of that path, 1.0 on
  Series X, which with FidelityFX forced on is more than the title's
  memory plan allows. 0.5 renders 1080p for a 4K output.

No title address is kept: each finds its code by a byte pattern, call
and RIP-relative offsets left open, that must match exactly once in the
title's executable sections; a build where it does not is left alone.
In Grand Theft Auto VI 1.0.2.1 each matches once.

The write itself is LoadedImage::write_code in victory-loader
(diagnostics builds only), an unsafe fn for code that has not run yet.
It writes only inside one region VirtualQuery reports as committed,
executable image pages with one protection, so the protection put back
is right for every page; then it restores the protection and flushes the
instruction cache, and reports a failure of either after writing as an
error. No Cargo.toml or Cargo.lock change: the loader already has the
Win32 features.

In the app:
- The patches run first in the diagnostics setup, before the stack
  dump, audio capture, watch and poke threads start, and before the
  title's TLS callbacks and entry point.
- With both switches set, both are found before either is written and
  the scale goes first: the picker alone would render at full size.
  An error after writing, or only the scale taking, stops the launch.

Reworked from Marvisak#1284 onto main's fidelityfx module.
CernyMuzCZ pushed a commit to CernyMuzCZ/vitezstvi-fork that referenced this pull request Nov 25, 2026
Port Marvisak/VIctory#1284 (bea3a58) and keep lazy host texture allocation.
sagouindupm pushed a commit to sagouindupm/Mandy that referenced this pull request Nov 26, 2026
Port Marvisak/VIctory#1284 (bea3a58) and keep lazy host texture allocation.

(cherry picked from commit f2ba7f512fe7bf07a3ae9e68e1bb91909c772441)

Onto feat/render, merged as 12cfac7a did with the Series S stand-in
dispatch: with VICTORY_FFX_DIR set the HLE module serves both FidelityFX
DLLs; without it the plain stretch is bound as before.

Left out: the RGB9E5 output packing (ffx/rgb9e5.rs, the resource.rs
fallback and the render-target guards in draw.rs and list.rs that went
with it). Here an R9G9B9E5 target's host copy is 16-bit float RGBA with
unordered access (resource::target_format), so the upscaler writes the
output directly. README conflict: ours kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RobertAndreiGit

RobertAndreiGit commented Nov 26, 2026 •

Copy link
Copy Markdown

RTX 3060 Ti / Proton, Series S: the PC provider reached a world frame at 720p → 1080p. This was a downstream port of the host FidelityFX path, not a build of this PR head. codec-d/cool_fox base f4b48ad766dd, local temporal commit 4d8e5728a3df. Ryzen 5 5600, 32 GB, 8 GB RTX 3060 Ti, NVIDIA 615.78.08, CachyOS Proton, vkd3d-proton 3.2.0 (2576c0b4adfae4a).

On the console path, twelve timed compute shaders matched the title’s upscaler DLL. Their median combined cost was 309.36 ms/frame, 79% of the 390.8 ms in timed guest commands across 15 world intervals. Instrumentation slowed that build to 712 ms/frame; these numbers should not be subtracted from release frame times.

Both replacement paths passed a synthetic GPU pixel readback under Proton. In release gameplay:

Path Pipeline wait Qualifying world intervals Median frame time Median FPS Draws / dropped without a pipeline
PC temporal, provider 3.1.6 500 ms 15 455.8 ms 2.2 3,560 / 363
Same executable and save 24 ms 15 288.4 ms 3.5 4,376 / 292
Single-pass bilinear comparison 500 ms 6 652.7 ms 1.55 3,561 / 349

Settings: 1080p output, Series S, material cap 512, sparse mips off. On temporal, both the context and first successful dispatch reported 1280×720 → 1920×1080; the output used the fork’s FP16 substitute. The spatial comparison logged one early console fallback and at least 128 successful host dispatches; it exited before the 15-interval target.

The user could follow the action on the console-path visual reference. Pixel readback and dispatch logs establish that the replacements wrote an output; nobody confirmed equivalent world/UI rendering on these runs. The save is not a replay: we used the first 15 intervals with 3,000–6,000 draws/frame and ≤15 pending pipelines. The 3.5 FPS result is a measurement of the combination, not a standalone speedup attributable to this PR.

Follow-up with someone watching the 24 ms temporal configuration: a fresh control reproduced 3.5 FPS / 282.4 ms across 15 qualifying world intervals (3,903 draws/frame; 308 dropped). The player described it as visibly smoother and better overall than the earlier runs, but saw backgrounds load a little later and suspected some shading was missing. The scene was visible; the cause of the shading difference and full visual equivalence remain unverified. Provider 3.1.6 and the first 720p → 1080p dispatch were confirmed again.

@AwkGrep256

Copy link
Copy Markdown
Author

@RobertAndreiGit Thanks for testing this on Proton and sharing the numbers. The successful FSR 3.1.6 dispatch at 720p → 1080p on a 3060 Ti is a useful NVIDIA datapoint. I appreciate you separating the pipeline-wait change from the FSR result.

For anyone following this closed PR, the PC SDK port for fxceless is in #86, and the upstream Series X controls are in #1793. If you have a link to the cool_fox diff, I’d be interested in seeing how you handled the FP16 output.

@RobertAndreiGit

Copy link
Copy Markdown

@AwkGrep256 Thanks! Here’s the exact cool_fox diff and two-frame readback test, based on upstream 0b35b7f.

The RGB9E5 → FP16 allocation was already in the fork. The change on the SDK side is in fidelityfx.rs: just before dispatch we read GetDesc().Format on the actual host texture. If it’s DXGI_FORMAT_R16G16B16A16_FLOAT (10), we set the matching FFX resource description to FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT (4) and pass that texture to the SDK. It writes straight into the FP16 target; there’s no pack-back to RGB9E5 in the bridge.

On the 3060 Ti under Proton, the synthetic test requested RGB9E5, got host format 10, and checked every output pixel against a known colour after two dispatches with provider 3.1.6. The first in-game 720p → 1080p dispatch also reported output format 10.

@AwkGrep256

Copy link
Copy Markdown
Author

@RobertAndreiGit Thanks for sharing the exact diff and the pixel test. I pushed the same host-format check to fxceless #86. When D3D12 gives us an FP16 texture, we now describe it as FP16 to the SDK. The existing packed RGB9E5 path is still there for targets that need it. The descriptor regression and build checks passed. Your Proton readback is the end-to-end evidence we have so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants