Add AMD FSR 3.1 frame generation: a generated frame between every two the game draws.

With Frame generation set to AMD FSR 3.1 (after a restart), AMD's frame generation swapchain takes the place of the
present path's own: the device creates two more graphics queues for its presents and image acquires, the present
path acquires, gets images and presents through its replacement functions, and every frame configures generation
and records its preparation from the depth and camera motion vectors the DLSS or FSR 3.1 upscaling pass made (one of
them must be on). Generation pauses while the menu is open. On an RTX 5090 at a 60 fps game, about one frame was
generated for every frame drawn in play.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-07 12:25:25 -05:00
parent ca5e5eb5a4
commit 7c11ff6816
12 changed files with 352 additions and 15 deletions

View File

@@ -354,8 +354,18 @@ static struct {
int ids_ok;
unsigned cfg_seen; // cfg_version when preset was read
uint64_t last_eval_ns; // plat_now_ns of the previous evaluation (FrameTimeDeltaInMsec)
VkFfxImage fg_depth, fg_mv; // the last evaluation's depth and motion vectors, for frame generation
float fg_jx, fg_jy;
int fg_fresh, fg_reset; // fresh: not handed out yet (vk_dlaa_fg_inputs)
} D = {.mv_ok = -1, .cfg_seen = ~0u};
int vk_dlaa_fg_inputs(VkFfxImage *depth, VkFfxImage *mv, float *jx, float *jy, int *reset) {
if (!D.fg_fresh || D.failed) return 0;
D.fg_fresh = 0;
*depth = D.fg_depth, *mv = D.fg_mv, *jx = D.fg_jx, *jy = D.fg_jy, *reset = 0;
return 1;
}
const VkTexImage *vk_dlaa_swap_img;
VkImageView vk_dlaa_swap_view;
@@ -1172,6 +1182,10 @@ evaluated:
ex->recorded += 4;
vk_exec_draw_new_cb(); // NGX bound pipelines and descriptor sets of its own: the next draw binds everything again
D.jdepth = z->image;
// for frame generation at this frame's present (vk_dlaa_fg_inputs)
D.fg_depth = (VkFfxImage){z->image, z->format, w, h, 0};
D.fg_mv = (VkFfxImage){e->mv, VK_FORMAT_R16G16_SFLOAT, w, h, 1};
D.fg_jx = jx, D.fg_jy = jy, D.fg_fresh = 1;
next_jitter(w, ow);
if (++D.evals == 1 || D.evals == 300 || D.evals % 3600 == 0) // 300: one early line with the frames counted
rt_log("dlaa: %llu frames anti-aliased (scene %ux%u, output %ux%u; %llu frames without the DLAA point, %llu with camera "