d3d12 ffx: AMD FSR 4 upscaler through AMD's PC DLL on RDNA 2-4 (D3D12-FSR4-PC-UPSCALER) #3404
Code
Clone this repository
Checkout
From your project repository, check out a new branch and test the changes.
git fetch -u origin "+refs/pull/3404/head:oreofr/fsr4-pc-upscaler" git switch "oreofr/fsr4-pc-upscaler"
Open
leonida/mandy
OreoFR
wants to merge 1 commit from
oreofr/fsr4-pc-upscaler into main
AGit
pull from: oreofr/fsr4-pc-upscaler
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!3404
Loading…
Reference in a new issue
No description provided.
Delete branch "oreofr/fsr4-pc-upscaler"
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?
This pull request has changes conflicting with the target branch.
Merge manually to resolve the conflicts.
Reviewers 0 approvals
Details
This pull request has changes conflicting with the target branch.
Merge manually to resolve the conflicts.
d3d12/apps/leonida/src/run.rsd3d12/crates/leonida-gpu/src/list.rsd3d12/crates/leonida-hle/src/modules/ffx.rsView 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.Item: D3D12-FSR4-PC-UPSCALER (claimed in #3312).
What and why
On AMD cards the title's Series S upscale (
ffxDispatch) is a plain stretch today (leonida-hle/src/modules/ffx.rs), with no temporal reconstruction. This adds AMD's own PC FSR 4 for it:LEONIDA_UPSCALE=fsr4makesleonida_gpu::list::upscale_nowrecord AMD's signedamd_fidelityfx_upscaler_dx12.dll(FidelityFX SDK v2.4.0) on the host list, in the same place DLSS is recorded, from the title's colour, depth, motion vectors, exposure, jitter, near/far and field of view (the title's upscale already speaks the same public API,ffx_upscale.h).d3d12/crates/leonida-gpu/src/fsr4.rs: loads the DLL (Authenticode checked first, its own folder + System32 only), lists the providers the DLL offers for the device and picks the newest FSR 4.x (FP8 on RDNA 4, INT8 "4.1.2" on RDNA 2/3/3.5), else the newest FSR 3.1.x (pick_provider); one context per (colour size, output size, flags), made with the flags the title gave its own context (note_upscale_create_flagsfromffx.rs's create, debug bits dropped;LEONIDA_FSR4_FLAGSoverrides for A/B). A replaced context is destroyed 16 upscales later, not while lists may still use it.list.rs:Upscalecarriesfsr4and the camera FOV (in word 10, so thin mode carries them too); FSR 4 is tried first, then DLSS, then the stretch.apps/leonida/src/run.rs:LEONIDA_UPSCALE=fsr4takes the dispatch likestretch|dlss.fsr.rs: only visibility (pub(crate)) of the shared FidelityFX structures,dir()andverify_signature(); no behaviour change.scripts/play-nvidia.ps1:-More @{LEONIDA_UPSCALE='fsr4'}setsLEONIDA_FIDELITYFX_DIRand says when the DLL is missing; Series X treatsfsr4likedlss|stretch.Switch and default
Off by default. On only with
LEONIDA_UPSCALE=fsr4, and only on an AMD adapter (vendor 0x1002, from the host device's adapter): on any other vendor, or an unknown one, the DLL is not even looked for (gated, testa_card_that_is_not_amds_falls_back_without_loading). Not auto-enabled on RDNA 2-4: nothing has run in game yet. The card-name check (fsr4_card, RX 6xxx/7xxx/9xxx, 6x0M/7x0M/8x0M, 80x0S) is only logged.NVIDIA unchanged: without
LEONIDA_UPSCALE=fsr4the new branch is never entered (if up.fsr4),dlssandstretchtake the same paths as before; with it on NVIDIA, the vendor gate refuses before loading anything and the upscale is the stretch.Fallback, and the 0xC0000094 report
Missing DLL, bad signature, no provider, refused context: one
FSR 4: ... stays a stretchline in the log, never retried, and the upscale is the stretch (recordreturns false). A refused dispatch: that upscale is a stretch (logged once). Nothing here returns an error to the title or leaves it without its own context.On MoonEyes' 0xC0000094 on AMD: the title divides by its upscaler's jitter phase count when its own (console) context was refused (
ffx.rscreate, title+0x28f03e8). Our PC context is separate and the title never sees it, so its refusal cannot cause that crash. WithLEONIDA_UPSCALE=fsr4the existingffx::createstand-in is bound (as forstretch|dlss), so the title's own context is made at its shipped sizes. Whether MoonEyes' crash is that one (e.g. a run withLEONIDA_UPSCALEunset, where the stand-in is not bound) needs his log; this PR does not claim to fix it.What is fetched
scripts/get-amd-fidelityfx.ps1 -Upscaler(alsoGet-AMD-FidelityFX.cmd -Upscaler) adds, from AMD's own repository at the pinned tag:https://raw.githubusercontent.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/v2.4.0/Kits/FidelityFX/signedbin/amd_fidelityfx_upscaler_dx12.dll6d01d9f52c412fc336350f04e948eb1bee196a38(from the v2.4.0 tree, GitHub API), SHA-256AAD4FCCCCB29084A655F9A4F9F613BD22C8C03FB4A0F8840148CC6543B4CCACE(computed on a copy downloaded once from that URL, outside the repository; it matches Darner's pin), Authenticode valid, signer "Advanced Micro Devices".Without
-Upscalerthe script fetches the same two FSR 3 DLLs as before (the launcher's button is unchanged). No AMD file is in this PR.Credit
After Darner (TrustNo1/Darner, GPL-3.0-or-later) commit 5345be7 by ggwp (
crates/darner-hle/src/modules/fidelityfx/pc.rs,apps/darner/src/play.rsamd_fsr4_card,scripts/get-amd-fsr.ps1), itself adapted from Marvisak/VIctory PR #2751. Darner serves the title's FidelityFX contexts with the PC DLL; here the PC context is ours and sits where DLSS is recorded.Tests (RTX 4070 Laptop, NVIDIA; Windows 11)
cargo test -p leonida-gpu -p leonida-hle -p leonida --locked: all pass (leonida-gpu 737 passed / 59 ignored, leonida-hle 259 passed / 2 ignored, the rest OK). New infsr4.rs: structure layouts against SDK v2.4.0's headers, provider picking, AMD-only gate, card names, creation flags, missing DLL and unsigned DLL refused;list.rswords round-trip withfsr4and FOV.cargo clippy -p leonida-gpu -p leonida-hle -p leonida --all-targets --locked: no warnings.cargo build --profile diag -p leonida: links, no warnings.python -I tests/test_leonida_launcher.py(240 OK, the fetcher's pins,-Upscalerwith a fake DLL keeps nothing),python -I tests/test_d3d12_switches.py(d3d12/docs/switches.mdregenerated:LEONIDA_FSR4_FLAGS,LEONIDA_UPSCALE),python -I tests/test_docs_links.py,python -I scripts/check_no_game_data.pyon the changed files: OK.Needs an AMD RDNA 2/3/4 tester; not run in game. Steps are in
d3d12/README.md, "FSR 4 on AMD cards (experimental)":Get-AMD-FidelityFX.cmd -Upscaler, thenscripts\play-nvidia.ps1 -Log -More @{LEONIDA_UPSCALE='fsr4'}on Series S, and theFSR 4:lines of the log, fps with and without, and screenshots on this PR.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Conflict with #3378 (fitted on
beta)This PR conflicts in code with #3378 (
d72ecd346) ind3d12/crates/leonida-gpu/src/list.rsandd3d12/crates/leonida-hle/src/modules/ffx.rs: both add a field toUpscaleand both take bit 2 ofw[10]in the recorded words (#3378:mv_jittered, this PR:fsr4), and they collide indispatchandcreate.How it was fitted on
beta(mergeab504936d, beta head0d70cf038):w[10]: bit 0 reset, bit 1 DLSS, bit 2mv_jittered(#3378, unchanged), bit 3fsr4(moved from bit 2),fovin bits 32-63 (unchanged).to_words/from_wordsandan_upscale_keeps_its_numbers_through_its_wordsupdated; the test now also checks that turning one of dlss/mv_jittered/fsr4 off leaves the other two and the fov as they were.ffx.rs:dispatchfillsmv_jittered,fsr4andfov;createcalls #3378'snote_context_flags, which now also callsleonida_gpu::list::note_upscale_create_flags, so FSR 4's context gets the title's flags at both points #3378 reads them (before and after the title's own create).INPUT_FLAGS(0x17f) keeps bit 2 (FFX_UPSCALE_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION), so FSR 4 follows the title's jitter flag the same way DLSS/FG do.docs/switches.mdregenerated.Checks on beta:
cargo build --locked --profile diag -p leonida --features diagnostics,dlss,mimallocOK;cargo testof the upscale-words test,fsr4::,fg::,dlss::(with--features dlss) andleonida-hlemodules::ffxOK. Not run in game (no AMD card here).Whichever of #3404 / #3378 merges into
mainsecond needs the same fit (separate bits, one notes-flags path).AI-assisted (Claude Code).