WIP: fix(fsr4): the tail is written before its reader also when the unrolled shader arrives between bind and dispatch #1163
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1163
Loading…
Reference in a new issue
No description provided.
Delete branch "TrashPanda/Longshot:fix/fsr4-tail-order"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: fix · Risk: low · Tested on: Linux, RTX 4070 Ti (game-free checks) · Needs: AMD RDNA 4 with FSR 4
Why
With AMD FSR 4's shader tuning, a tuned pipeline published between bind and dispatch could run once on weight tables not written yet, a frame of wrong upscaling on RDNA 4.
Restored from Hookshot 2952, by jarynclouatre, and split out of #287 so it can be reviewed and merged on its own.
What changed
cmd_dispatchingpu/vk/vk_fsr4.cppdecides from what the bind put in place (struct Bind), not from the published pipeline at dispatch time.Commits, each with its original author and message:
0ae73075fix(fsr4): the tail is written before its reader also when the unrolled shader arrives between bind and dispatch (jarynclouatre)With AMD FSR 4's shader tuning (https://github.com/NotRexed/Hookshot/pull/2798), a tuned pipeline reads its
weight tables from a tail at the end of the library's storage buffer,
and
tune::cmd_dispatchwrites that tail before the first dispatch thatreads it. The unrolled pipeline is built by a background job and
published into
betterfrom its own thread.cmd_bind_pipelinebindsthe library's pipeline when no unrolled one exists yet, but
cmd_dispatchaskedbetteragain at dispatch time. When the jobpublished between the two, the dispatch took the unrolled pipeline as
bound: it skipped the tail's upload (
duestayed set) and the fallbackto AMD's own pipeline, while the tail-reading pipeline ran once on a
tail not written yet.
Change
boundkeeps, per command buffer, the library's pipeline and whetherthe bind put the unrolled one in its place (
struct Bind).cmd_dispatchdecides from that, not frombetterat dispatch time.The twin path still gets the library's pipeline from it. No lock is held
across a driver call that was not held before.
Testing
tests/test_fsr4_bind_dispatch.py(new): cutscmd_bind_pipeline,cmd_dispatchand the structs they use out ofvk_fsr4.cppand runsthem against recording stand-ins for the driver's calls, with no GPU and
no
spirv-val. Three cases: the library's pipeline bound and theunrolled one published before the dispatch (the tail is written and
duecleared); the unrolled one bound (no tail written); a tail thatcannot be read with the unrolled one published in between (AMD's own
pipeline is bound). The first and third fail on main and pass here.
HOOKSHOT_FSR=1:vk_fsr4.cppcompiles.(
test_bake_portability:zstandard;nx2/test_texture_init_barrier.py:clang++); both fail the same onmain.
Restored-from: https://github.com/NotRexed/Hookshot/pull/2952
Measurements
Verdict: nothing to measure: a correctness fix off the frame path, covered by game-free checks.
Flags and settings
None.
Testing
Tested: On Linux (kernel 7.0), RTX 4070 Ti,
main@71b1edd8, this PR @0ae73075:the checks that read the changed files (tests/run_all.py --changed origin/main)pass. The full suite (tests/run_all.py) has not been run on this branch yet; a comment will follow when it has.Not tested: An RDNA 4 card. Opened as work in progress until it runs in the game.
Must be tested:
Risks
What could break: FSR 4 on RDNA 4.
Turning it off: revert the commit.
Compatibility: Nothing changes.
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why. Not ticked yet: The in-game run never reached the changed FSR 4 path, which needs an RDNA 4 card.
in Risks.
main.third_party/untouched (a new folder with aPROVENANCE.mdinstead).python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).When it applies
mainand passing here.Tested in game: Linux (Ubuntu 26.04.1, kernel 7.0.0-43), RTX 4070 Ti 12 GB, NVIDIA 595.99.02, Ryzen 7 9800X3D: this branch built together with the other 18 split from #218 and #284-#288, merged onto main @
71b1edd8(make_game.py --update, build v3.0.0-rc.5-82-g5952bb3d), then played by a scripted tour through the control bridge (scripts/memtour.py: a save loaded, Zora's Domain, the Market, Hyrule Field and Death Mountain Trail, 40 s each with walking and camera swings). All 4 stops reached, a clean quit, and no device loss or Vulkan error in the log. FSR 4 does not run on this NVIDIA card, so the changed path did not run; it needs an RDNA 4 card.Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).
**Not testable by hand:**line saying why and what stands in for it. Then tick it.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.