Commit Graph
9 Commits
Author SHA1 Message Date
Valiantsin DzerakhandClaude Opus 5.5 1ab3856fdd TOTK_SYNC_AHEAD=check measures what a one-frame-late frame wait without shadow storage would race, with the wait left exact
The replay notes each GPU-timeline access of guest memory with its submission's value (in-place bindings of imported
pools without a mirror, mirror sync copies, GPU deswizzle sources, mirror write-backs); at the frame wait the notes of
the frame the late wait would leave running form its read set, snapped with the write watch and checked again at the
next frame-wait entry. Invalidates and small-target write-backs of GPU results from that frame count as stale
readbacks. One summary line per second and a run summary with the largest offenders by pool (runtime/vk_ahead.c).
--probe-vkmem checks the detector with a synthetic write after the wait; tests/sync_ahead_check.py checks that check
mode keeps the wait exact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 09:19:54 +03:00
Valiantsin DzerakhandClaude Opus 5.5 22794ab332 Merge task/fg into task/fsr31: frame generation's per-object motion vectors and its contexts kept across dynamic resolution, on one motion gate with FSR 3.1
vk_objmv_wanted is FSR 3.1's latched upscaler half (DLSS with NGX up, or FSR 3.1 picked at start) or frame generation following the scene with its objects (vk_fg_objects_on), and vk_mvprev_frame turns the tables on for the running upscaler or for frame generation. vk_usnap.c keeps this branch's host regions: a region's host flag says whether this submission wrote its host copy, which covers frame generation going on and off live without fg's separate U.host pointer. The jitter fix in mv_pass stays a single copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 20:15:40 +03:00
14ccef9a80 AMD FSR 3.1 upscales the 3D scene on the FidelityFX SDK 1.1.4 sources behind scene_upscaler = fsr3, off by default
scene_upscaler (off | dlss | fsr3, read at start) replaces the dlaa toggle on the Screen tab; without the key dlaa = 1
still means DLSS, so nobody gets FSR 3.1 without picking it. The DLSS mode row is the upscaling mode of both engines,
the DLSS model, characters' mask, fixed exposure and effects-after rows show only with DLSS, and the performance
overlay names the upscaler that ran and its mode. resolution.c sizes the scene for the engine picked at start.

runtime/vk_fsr3.cpp drives the SDK's upscaler context on its Vulkan backend directly, as Savage Wind's fsr3.cpp does:
one context per output size with the output as its largest render size (the modes and the dynamic resolution need
no new context), HDR input (the light target before the bloom, where DLSS reads it), render-size motion vectors with
the per-object pass, the camera jitter, the camera's planes and field of view from the scene block (vk_fg_camera; a
cut starts a new history), FSR's sharpening off. vk_dlaa.c calls it at the DLSS point after the recorder's drain;
the NGX path is left as it was. The backend's per-frame rings hold four dispatches: a dispatch waits for the one three
back should it still be in flight. Frame generation stays off while FSR 3.1 runs (logged once).

The SDK subset gains the upscaler component, its shader headers, FSR 1's (its RCAS) and its GLSL, from Savage Wind's
copy unchanged; tools/ffx_shaders.py --effects fu builds its blobs (HDR, 32- and 16-bit floats) into
spirv/ffx_fsr3upscaler_vk.h, and vk_fg.cpp's blob lookup hands those out through vk_fsr3_blob. The luma history's
storage image is declared rgba16f, its images' format (rgba8 in the SDK; the validation layer reported it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Revivedx <82332536+Revivedx@users.noreply.github.com>
2026-11-20 14:39:57 +03:00
Valiantsin DzerakhandClaude Opus 5.5 0a299a41ec Frame generation keeps its contexts when the game's dynamic resolution changes the scene size, instead of making them again after a device idle each time
In the town the scene moved between 1600x896, 1432x808 and 1280x720 under a 1080p output; vk_fg_prepare compared the
scene size with the contexts' and made the contexts again each time, 58 times in 222 s of a user's session, each after
vkDeviceWaitIdle (89 ms measured). The contexts are now made for scenes up to the output's size (or a larger scene's,
once one comes) as the SDK's maxRenderSize, and each frame passes its own size as renderSize to the prepare and the
interpolation: the SDK sizes its images by maxRenderSize, dispatches over renderSize and divides the motion vector scale
by it. A frame at another size than the last starts the interpolation over (its dilated depth and vectors from last
frame are of the other size); the summary line counts those.

Checked: 60 s in the town with two scene size changes, no remake and the replay thread's FG time at most 6.4 ms; a run
at render_scale = 50 (960x536 scene, 1920x1080 contexts) generates Link running without a double image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 14:30:51 +03:00
efee9bcf16 Frame generation gets a row on the Game tab under the frame limit (Off or AMD FSR 3) that applies at once, and the fps overlay reads "N fps drawn, M shown" while it runs
The row and its description (for displays of 120 Hz and more, the game at half the limit, about half a frame more input delay, not with DLSS or HDR) are in the menu's catalog for English, Russian, Portuguese (Brazil) and Simplified Chinese. frame_gen is live: vk_fg.cpp vk_fg_engine reads it again after a settings change, the contexts are made at the first frame after it is turned on (a hitch of about 0.1 s once), turned off they stay unused until exit, and gfx_present.c builds the swapchain again when the extra image for the pair comes or goes. The full overlay gets a Shown row. totk.ini.example describes frame_gen.

The shown-frames counter and the overlay lines follow PR #1089 by xellow78-lgtm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: xellow78-lgtm <336264245+xellow78-lgtm@users.noreply.github.com>
2026-11-20 13:48:10 +03:00
451813aa17 Frame generation shows its pictures: each drawn frame goes out as a pair, the generated picture once the GPU has drawn the frame and the game's half the smoothed interval later, and the game draws at half the frame limit while it does
vk_backend.c present_pair: both blits are submitted at once (gfx_present.c vk_present_blit_pair, the flip queue of two), the generated picture is presented after a timeline wait on the frame's last submission and not before the pacer's display time, the game's frame after a wait on the value after both blits and half the smoothed interval between generated pictures (factor 0.1) after it, as AMD's frame interpolation swapchain and Savage Wind's present_wait_turn do: spaced by the CPU clock alone both pictures went on screen together under FIFO and G-SYNC. The swapchain gets one image more while frame_gen names a generator, for the two images held at once; the present slots stay at two (each blit waits on the fence of the blit two before, the previous frame's same picture, already shown). The generated picture's blit lays the menu and overlay out, the game's draws them again; colour and FSR 1 run per blit; the flight recorder keeps the game's frames; the generated present carries no present ID. frame_rate.c frame_step_cap_ns halves the limit, 30 drawn at least, while the last frame went out with a generated picture, so menus and fades keep the whole limit; the real-time step follows the game's presents and stays the drawn interval. With frame_gen = off the present path is unchanged. "fg present" log lines give shown and drawn fps and the present intervals (mean, sd, p99, each half of the pair) in the world.

Measured on the RX 9070 and the 7900X on 4 cores, field save, camera turning, 1080p output: limit 120 immediate 117 shown and 60 drawn, intervals 8.34 ms sd 0.16 from generated to game's, 8.38 sd 1.71 back; FIFO at 144 Hz the same at 120, and 141 shown and 72 drawn without a limit; immediate without a limit 169 shown and 86 drawn against 94 drawn with frame_gen = off. Replay-thread cost 0.59-0.65 ms a drawn frame.

The flip queue, the pair blit, the halving rule and the present without an ID follow PR #1089 by xellow78-lgtm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: xellow78-lgtm <336264245+xellow78-lgtm@users.noreply.github.com>
2026-11-20 10:38:58 +03:00
Valiantsin DzerakhandClaude Opus 5.5 a7275e6644 frame_gen names the frame generator, off or fsr3 (default off), instead of 0 or 1, so later generators (FSR 4 through AMD's DLL, DLSS) become values of the same setting
vk_fg.cpp vk_fg_engine is the one place that reads the string and maps it to VkFgEngine; an unknown value is off and logged once. The setting was never released, so 0 and 1 are not kept as aliases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 10:20:18 +03:00
1ea8838da9 Frame generation inputs and dispatch with DLSS off: the replay follows the scene for it, records the camera motion vectors and the SDK's prepare at the scene's end, copies the picture before the HUD sRGB-encoded as the window texture holds it, and runs the optical flow and the interpolation after the frame's window texture, nothing shown yet
vk_dlaa.c follows the scene while frame_gen is live and DLSS is off (track: the arming and end of the DLSS path, without jitter, reactive mask or per-object motion), fg_motion runs mv_pass on the camera alone and vk_fg_prepare, vk_dlaa_hud takes the picture before the HUD by PR #1089's rule once the bloom chain began, vk_dlaa_sub_end runs the interpolation at the end of the submission that drew the window texture. vk_fg.cpp reads the camera's planes and depth convention from the scene block's projection (standard depth, near 0.1 m, far 25 km in TotK 1.4.3), makes the contexts again when sizes or the convention change, resets the history on a cut (10 m or 35 degrees, as Savage Wind), a frame without camera motion and after any frame without a generated picture, and stays off with DLSS, replay workers, sync_ahead, HDR and while a menu background or a fade is open. fg_test, fg_debug, fg_shot and fg_times are the checks; GPU timestamps and the replay thread's recording time go to the log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Revivedx <82332536+Revivedx@users.noreply.github.com>
Co-Authored-By: xellow78-lgtm <336264245+xellow78-lgtm@users.noreply.github.com>
2026-11-20 10:09:58 +03:00
4e48669c86 FidelityFX SDK 1.1.4 frame interpolation and optical flow built into totk.exe behind frame_gen, contexts created and destroyed only, no frame-path change
The SDK subset, its compat header and the SPIR-V shader header come from Savage Wind (MIT); tools/ffx_shaders.py regenerates the header with glslangValidator, build_game.py compiles the SDK sources with ffx_compat.h force-included, and runtime/vk_fg.cpp makes the backend, optical flow and frame interpolation contexts after the device exists when frame_gen = 1 (default 0, read at start).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Revivedx <82332536+Revivedx@users.noreply.github.com>
2026-11-20 09:40:26 +03:00