Shaders: translate the title's FidelityFX upscaler programs (FSPX images) #258

Open
github-bot wants to merge 9 commits from github-bot/gh-258 into main AGit
Owner

@⁠Ortomanic on GitHub · 2026-11-24 23:01 UTC · original
Ortomanic:fx/fspx-upscaler → main · +721 −32 · 11 files · 9 commits · open

Changes

The title's FidelityFX upscaler keeps its compute programs in FSPX images inside the container, with no DXIL part. They failed with malformed shader: no DXIL part and their dispatches were dropped, so the upscaled scene was never written.

  • First commit: an FSPX image is read as a native program (victory_shader::program_part, new fspx.rs).
  • The other eight commits are the instructions and descriptor forms those programs use that did not lower yet: v_dot4_* as Dot4AddPacked, v_pk_fmac_f16, src_scc as an operand, s_bfm_b32/s_mov_b64 literals in descriptor constants, image atomics with 16-bit coordinates, partial-channel image stores, raw views of a loaded buffer descriptor, and v_readlane_b32 at constant lanes after a whole-wave section.

Programs outside the upscaler are not affected by the first commit. This is the title's own upscaler running as translated code, so it is independent of #86 (a PC FSR path) and of #188 (a plain stretch for the dispatch); either can sit beside it.

Validation

  • CachyOS, Wine 11.22, vkd3d-proton 3.1.r64, RTX 5080 (32-lane waves).
  • In the title, before: 20 compute programs logged no DXIL part. After: none, and the upscaler's dispatches run.
  • Offline over the shader pack on a 32-lane host: of the 29 FSPX programs, 23 translate on plain upstream ffe310e with this series; all that translate convert with dxil-spirv. On this fork three more still refuse on a 32-lane host because they need a 64-lane form.
  • On NVIDIA the upscaler's output texture is an R9G9B9E5 render target with unordered access, which the host refuses; the picture only appears together with #32. With both, the lit world frame is shown through the title's own upscale.
  • cargo clippy --workspace --all-targets --locked -- -D warnings for the Windows target, with and without --all-features, and cargo test -p victory-shader -p xtask pass on this branch (cross-compiled from Linux with the pinned toolchain). Four unit tests are added.
  • Not run on Windows or on AMD.

AI-assisted patch with local build and runtime validation.

**@⁠Ortomanic** on GitHub · 2026-11-24 23:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/258) `Ortomanic:fx/fspx-upscaler` → `main` · +721 −32 · 11 files · 9 commits · open ## Changes The title's FidelityFX upscaler keeps its compute programs in `FSPX` images inside the container, with no `DXIL` part. They failed with `malformed shader: no DXIL part` and their dispatches were dropped, so the upscaled scene was never written. - First commit: an `FSPX` image is read as a native program (`victory_shader::program_part`, new `fspx.rs`). - The other eight commits are the instructions and descriptor forms those programs use that did not lower yet: `v_dot4_*` as `Dot4AddPacked`, `v_pk_fmac_f16`, `src_scc` as an operand, `s_bfm_b32`/`s_mov_b64` literals in descriptor constants, image atomics with 16-bit coordinates, partial-channel image stores, raw views of a loaded buffer descriptor, and `v_readlane_b32` at constant lanes after a whole-wave section. Programs outside the upscaler are not affected by the first commit. This is the title's own upscaler running as translated code, so it is independent of #86 (a PC FSR path) and of #188 (a plain stretch for the dispatch); either can sit beside it. ## Validation - CachyOS, Wine 11.22, vkd3d-proton 3.1.r64, RTX 5080 (32-lane waves). - In the title, before: 20 compute programs logged `no DXIL part`. After: none, and the upscaler's dispatches run. - Offline over the shader pack on a 32-lane host: of the 29 `FSPX` programs, 23 translate on plain upstream `ffe310e` with this series; all that translate convert with dxil-spirv. On this fork three more still refuse on a 32-lane host because they need a 64-lane form. - On NVIDIA the upscaler's output texture is an R9G9B9E5 render target with unordered access, which the host refuses; the picture only appears together with #32. With both, the lit world frame is shown through the title's own upscale. - `cargo clippy --workspace --all-targets --locked -- -D warnings` for the Windows target, with and without `--all-features`, and `cargo test -p victory-shader -p xtask` pass on this branch (cross-compiled from Linux with the pinned toolchain). Four unit tests are added. - Not run on Windows or on AMD. AI-assisted patch with local build and runtime validation.
The upscaler's containers have no DXIL part: an ACCC part holds an FSPX
image. Its kind 0 section gives the thread-group size, wave size and
COMPUTE_PGM_RSRC1/2; kind 6 the GFX10 code, uncompressed; kind 7 the
bindings (resource and root type, table offset, register, descriptor
dwords, user-data dword, root slot), from which the used resources and
the root layout follow. Immediate samplers take no user SGPRs: the code
builds their words itself.

program_part() picks a container's DXIL part, else its ACCC part, and
native_programs() reads an FSPX image where it finds one; translate(),
victory-gpu's pipelines and the shader and translate listings use them.

(cherry picked from commit 6c43bda432578fad4897f44e8400f7e2398a549c)
The FidelityFX upscaler's programs clear a loaded buffer descriptor's
stride, multiply its record count into bytes and set its out-of-bounds
mode before byte-addressed access. The base address and everything else
stay as loaded, so it is traced as the loaded descriptor; the host reads
the buffer raw through its view. A moved base address is still another
buffer.

(cherry picked from commit 474a49135871f92be3296c7213b85685a9e0baee)
The FidelityFX upscaler's int8 network layers accumulate with them. DXIL
has the same operations: Dot4AddI8Packed and Dot4AddU8Packed (163, 164),
with the accumulator as their first operand; v_dot4c_i32_i8 accumulates
into its destination.

(cherry picked from commit d44f7518f271479cd9f27d562bae6c4b8b7b2dd6)
src_scc reads the scalar condition as 0 or 1. The SCC a lane-mask
operation leaves (whether its result has a lane set) is whether that
mask's ballot is not zero, computed only where it is read (s_cselect on
it, say).

(cherry picked from commit b2312eb27d1afb986ccd3e261dcb36b9f736e2c0)
A wave64 reduction that joins its halves with lane 31's value is read
from lane 63 after EXEC is restored: those reads pick one lane of the
section's partial result, so they are folded into the section.

(cherry picked from commit e04ee827c53b6a8ba2a6e88f63a2063f21ae865e)
The VOP2 form has no op_sel: each half reads its own half of the
sources, and the destination's is the addend.

(cherry picked from commit 985c35654d70be389d038cb906ba36bedea58ea3)
The FidelityFX upscaler builds its static sampler's words in the code
(s_movk_i32, s_bfm_b32, s_mov_b64 of a literal). A bit field of constant
width and offset is a constant; a 64-bit move of a literal below 2^31 is
the literal and 0 (zero and sign extension agree there).

(cherry picked from commit e123f48b32d6f0bda1f6375607247a14cacc0a91)
With a16 the coordinates are 16-bit integers, two per VGPR, unpacked as
for image loads (the FidelityFX upscaler's single-pass reduction counts
its groups so). 16-bit data still has no atomic form.

(cherry picked from commit e1f27dfeaec4701295525247d820565581533dc1)
DXIL's typed stores write all four channels; the console's image_store
writes those of its dmask, its data packed in channel order (d16: two
per VGPR). The others are read from the texel first (a typed UAV load,
as our image loads of UAVs are) and stored back unchanged, which is
right whatever the view's format. Unlike the console's masked write, it
races with other lanes' stores to those channels of the same texel.
A store of all four channels reads nothing.

(cherry picked from commit 57b302bf6f2612d85cb39ae0cfdc39bd07121766)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:39:23 +00:00
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/258/head:github-bot/gh-258'
git switch 'github-bot/gh-258'

Merge

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