FSR 3 frame generation: fix smearing at the screen edges and behind the player's vehicle #588

Open
github-bot wants to merge 2 commits from github-bot/gh-588 into main AGit
Owner

@⁠c0ldpiston on GitHub · 2026-12-05 13:16 UTC · original
c0ldpiston:main → main · +1600 −19 · 14 files · 2 commits · open

Two fixes to the built-in FSR 3.1 frame generator (VICTORY_FIDELITYFX_FRAMEGEN=1, or 4 after it falls back to FSR 3.1). We patch AMD's own interpolation pass, build it from the FidelityFX SDK source and swap it in at runtime. The driver's ML generator (FSR 4, mode 4) is never touched.

Both fixes are on by default once ./setup.sh fsr4 has built the shaders, and each can be turned off on its own.

1. Edge fade (VICTORY_FIDELITYFX_FRAMEGEN_FIX_EDGE)

Near a screen edge, the half-way warp samples outside the frame, so while the camera moves AMD's interpolation smears or inpaints a band along that edge.

patches/fsr3-edge-fade.patch adds ComputeGenerationEdgeFade. Where the warp distance reaches the edge, it blends the generated frame toward the current frame over at most 12 px. A border that isn't moving is left as it is.

  • setup.sh fsr4 fetches the FidelityFX SDK v2.4.0 source once, pinned to a revision. It only needs the api and framegeneration/fsr3 folders. It also fetches the Linux DXC, and tools/build-fsr3-framegen.sh uses both to build fsr4/fg-edge/interpolation.dxil. The build is stamped, so it only runs again when DXC, the SDK revision, the patches or the tools change.
  • framegen::edge hooks the host device up front, because the device is created before the frame-generation DLL loads. When the FSR 3.1 generator is created, the hook finds the DLL's interpolation pass by DXBC checksum and swaps in the patched shader, keeping AMD's root signature.
  • replay/hook.rs moves to crate::hook so release builds can use it too.

2. Vehicle mask (VICTORY_FIDELITYFX_FRAMEGEN_FIX_VEHICLE)

Behind the chase-camera vehicle, the interpolation warps the road the vehicle uncovers and smears or ghosts the vehicle's tail across it, worst while swerving.

framegen::vehicle finds the player's vehicle on each render frame (tools/fsr3-vehicle-mask.hlsl). The title's stencil gives the player's vehicle the same class as traffic (0x42 body, 0x41 person, 0x40 other), so the shader combines that class with what only the player's vehicle has: it stays near the same screen spot, barely moves between real frames, and sits at about the same depth.

Pass What it does
CSNearest Looks at body pixels that move less than 4 px between real frames and picks the one nearest to the chase-camera anchor (horizontal middle, three quarters down the screen), within 15% of the screen height. On foot the character stands there but never seeds, so nothing is marked.
CSMark Seeds the mask with every still body pixel within that reach whose depth is within 25% of the nearest one, which catches all the pieces of a small boat or a scooter.
CSRows / CSColumns Four rounds that grow the mask along connected 0x40 runs with no depth jump over 4% between neighbours. The mask reaches the far end of a yawing vehicle and its rider, but not traffic that touches it on screen.
CSField Feathers the mask 24 px out and hands it to FSR as the distortion field, kept under half a pixel so no lookup moves.

patches/fsr3-vehicle-mask.patch reads the mask in the disocclusion pass and tags pixels the vehicle covers or uncovers. Interpolation shows the current frame on those pixels and blends toward it next to them by distance, so the vehicle's shadow stays with it.

Note: The thresholds above were tuned by hand. They currently remove about 80–90% of the smearing behind the vehicle, and may need more tuning later.

The vehicle patch applies on top of the edge-fade patch. It also has a build without the fade (interpolation-no-edge.dxil), so it works with FIX_EDGE=0. The device is hooked if either fix is on.

Settings

Variable Default Effect of 0
VICTORY_FIDELITYFX_FRAMEGEN_FIX_EDGE on keeps AMD's pass
VICTORY_FIDELITYFX_FRAMEGEN_FIX_VEHICLE on no vehicle mask

Both settings are documented in docs/SETTINGS.md and run.conf.default.

**@⁠c0ldpiston** on GitHub · 2026-12-05 13:16 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/588) `c0ldpiston:main` → `main` · +1600 −19 · 14 files · 2 commits · open Two fixes to the built-in FSR 3.1 frame generator (`VICTORY_FIDELITYFX_FRAMEGEN=1`, or `4` after it falls back to FSR 3.1). We patch AMD's own interpolation pass, build it from the FidelityFX SDK source and swap it in at runtime. The driver's ML generator (FSR 4, mode `4`) is never touched. Both fixes are on by default once `./setup.sh fsr4` has built the shaders, and each can be turned off on its own. ## 1. Edge fade (`VICTORY_FIDELITYFX_FRAMEGEN_FIX_EDGE`) Near a screen edge, the half-way warp samples outside the frame, so while the camera moves AMD's interpolation smears or inpaints a band along that edge. `patches/fsr3-edge-fade.patch` adds `ComputeGenerationEdgeFade`. Where the warp distance reaches the edge, it blends the generated frame toward the current frame over at most 12 px. A border that isn't moving is left as it is. - `setup.sh fsr4` fetches the FidelityFX SDK v2.4.0 source once, pinned to a revision. It only needs the `api` and `framegeneration/fsr3` folders. It also fetches the Linux DXC, and `tools/build-fsr3-framegen.sh` uses both to build `fsr4/fg-edge/interpolation.dxil`. The build is stamped, so it only runs again when DXC, the SDK revision, the patches or the tools change. - `framegen::edge` hooks the host device up front, because the device is created before the frame-generation DLL loads. When the FSR 3.1 generator is created, the hook finds the DLL's interpolation pass by DXBC checksum and swaps in the patched shader, keeping AMD's root signature. - `replay/hook.rs` moves to `crate::hook` so release builds can use it too. ## 2. Vehicle mask (`VICTORY_FIDELITYFX_FRAMEGEN_FIX_VEHICLE`) Behind the chase-camera vehicle, the interpolation warps the road the vehicle uncovers and smears or ghosts the vehicle's tail across it, worst while swerving. `framegen::vehicle` finds the player's vehicle on each render frame (`tools/fsr3-vehicle-mask.hlsl`). The title's stencil gives the player's vehicle the same class as traffic (`0x42` body, `0x41` person, `0x40` other), so the shader combines that class with what only the player's vehicle has: it stays near the same screen spot, barely moves between real frames, and sits at about the same depth. | Pass | What it does | |---|---| | `CSNearest` | Looks at body pixels that move less than 4 px between real frames and picks the one nearest to the chase-camera anchor (horizontal middle, three quarters down the screen), within 15% of the screen height. On foot the character stands there but never seeds, so nothing is marked. | | `CSMark` | Seeds the mask with every still body pixel within that reach whose depth is within 25% of the nearest one, which catches all the pieces of a small boat or a scooter. | | `CSRows` / `CSColumns` | Four rounds that grow the mask along connected `0x40` runs with no depth jump over 4% between neighbours. The mask reaches the far end of a yawing vehicle and its rider, but not traffic that touches it on screen. | | `CSField` | Feathers the mask 24 px out and hands it to FSR as the distortion field, kept under half a pixel so no lookup moves. | `patches/fsr3-vehicle-mask.patch` reads the mask in the disocclusion pass and tags pixels the vehicle covers or uncovers. Interpolation shows the current frame on those pixels and blends toward it next to them by distance, so the vehicle's shadow stays with it. > **Note:** The thresholds above were tuned by hand. They currently remove about 80–90% of the smearing behind the vehicle, and may need more tuning later. The vehicle patch applies on top of the edge-fade patch. It also has a build without the fade (`interpolation-no-edge.dxil`), so it works with `FIX_EDGE=0`. The device is hooked if either fix is on. ## Settings | Variable | Default | Effect of `0` | |---|---|---| | `VICTORY_FIDELITYFX_FRAMEGEN_FIX_EDGE` | on | keeps AMD's pass | | `VICTORY_FIDELITYFX_FRAMEGEN_FIX_VEHICLE` | on | no vehicle mask | Both settings are documented in `docs/SETTINGS.md` and `run.conf.default`.
Near a screen edge the half-way warp samples past the frame and AMD's
interpolation pass smears or inpaints a band there while the camera moves.
patches/fsr3-edge-fade.patch (ComputeGenerationEdgeFade) blends toward the
current frame where the warp distance reaches the edge, over at most 12 px;
a still border is left as it is.

setup.sh fsr4 fetches the FidelityFX SDK v2.4.0 source once, pinned by
revision, and builds the pass with Linux DXC (tools/build-fsr3-framegen.sh)
into fsr4/fg-edge/interpolation.dxil. framegen::edge hooks the host device
on VICTORY_FIDELITYFX_FRAMEGEN=1 or 4 (the device is created before frame
generation's DLL loads), reads the shader when the built-in FSR 3.1
generator is created, and swaps it for the DLL's pass, found by DXBC
checksum, keeping AMD's root signature. The driver's ML generator (FSR 4,
mode 4) has no such band and is created unchanged; when mode 4 falls back
to FSR 3.1, the fade applies.

replay/hook.rs is now crate::hook so it serves release builds too.
VICTORY_FIDELITYFX_FRAMEGEN_FIX_EDGE=0 keeps AMD's pass.
Behind the chase-camera vehicle, AMD's interpolation warps the road the
vehicle uncovers and smears or ghosts its tail across it, worst while
swerving.

framegen::vehicle finds the player's vehicle on the render frame
(tools/fsr3-vehicle-mask.hlsl). The title's stencil (depth plane 1) gives it
the same class as traffic (0x42 a body, 0x41 a person, 0x40 on its own:
signs, poles, a pickup's bed), in every stencil it writes, so the class is
combined with what only the player's vehicle has:

- CSNearest: of the body pixels that move under 4 render pixels between
  real frames, finds the one nearest on screen to where the chase camera
  holds the vehicle (the middle, three quarters down), at most 15% of the
  screen's height away, and packs it with its depth. On foot the
  character stands there and never seeds, so nothing is marked unless a
  vehicle is right there.
- CSMark: seeds the mark with every such still body pixel within that
  reach whose distance from the camera is within 25% of the nearest one's,
  so all pieces of a small boat or a scooter are included.
- CSRows and CSColumns: in four rounds, spread the mark over every run of
  0x40 pixels joined to it with no depth jump over 4% between neighbours.
  That reaches the far end of a yawing vehicle and its rider, but not
  traffic that touches it on screen.
- CSField: feathers the mark 24 px out and hands it to FSR as the
  distortion field, kept under half a pixel so no lookup moves.

patches/fsr3-vehicle-mask.patch reads it in the disocclusion pass and tags
pixels the vehicle covers or uncovers; interpolation shows the current
frame there, and beside it blends toward it by nearness, so the vehicle's
shadow stays with it. Checked in play: cars, bikes, motorbikes, scooters,
jet skis, small and big boats and planes are marked whole, traffic beside
them at junctions is not, and on foot nothing is. Three-minute race
sessions average 14.5 fps both with VICTORY_FIDELITYFX_FRAMEGEN_FIX_VEHICLE=1
and with =0.

tools/build-fsr3-framegen.sh builds these passes into fsr4/fg-vehicle/
beside the edge fade. The vehicle patch applies on top of the edge one;
with VICTORY_NO_EDGE_FADE defined it builds its interpolation pass without
the fade (interpolation-no-edge.dxil), so the vehicle fix also works with
VICTORY_FIDELITYFX_FRAMEGEN_FIX_EDGE=0. The device is hooked if either fix
is on. Like the edge fade, the correction is for the built-in FSR 3.1
generator only, never the driver's ML one.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 13:20:07 +00:00
Author
Owner

@⁠diafebus on GitHub · 2026-12-05 14:51 UTC · original

Tested #588 locally on an RX 6950 XT (RDNA 2), Core Ultra 7 270K Plus, Fedora with Proton-CachyOS 11 and xmem’s patched RADV. The local base was 8bf4878 plus our existing patches, and #596 was enabled alongside #588. FSR 3.1.6 frame generation was on. We tried 2133×1200 and 1920×1080 internal, both upscaled to 3840×2160. The log confirmed that the screen-edge fade and player-vehicle correction were active.

During fast driving, the player’s car visibly updated less often than the scenery around it. The car felt disconnected from the terrain, and the shadows still smeared at speed. I didn’t see a net improvement to driving in this run.

That looks consistent with the mask showing the current rendered car while the surrounding scene keeps interpolating. This is a visual and handling observation. We didn’t instrument physics or do a vehicle-mask-only A/B, so I can’t isolate the cause from this combined run.

**@⁠diafebus** on GitHub · 2026-12-05 14:51 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/588#issuecomment-7439920686) Tested #588 locally on an RX 6950 XT (RDNA 2), Core Ultra 7 270K Plus, Fedora with Proton-CachyOS 11 and xmem’s patched RADV. The local base was `8bf4878` plus our existing patches, and #596 was enabled alongside #588. FSR 3.1.6 frame generation was on. We tried 2133×1200 and 1920×1080 internal, both upscaled to 3840×2160. The log confirmed that the screen-edge fade and player-vehicle correction were active. During fast driving, the player’s car visibly updated less often than the scenery around it. The car felt disconnected from the terrain, and the shadows still smeared at speed. I didn’t see a net improvement to driving in this run. That looks consistent with the mask showing the current rendered car while the surrounding scene keeps interpolating. This is a visual and handling observation. We didn’t instrument physics or do a vehicle-mask-only A/B, so I can’t isolate the cause from this combined run.
Author
Owner

@⁠xstasy on GitHub · 2026-12-05 21:48 UTC · original

The ML framegen on fast speeds have some vignette flickering behind car as well, maybe this could solve that as well?

**@⁠xstasy** on GitHub · 2026-12-05 21:48 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/588#issuecomment-7446025295) The ML framegen on fast speeds have some vignette flickering behind car as well, maybe this could solve that as well?
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/588/head:github-bot/gh-588'
git switch 'github-bot/gh-588'

Merge

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