Repository navigation
feat(vk): AMD Anti-Lag 2 with frame generation - #2262
Conversation
Joey-Magnus
left a comment
There was a problem hiding this comment.
Needs a rebase after #2118: it conflicts in vk_framegen.cpp/.h, vk_replay.cpp, vk_menu.cpp, test_antilag.py, test_present_semaphores.py and tested-configurations.md, around PendingPresent/present_out. The change is still needed (main still has wanted() && !framegen_on() at vk_antilag.cpp:58). After the rebase, the present-stage index needs re-checking through #2118's present path. A latency measurement would also show the driver's wait helps when the present comes after the next frame's input stage.
844476a to
8d16615
Compare
Frame generation no longer turns Anti-Lag 2 off. As NVIDIA Reflex's markers with frame generation (NotRexed#2118), each set keeps the game frame it was made at (antilag_frame), and only the set's game frame gives that frame's present stage (antilag_present_frame, kept by a deferred present until its commit); the made frames' presents give none. Without frame generation nothing changes. The row's hint takes the Reflex row's wording and translations.
|
Rebased onto main after #2118 (now one commit, 8d16615). The present stage follows #2118's Reflex path: Retested in the game with the rebased build (main + this PR, built from source): RX 9070 XT, Adrenalin 26.10.2, Windows 11, 2560x1440 fullscreen, FSR 3.1, frame generation Auto (144 Hz, present ahead).
No latency number in milliseconds yet (no PresentMon run). The description is updated. |
With frame generation on, AMD Anti-Lag 2 turned itself off, so on AMD GPUs the input delay that frame generation adds got no help: the menu row said On, but the log said
vk: AMD Anti-Lag 2: off. This keeps it on with frame generation.Rebased onto main after #2118, and now built the way #2118 gives NVIDIA Reflex its present markers with frame generation.
What changed
vk_antilag.cpp: frame generation no longer turns Anti-Lag 2 off. The input stage is where it was (after the game thread's present, with Reflex's sleep). The present stage now gives the index of the frame the present shows, not the latest one: with frame generation, the display thread shows a frame after the game thread has already given the next frame's input stage.vk_antilag.h:antilag_present_frame, athread_locallikereflex_present_frame:kAntiLagThisFrame(the default) is the frame being made, as without frame generation; the display thread sets a set's game frame for its game frame and 0 for a made frame.antilag_frame()is the frame whose input stage was given last, likereflex_frame().vk_framegen.cpp: each set keepsantilag_id = antilag_frame()next toreflex_idinframegen_record, anddisplay_mainsetsantilag_present_framewith the same choice asreflex_present_frame(timed ? game[k] : k == made) in both the direct path and present ahead. So only the set's game frame gives the present stage, at the same present that gets Reflex's present id and markers; the made frames before it give none. Auto, fixed 2x and up, FSR 3.1 interpolation and DLSS frame generation all go through this path.vk_replay.cpp/vk_framegen.h: a deferred present keeps it inPendingPresent::antilag_frame, andpresent_commitrestores it aroundpresent_out, as it does forreflex_frame.present_outstill gives the stage right beforevkQueuePresentKHR(and before a hand-off to the present thread). Without frame generation nothing changes.How it was tested
tests/test_antilag.pycompiles the real functions against the Vulkan headers with a recordingvkAntiLagUpdateAMD. It checks the stages without frame generation, a game frame's present stage given after the next frame's input stage with its own index, nothing for a made frame (0), nothing for a frame from before the row was turned on again, and Off told once. Its wiring checks coverframegen_record, both present paths indisplay_main, the deferred present inpresent_imageandpresent_commit. It fails onmain.python -I -B tests/run_all.py: 448 passed, 37 skipped, 10 failed on Windows. The same 10 fail on unmodifiedmainon this PC (builder, portable, updater and a few local-environment checks), not from this change.vk_antilag.cpp,vk_framegen.cpp,vk_replay.cppandvk_menu.cppcompile with llvm-mingw against Vulkan-Headers v1.4.345.vk: AMD Anti-Lag 2: on, nooffafter it), each switch took effect at once, 0 late frames (28,652 shown on time in the longest stretch with it on), about 58-59 fps with it on and off, no hang, no failed submit. The FPS counter's Breakdown shows more "Pacing" with the row on than off at the same frame time (it varies from frame to frame): the driver's wait at the input stage now happens with frame generation too.Not tested