feat(vk): FSR 4 model selection for FSR SDK 2.4's upscaler library, named by its SHA-256 #2331
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2331
Loading…
Reference in a new issue
No description provided.
Delete branch "roblesleo/Longshot:fsr4-known-library"
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?
What this does
#1989 added the FSR 4 model row and its scanner, and shipped them switched off for two reasons stated in the code:
This PR turns the row on for exactly one file, and answers both points:
amd_fidelityfx_upscaler_vk.dll(4.1.2.4555), by the hashscripts/fetch.pyalready pins (4a7e895a…bdab7).fsr4_models.cppkeeps it in a one-row table,kKnown. A newer AMD file is Auto only until someone reads its layout and adds its hash.load_knownhashes the file beside AMD's loader and, only for that hash, loads it from that full path before the loader asks for the name, pins it, hashes the module's own file again, and scans it. After the loader has listed its upscalers,known_module_is_loaderschecks that the module under that name is still the one that was checked. If not,release()makes the hook answer as AMD does.Any other file is neither loaded nor scanned here: Auto, with the row hidden, as today.
scan_loaded_modules()stays disabled.installrefuses anything that is not a row ofkKnown, a shape that is not understood, a second install, or a slot that no longer holds what the scan read. It acquires write access to every slot before writing onlyvtable[2](IsSupported); if it cannot restore protection afterward, the hooks answer as AMD does.A second part you may want to drop: Lite stands in where AMD lists no FSR 4
By default, where AMD's library lists no FSR 4 model for the GPU (another maker's GPU, or a Radeon AMD names for none) and the Lite provider is hooked,
loadasks the list again with Lite answering. If FSR 4 is listed then, every context runs on Lite: FSR 4 is offered, the model row is not shown (there is nothing to choose), AMD's own shaders run, and the log saysINT8 Lite stands in.RX_VK_FSR4_STANDIN=0leaves FSR 4 off there, as it was. This goes past the AMD-only gate #1989 chose, so I kept it apart in the code: it is thestandin_allowedblock infsr4::load,g_standin, and the threestandinlines inmake_context. Say the word and I will send the hook without it.Tested
tests/fsr4_models_test.cpp: new cases for the SHA-256 (three known vectors), the known table, the refusals ofinstall, including write-access acquisition failures (slots left unchanged), Auto and Lite answers, and the answers afterrelease(). Passes, also with-Wall -Wextra -Werror.tests/test_switch_table.pypasses with the new switch.3.1.6, 2.3.4to4.1.2, 3.1.6, 2.3.4;FSR 4.1.2 made for outputs of 1536x864, its own 60 MB; it draws 1152x648 -> 1536x864 for a whole 170 s run in Castle Town at about 60 fps (GPU about 8 ms a frame), picture clean. Two runs.Not tested
RX_VK_FSR4_MODEL=litebefore this merges.load_knownreturns nothing there).🤖 Generated with Claude Code
A note on the
risk/highlabel, to make the scope of the hook explicit:amd_fidelityfx_upscaler_vk.dllon disk stays byte-identical. Its SHA-256 is checked before it is loaded, and the loaded module's own file is hashed again afterwards.vtable[2](IsSupported), four in total, in this process's copy of the module. Nothing else in the image is touched, and nothing persists after the game closes.kKnown, a vtable shape that is not understood, a slot that no longer holds what the scan read, or a loader that ends up using another copy of the module. In each case nothing is written, or the hook answers as AMD does.So the risk is confined to one known file, and a new AMD release is plain Auto until someone reads its layout and adds its hash.
One thing I cannot cover: I have no AMD GPU. If someone with a Radeon that runs FSR 4 could try
RX_VK_FSR4_MODEL=liteon this branch and post thevk: AMD FSR 4:log lines, that would test the Auto / Lite row itself.@review
Recommendation: Approve. A partial hook can report Lite as available while leaving another provider able to win selection, and the AMD model-selection path remains untested in game. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
The change enables FSR 4 Lite model selection for one identified Windows DLL and offers Lite on GPUs AMD does not list. It adds a private-ABI hook and an enabled-by-default fallback, with hardware coverage and performance costs still to establish.
Should fix (2): not blocking, but worth doing before merging.
gpu/vk/fsr4_models.cpp:634: A failure to make one vtable writable is skipped, but installation still succeeds if any other provider was patched. (more on the line) Do: Make installation all-or-nothing: acquire writable access for every required slot before publishing any hook, and restore or release all hooks if any step fails. Test a failure at each provider.gpu/vk/vk_fsr4.cpp:1154: The new boolean switch uses numeric parsing, so documented boolean on-values are interpreted as off. (more on the line) Do: Read the switch with the repository's default-on boolean parser and cover its accepted on and off values.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_fsr4.cpp:1216: The Radeon Auto and Lite paths have not been exercised in game. (more on the line) Do: Run Auto and Lite on supported Windows Radeon hardware, switch between them in game, and check output, context creation and fallback.gpu/vk/vk_fsr4.cpp:1155: The enabled stand-in has only been run on one RTX laptop, with no comparison against the base or the disabled setting. (more on the line) Do: Compare base, stand-in enabled and disabled in the same scene and settings with repeated runs, including frame times and image quality; exercise representative affected NVIDIA, Intel and unlisted Radeon hardware.@fixcan do L1 and L2.Questions (1) (not confirmed from the code; they don't hold the recommendation)
gpu/vk/vk_fsr4.cpp:1155: Does AMD's library return a successful zero-count query for a GPU on which the Lite retry would list FSR 4?Checks: Failing on this head, which is behind its base, where it passes:
PR description / Description follows the template (pull_request_target).@rebase(or@fix) brings it up to date and runs it again; not held against it. Still running: 10 checks.More: does it help, other systems, switches, what was read
Does it help: Unproven for the model-selection feature: the author reports two 170-second Windows RTX 3060 Laptop runs with the stand-in, about 60 fps and 8 ms GPU time, but no Radeon run. There is no comparable base-versus-head measurement of the enabled default or its cost.
Other systems: The hook runs on Windows with the pinned AMD DLL; Linux remains on AMD's selection. Radeon model selection, other NVIDIA generations, Intel GPUs, older Radeon GPUs, HDR and context failure paths need coverage. The stand-in can also change which upscalers are offered and selected.
Switches: RX_VK_FSR4_STANDIN is added, on by default; 0 disables the stand-in. Its default has only one GPU's game-run evidence and no comparative measurements. RX_VK_FSR4_MODEL is unchanged, but its Lite choice becomes effective on supported Windows Radeon configurations.
Reviewed:
5cf57b68d6against02c5952ca3: Read AGENTS.md, CONTRIBUTING.md, the PR template, relevant standards, the changed model and integration code, the model test and test runner, and the diffs for all changed documentation and the switch table. Traced context creation, dispatch, version queries and switch parsing. The requested docs/review-checklist.md and sibling Tooling checkout were absent. The large switch table and unrelated portions of vk_fsr4.cpp were skimmed; no generated files or recorded runs were changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, tests or project scripts were run. The author reports synthetic tests and two Windows RTX stand-in runs. Several CI checks remain running.
Overlaps and merge order: Not checked: network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -439,0 +631,4 @@for (const Provider& p : result.providers) {#ifdef _WIN32DWORD before = 0;if (!VirtualProtect(&p.vtable[2], sizeof(void*), PAGE_READWRITE, &before)) continue;L1 (should fix): A failure to make one vtable writable is skipped, but installation still succeeds if any other provider was patched.
When: If protection fails for an earlier supported provider but succeeds for Lite, has_model(Lite) exposes the choice; when Lite is selected the unpatched provider can still answer yes first, so AMD selects it instead of Lite.
Do: Make installation all-or-nothing: acquire writable access for every required slot before publishing any hook, and restore or release all hooks if any step fails. Test a failure at each provider.
@ -1148,0 +1151,4 @@pick_newest();// (no FSR 4 for this GPU in AMD's own list: a GPU of another maker, or a Radeon AMD names for no model. Where the Lite// provider is hooked it stands in, and the list is asked again with it answering. RX_VK_FSR4_STANDIN=0 leaves this out)static const bool standin_allowed = env_switch("RX_VK_FSR4_STANDIN") != 0;L2 (should fix): The new boolean switch uses numeric parsing, so documented boolean on-values are interpreted as off.
When: RX_VK_FSR4_STANDIN=true or on passes through atoi as zero and disables the stand-in, despite the switch table declaring a boolean.
Do: Read the switch with the repository's default-on boolean parser and cover its accepted on and off values.
@ -1148,0 +1152,4 @@// (no FSR 4 for this GPU in AMD's own list: a GPU of another maker, or a Radeon AMD names for no model. Where the Lite// provider is hooked it stands in, and the list is asked again with it answering. RX_VK_FSR4_STANDIN=0 leaves this out)static const bool standin_allowed = env_switch("RX_VK_FSR4_STANDIN") != 0;if (!l.version_id && standin_allowed && fsr4_models::hook_installed() && fsr4_models::has_model(fsr4_models::MODEL_LITE)) {L4 (should fix): The enabled stand-in has only been run on one RTX laptop, with no comparison against the base or the disabled setting.
When: The default offers an unsupported-by-AMD model across NVIDIA, Intel and unlisted Radeon devices; its picture, frame pacing and cost on those devices are not established by the single RTX configuration.
Do: Compare base, stand-in enabled and disabled in the same scene and settings with repeated runs, including frame times and image quality; exercise representative affected NVIDIA, Intel and unlisted Radeon hardware.
@ -1185,2 +1214,3 @@c->effective = effective;const bool suppress = effective == FSR4_MODEL_LITE && fsr4_models::native_model() != fsr4_models::MODEL_LITE;const bool lite = effective == FSR4_MODEL_LITE || standin;const bool suppress = lite && fsr4_models::native_model() != fsr4_models::MODEL_LITE;L3 (should fix): The Radeon Auto and Lite paths have not been exercised in game.
When: On a supported Radeon, changing the row creates a context using the patched private provider interface and may also change shader tuning; the supplied RTX stand-in run does not exercise that path.
Do: Run Auto and Lite on supported Windows Radeon hardware, switch between them in game, and check output, context creation and fallback.
@fix
5cf57b68d60182e1de2cRecommendation: Approve. The code is ready: only testing is left. The hook and default-on stand-in still need the Radeon and comparative hardware runs identified in the ledger. The reported RTX run shows the stand-in working on one laptop, but does not establish its cost or behavior across the affected systems. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
0182e1de2c. I rebased it ontomain(79d192c655). I edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
The change enables FSR 4 model selection for one identified AMD library and offers Lite as a stand-in on GPUs for which AMD lists no FSR 4 model. The fix makes hook installation acquire write access before patching and makes the stand-in switch default on.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_fsr4.cpp:1216: The Radeon Auto and Lite paths have not been exercised in game. When: On a supported Radeon, changing the row creates a context using the patched private provider interface and may also change shader tuning; the supplied RTX stand-in run does not exercise that path. Do: Run Auto and Lite on supported Windows Radeon hardware, switch between them in game, and check output, context creation and fallback.gpu/vk/vk_fsr4.cpp:1155: The enabled stand-in has only been run on one RTX laptop, with no comparison against the base or the disabled setting. When: The default offers an unsupported-by-AMD model across NVIDIA, Intel and unlisted Radeon devices; its picture, frame pacing and cost on those devices are not established by the single RTX configuration. Do: Compare base, stand-in enabled and disabled in the same scene and settings with repeated runs, including frame times and image quality; exercise representative affected NVIDIA, Intel and unlisted Radeon hardware.Checks: they run again on this head (
PR description / Description follows the template (pull_request_target)failed on the last one); a failure shows on the pull request.More: does it help, other systems, switches, what was read
Does it help: Unproven across the affected hardware. The author reports two Windows RTX 3060 Laptop runs with a clean picture at about 60 fps and 8 ms GPU time, but no comparison against the base or the disabled stand-in; Radeon Auto and Lite have not been exercised in game.
Other systems: The provider hook is Windows-only; Linux retains the existing path. Radeon Auto and Lite and the default-on stand-in on other supported GPUs still need the runs in the ledger.
Switches: RX_VK_FSR4_STANDIN is added, default on; 0 disables the stand-in. The available measurements do not yet establish that this default is right across affected GPUs. RX_VK_FSR4_MODEL selects Auto or Lite where the model row is available.
Reviewed:
0182e1de2cagainst79d192c655: Read the repository rules, PR template, standards, fix diff, hook installation and release code, and the FSR 4 load and context paths. Skimmed the remaining changed code, tests, documentation and broader base diff; the full base diff includes many changes beyond the listed PR files. The review checklist file is absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The author reports unit and switch-table checks passing before the fix; the fix report says its new tests were not run, and CI has not yet run on this head.
Overlaps and merge order: Not determined from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.