Series S stretch: an opt-in Catmull-Rom sample with contrast-adaptive sharpening (VICTORY_UPSCALE_SHARP; stacked on #188) #1180

Open
github-bot wants to merge 11 commits from github-bot/gh-1180 into main AGit
Owner

@⁠Exopus-0x65f7ad0 on GitHub · 2026-11-25 23:02 UTC · original
Exopus-0x65f7ad0:pr/upscale-sharp → main · +1215 −9 · 9 files · 11 commits · open

Stacked on #188 (its commits come first; the two commits after them are this PR's). Opt-in, so nothing changes without the switch.

Problem

In the Series S profile the title renders at 1280x720 and asks its upscaler for 1920x1080. #188 answers that dispatch with a plain bilinear stretch, and its own comment says so: "an image, not the upscaler's quality". On screen the picture is soft, and fine detail in the distance, through window glass and on posters smears.

Change

VICTORY_UPSCALE_SHARP=<0..1>, off when unset or 0 (#188's bilinear stretch, byte for byte the same pass).

When on, each output texel goes through four steps:

  1. It is a Catmull-Rom (bicubic) sample of the rendered region, taken with nine bilinear taps and kept inside the rendered rectangle as #188 does.
  2. It is clamped to its four source neighbours, so the bicubic lobes do not ring.
  3. It is sharpened by its neighbourhood's contrast, as AMD's CAS does: -1 / lerp(8, 5, SHARP) lobes, scaled down where the neighbourhood already spans the range.
  4. Steps 2-3 run in a reversible tone-mapped space, c / (1 + max(c)) and back, because the colour input is HDR.

The result is never brighter than its brightest neighbour. Without that bound, backlit hair showed bright specks: a value near 1 in tone-mapped space becomes a very large HDR value on the way back.

The shader stays one compute pass. SHARP is a #define set when the pass is created, so the switch costs nothing per frame.

Tested

  • over::tests::the_sharpened_stretch_compiles_and_its_switch_parses: the switch parses and stays in bounds, and both forms (0 and 0.6) compile with FXC cs_5_1. The existing stretch tests still pass.
  • In game, Series S, RTX 5060 Ti 8 GB, Windows 11, fork main d510ee4 plus a stack of open PRs, VICTORY_UPSCALE_SHARP=0.6:
    • first room: frame time unchanged within run-to-run noise (7.8 fps in that run);
    • posters, the window's mesh and brick edges visibly sharper than with the bilinear stretch;
    • no ringing or specks after the bound;
    • opening cutscene close-ups (skin, eyes, hair) clean.

It is still a spatial filter: no temporal accumulation and no use of the depth or motion inputs. #86 / #730 (a real upscaler) remain the better long-term answer. This is a cheap step up from the stretch until then.

No game data in this PR (no captures, hashes, addresses or logs).

🤖 Generated with Claude Code

**@⁠Exopus-0x65f7ad0** on GitHub · 2026-11-25 23:02 UTC · [original](https://github.com/fxceless/victory-fork/pull/1180) `Exopus-0x65f7ad0:pr/upscale-sharp` → `main` · +1215 −9 · 9 files · 11 commits · open **Stacked on #188** (its commits come first; the two commits after them are this PR's). Opt-in, so nothing changes without the switch. ## Problem In the Series S profile the title renders at 1280x720 and asks its upscaler for 1920x1080. #188 answers that dispatch with a plain bilinear stretch, and its own comment says so: "an image, not the upscaler's quality". On screen the picture is soft, and fine detail in the distance, through window glass and on posters smears. ## Change `VICTORY_UPSCALE_SHARP=<0..1>`, off when unset or 0 (#188's bilinear stretch, byte for byte the same pass). When on, each output texel goes through four steps: 1. It is a **Catmull-Rom (bicubic) sample** of the rendered region, taken with nine bilinear taps and kept inside the rendered rectangle as #188 does. 2. It is **clamped to its four source neighbours**, so the bicubic lobes do not ring. 3. It is **sharpened by its neighbourhood's contrast**, as AMD's CAS does: `-1 / lerp(8, 5, SHARP)` lobes, scaled down where the neighbourhood already spans the range. 4. Steps 2-3 run in a **reversible tone-mapped space**, `c / (1 + max(c))` and back, because the colour input is HDR. The result is **never brighter than its brightest neighbour**. Without that bound, backlit hair showed bright specks: a value near 1 in tone-mapped space becomes a very large HDR value on the way back. The shader stays one compute pass. `SHARP` is a `#define` set when the pass is created, so the switch costs nothing per frame. ## Tested - `over::tests::the_sharpened_stretch_compiles_and_its_switch_parses`: the switch parses and stays in bounds, and both forms (0 and 0.6) compile with FXC `cs_5_1`. The existing stretch tests still pass. - In game, Series S, RTX 5060 Ti 8 GB, Windows 11, fork `main` d510ee4 plus a stack of open PRs, `VICTORY_UPSCALE_SHARP=0.6`: - first room: frame time unchanged within run-to-run noise (7.8 fps in that run); - posters, the window's mesh and brick edges visibly sharper than with the bilinear stretch; - no ringing or specks after the bound; - opening cutscene close-ups (skin, eyes, hair) clean. It is still a spatial filter: no temporal accumulation and no use of the depth or motion inputs. #86 / #730 (a real upscaler) remain the better long-term answer. This is a cheap step up from the stretch until then. No game data in this PR (no captures, hashes, addresses or logs). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
No PC GPU renders to R9G9B9E5, so CreateRenderTargetView on such a
target removes the device. Add it to the existing stand-in table, next
to the 16-bit colour formats.

(cherry picked from commit 7dc19f21f1)
(cherry picked from commit 9ba864a83e)
Two passes of ours for the title's Series S mode, in a new module `over`.

A present there has two planes: the game image at 1920x1080 and the
interface at 3840x2160, empty texels zero with alpha zero. Only the first
plane's first resource was shown, so the window was black through the menus
and loading screens. The second plane (its description 0x48 bytes after the
first, laid out the same) is now drawn over the back buffer after the copy
of the first: one triangle, the plane sampled across the whole buffer,
blended by its alpha, taken as premultiplied.

`list::upscale_stretch` records, on a title list, a compute pass that writes
a texture from the bilinear samples of the top-left part of another, then
replays the list's state. It is what the upscale dispatch is given in place
of the console upscaler (next commit).

Measured on an RTX 3050 8 GB, Windows 11: with `--console series-s` the
menus and loading screens are visible at 30 fps where the window was black.
One plane behaves as before. No test yet; planes after the second and a
plane's placement parameters are not read.
In its Series S mode the title renders at 1280x720 and calls the console's
FidelityFX upscaler (`ffxDispatch` of amd_fidelityfx_loader_xbox.dll) to make
the 1920x1080 output. The loader and upscaler are the title's own DLLs and
run, but the upscaler's passes are compute pipelines in a container that is
not translated ("falling back to NewBE" in the title's log), so the output
was never written: the world was black behind the interface.

The executable's import of `ffxDispatch` is now bound to ours. An upscale
dispatch (type 0x10001, the public FidelityFX API's layout) is recorded as
`victory_gpu::list::upscale_stretch` of its colour input into its output;
any other dispatch, and an upscale that could not be stretched, goes to the
title's DLL. The DLL is not registered as an HLE module: that kept the
title's own from loading and left its other three entry points missing.

Measured on an RTX 3050 8 GB, Windows 11, release build, on top of the
R9G9B9E5 stand-in (#32): the Series S world renders (opening cutscene), 0.4
to 1.2 s a frame with peaks of 3 s, the card about a quarter busy, 7 GB of
video memory, no host error in a five-minute run. Series X is not affected
in the run made (it does not dispatch the upscaler).

Not done: temporal accumulation, sharpening, use of the depth and motion
inputs. No test yet. Only the opening cutscene was looked at.
What the review of #188 asked for.

- over.rs: the stretch's groups are 8 by 8 and reach past a target whose
  size is not a multiple of 8; the shader now reads the target's size and
  returns for texels outside it, instead of leaving them to out-of-bounds
  writes being dropped.
- ffx.rs: a dispatch that was neither stretched nor passed to the title's
  own DLL (none found) returned success with the output unwritten. It now
  returns FFX_API_RETURN_ERROR and says so once in the log.
- queue.rs: the choice of a present's second plane is a function of its own
  (`second_plane`), so it can be tested.
- over.rs: a stretch pass that could not be made is tried again at the next
  dispatch, as the pass over a present is; the two view rings say what their
  fixed sizes rest on.

Tests: the typed-format mapping and the stretch's bounds guard
(`over::tests`), the second plane's choice over seven cases
(`queue::plane_tests`), the upscale description's offsets and the
unanswered dispatch (`ffx::tests`).

`cargo test --release -p victory-gpu -p victory-hle`: 113 passed, 0 failed,
1 ignored; 97 passed, 0 failed; `no_dll_planting` 1 passed. One release run
with `--console series-s` on an RTX 3050 8 GB, about 3.5 minutes: both
passes fire, the world renders, no host error.
Under Wine / Proton the system compiler compiles a [RootSignature] attribute
without writing the signature into the shader, so CreateRootSignature on the
shader failed and both passes of over.rs were never made: Series S stayed
black there (reported on #188, Bazzite, RTX 5060 Laptop, vkd3d-proton).

The signatures are now built from descriptions and serialized with
D3D12SerializeRootSignature: a table of the plane and a bilinear sampler for
the pass over a present; four constants, a table of the source and the
target, and the sampler for the stretch. The sources no longer name one.

cargo test --release -p victory-gpu --lib: 114 passed, 0 failed, 1 ignored
(three runs; an earlier run of the whole test binary ended in an access
violation once and did not again). One release run with --console series-s
on an RTX 3050 8 GB, Windows 11, about 3 minutes: both passes fire, menus
and the world render, no host error. Not run under Wine here.
Run the real stretch and overlay passes on a 3 by 2 blue scene and a 5 by 3 synthetic overlay. Read back the output and check every texel for transparent, half-alpha and opaque regions. On the RTX 5060 Laptop under Proton the previous revision fails to record the stretch and the serialized-root revision passes.

Assisted-by: OpenAI Codex (GPT-6.2-Sol)
(cherry picked from commit 76687ee3b125e7b94bd9db12549fd36705e91023)
The title's colour can be the top left of a larger texture. The sampler clamps at the texture's edge, not at the rendered size's, so the last column and row took in texels beside it. The coordinate now stays half a texel inside the rendered size.

Reported with the fix and the measurement by ArturoWolff on #188; the readback test gets a padded source for it (red beside a blue 3 by 2 scene in a 4 by 3 texture: top right was (51,0,204), now blue).
The stand-in for the title's upscaler was a bilinear stretch of the
1280x720 render to 1920x1080: soft, and the distance and glass blurred.
With the switch above 0 each output texel is a bicubic (Catmull-Rom)
sample, clamped to its neighbours, then sharpened as AMD's CAS does, in
a reversible tone-mapped space because the input is HDR. 0 keeps the
bilinear stretch. Both forms compile in a test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:00 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1180'
git switch 'github-bot/gh-1180'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1180'
git switch 'github-bot/gh-1180'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1180'
git switch 'main'
git merge --squash 'github-bot/gh-1180'
git switch 'main'
git merge --ff-only 'github-bot/gh-1180'
git switch 'main'
git merge 'github-bot/gh-1180'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.