Run FSR 3.1 on the frame chain FSR 4.1 uses #1096
Closed
N3oTraX wants to merge 14 commits from
fsr3/backend into main
pull from: fsr3/backend
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2756
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!1096
Loading…
Reference in a new issue
No description provided.
Delete branch "fsr3/backend"
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?
Part 2 of 3 of the split of #871. Adds FSR 3.1 as a second engine on the frame chain from #1008, so cards and systems without FSR 4 still get a temporal upscaler.
The branch merges cleanly on current
main. It carries one merge of #1008, whose conflict with #946 invk_menu.cppis resolved by keeping both sides (kMenuWidth = menu_hit::kWidthand #1008'shelp_of).What changed
gpu/vk/vk_fsr3.cppand.h: FSR 3.1's images, pipelines and nine dispatches. Three commits are notquiteog's, from #822.gpu/vk/upscale_engine.h: the choice between Off, Auto, FSR 4.1 and FSR 3.1, as plain data thattests/upscale_engine_test.cppchecks without a game or a GPU. Auto takes FSR 4.1 when AMD's library is present with a model for the card, else FSR 3.1, else the game's upscale. If FSR 4.1 fails in play, FSR 3.1 takes over.RX_FSR4=0/1andfsr4=still read as Off and Auto. New:RX_UPSCALER=off|auto|fsr4|fsr3andupscaler=.Known limit until part 3: the menu row is still
AMD FSR 4.1, whose On now means Auto. Without AMD's library FSR 3.1 runs while the row says no FSR 4 was found. Part 3 replaces the row.Left out on purpose from #821 and #822, because none of it is on the tested path: the input contract, the seam, the census, the camera hooks and
HOS_FPS_FORCE.How it was tested
e0f3ccfa, Ultrawide on6095c4d)5120x2160 -> 5120x2160, switched live several times, no crash or device lost in the log.vk_fsr3.cpp,vk_fsr4.cppand the selection code are unchanged from that treehookshot_vk.sobuilds with 0 warnings.tests/run_all.py fsr upscale menu: 8 passedThat run used
RX_VK_NO_WARM=1,RX_VK_NO_PREDICT=1andRX_VK_PRECOMPILE=0because of #803, andRX_VK_ANISO=16.Not tested
🤖 Generated with Claude Code
Hi! This PR has merge conflicts with
mainnow (a lot has landed today). Could you mergemainin or rebase and resolve them? Happy to give it a proper review once it's up to date.I will rebase all PR
Thanks for splitting #871 up. I reviewed only this PR's own commits (
6de9239..1bbdb02:vk_fsr3.cpp/.h,upscale_engine.h, and thevk_draw.cpp/vk_menu.cpp/vk_fsr4.cppglue). I didn't re-review #1095 or #1008.The FSR 3.1 backend itself looks solid. I checked every pass's binding list against the
FSR3UPSCALER_BIND_*defines in #1095's GLSL and they all match. The storage formats match the shaders' qualifiers, the luma-history rgba8 note is right, and the UNDEFINED to GENERAL transition plus the clears on a new image set are fine. So are the per-pass compute barriers, the depth-to-view constants, the horizontaltanHalfFOV, and jitter in render pixels with jitter-free motion (motion_vector_jitter_cancellation= 0). Thewave/_nowavepick is a nice touch.The main problem is that #1008 has been rebuilt since, so almost all of the glue here now targets code that no longer exists.
dlss_dispatch,FsrJitter,fsr_on()and the viewport jitter are gone. #1008 now has aTemporalEngine(vk_temporal.h) and the chain invk_temporal.cpp, with jitter on the host side (nx2/oot_jitter.py). That's why this PR conflicts. Here's what I think has to change to fit it:const TemporalEngine* fsr3_engine()next tofsr4_engine(), built fromstart/prepare/evaluate/release/memory, and drop all thevk_draw.cppchanges (fsr_engine(),fsr3_evaluate,fj.engine, theoutput_view()branch). The chain already starts a new history when the engine changes (s.drawing != engine.ecallsrelease()and setslast_frame = 0), so the engine-switch reset here isn't needed.prepare(cmd, rw, rh, ow, oh, &in_w, &in_h, &why). The chain's inputs arein_w x in_hwith the frame in the top-left corner, and the render size can change under them. Allocate the render-size images at the maximum render size (set*in_w = ow, *in_h = ohlike FSR 4, or pick your own maximum). Put that size inmax_render_sizeand giverender_size = f.render_w/hper frame. Todaymax_render_sizeis always the current render size, and any size change rebuilds and retires everything (see inline). Return 2 when the images are (re)made and -1 for a hard failure.evaluate(cmd, f). WriteUPSCALED_OUTPUTintof.output.view(RGBA16F atdw x dh) and removeg.output,output_image()andoutput_view(); the chain'sdlss_out.compcopies it into the game's target. Usef.jitteras it is (same convention as FSR 4'sjitterOffset). Take near, far and fov fromf.near_z/far_z/fov_y, since the chain already gets them from the projection, socamera_from_view_projectionand its test can go. Takemotion_vector_scalefromf.render_w/h. Leave the inputs in GENERAL. FSR_AA (dw = rw) should work as is.release()andmemory(). Hand the images (and, on a final release, the pipelines) totemporal_later()in place of theg_retiredlist counted bytexture_frame_no(). The chain then frees FSR 3.1's VRAM when it goes idle (temporal_idle) or another engine takes over. Right now nothing frees it (see inline).opts.upscaler, withupscaler_rows.hvalues GAME / DLSS / DLAA / FSR / FSR_AA, saved asdlss=, plusRX_VK_FSR=1/2. This PR'sChoiceenum reuses the same field with other meanings (3 is FSR 3.1 here and FSR 4 in #1008). So dropupscale::Choice,RX_UPSCALER,upscaler=and thefsr4=migration, and do the choice inupscaler_rows.h/temporal_mode()/engine_of():temporal_mode()returns GAME wheneverfsr4_why() != FSR_OK. That has to allow FSR 3.1.engine_of()has two slots chosen byis_fsr. It needs an FSR 3.1 slot, picked when FSR 4 isn't usable or its slot hasfailed(that's the "FSR 3.1 takes over" fallback; today a failed FSR 4 means the game's upscale for good). With that,fsr4_failed()isn't needed.temporal_jitter_size()checksengines[is_fsr ? 1 : 0].failed, so after an FSR 4 failure it would switch the jitter off while FSR 3.1 is drawing. It has to check the engine in use.name_of()needs the new names too.upscaler_rows.hmeanstests/test_upscaler_rows.cppcan cover it.A few smaller points (inline): the 1x1 default reactive mask is read with
texelFetchat every render pixel; frame time is fixed at 16.7 ms; and the current menu row clamps forced choices back to Auto. The last one goes away with point 5.Compared with #1335: its
vk_fsr3.cppcomes from the same #822 code but from before this PR's work. It has nofailed/reasonstate, nowavedetection and no retiring, it addsRX_VK_FSR_STAGEdiagnostics, and it assumes HDR colour and reversed depth. It feeds FSR 3.1 through its own seam (upscale_seam.h, its own depth and camera hooks), copiesfsr3::output_image()straight into the game's target, and keeps the "jitter not extracted yet" plumbing-check path. Itsupscaler_rows.husesFSR3 = 3, FSR4 = 4, which collides with #1008'sFSR = 3, FSR_AA = 4, and it doesn't useTemporalEngineeither. This PR's approach is the right base: one input path shared with FSR 4, shaders compiled for exactly those inputs, and a failure state. Once ported as above it slots straight into #1008. #1335 would need the same port and more.No CI ran on this branch. Not good to merge as is: it conflicts, and it needs the port to #1008's current interface first.
@ -0,0 +481,4 @@// (work recorded against the old size may still run: its images are retired, not destroyed)for_each_image([](Image& t) {if (t.image) g_retired.push_back({t, texture_frame_no()}), t = Image{};Nothing ever frees these.
free_retired()only runs fromprepare(), andshutdown()has no caller, so after switching to FSR 4 / Off / DLSS the current set and any retired ones stay allocated for the rest of the run. In #1008 this becomesrelease()handing them totemporal_later().@ -0,0 +515,4 @@made = made && make_image(g.frame_info, VK_FORMAT_R32G32B32A32_SFLOAT, 1, 1);made = made && make_image(g.spd_atomic, VK_FORMAT_R32_UINT, 1, 1);made = made && make_image(g.lanczos_lut, VK_FORMAT_R16_SNORM, 128, 1);made = made && make_image(g.default_reactive, VK_FORMAT_R8_UNORM, 1, 1);The 1x1
default_reactiveis also bound as the reactive and transparency/composition masks (pass 6, bindings 3 and 4).DilateReactiveMaskscallsLoadReactiveMask(), which is atexelFetchat render-pixel coordinates (ClampLoadtoRenderSize()), so every pixel except (0,0) reads out of bounds.robustImageAccessis off invk_main.cpp, which makes that undefined. AMD returns 0 in practice, but other vendors may not. The SDK does the same thing, but D3D defines out-of-bounds loads as 0. A render-size R8 image cleared to 0 (or enabling robust image access for these pipelines) avoids it. The exposure binding is fine, since it only reads (0,0).@ -0,0 +541,4 @@Constants k{};k.render_size[0] = rw, k.render_size[1] = rh;k.upscale_size[0] = uw, k.upscale_size[1] = uh;k.max_render_size[0] = rw, k.max_render_size[1] = rh;max_render_sizeis always the current render size, andprepare()rebuilds every image whenrw/rhchange. Each change resets the history, and each old set (two RGBA16F output-size images plus the rest, a few hundred MB at 4K) is kept for 120 frames, so a render size that keeps moving piles them up. The SDK's way is to allocate the render-size images at the maximum render size and passrender_sizeper frame (its shaders clamp UVs toRenderSize()/MaxRenderSize()). #1008'sprepare(..., &in_w, &in_h, ...)is built for exactly that.@ -0,0 +570,4 @@else if (phases > g.jitter_phase_count) g.jitter_phase_count += 1.0f;else if (phases < g.jitter_phase_count) g.jitter_phase_count -= 1.0f;k.jitter_phase_count = g.jitter_phase_count;k.delta_time = std::clamp(in.frame_time_ms / 1000.0f, 0.0f, 1.0f);Nit:
frame_time_msis never set by the caller, so this is always 16.7 ms. OoT runs at 20/30 fps, and the luma pyramid smooths exposure withexp(-DeltaTime()). #1008's FSR 4 engine measures it withsteady_clock, and doing the same here would be easy.The row still has
hi = 1.RX_UPSCALER=fsr3sets 3 and the row showsOn. When it's saved asupscaler=3, the next start clamps it to 1 (Auto) in the ini loop (min(max(v, lo), hi)), so a forced FSR 3.1 / FSR 4.1 doesn't persist the way the description says. This goes away anyway once the choice moves into #1008'supscaler_rows.h, whereopts.upscaleralready means GAME/DLSS/DLAA/FSR/FSR_AA.Superseded by #1386, which brings FSR 3.1 (upscaling and frame generation) onto the frame chain already on main from #841. This branch also carries #1008 and #1095 and conflicts with main in 10 files. Closing; thanks!