Merge keeping the upscaler's history when the game moves its scene to another light target.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-11 06:54:21 -05:00
2 changed files with 29 additions and 13 deletions

View File

@@ -44,7 +44,7 @@ static const char *const known[] = {
"BIND_SKIP", "BIND_STATS", "BIND_UP", "BIND_X", "BIND_Y",
"BIND_ZL", "BIND_ZR", "BLOCK_VIEWS_3D", "CACHE_DIE", "CLOTH_REALTIME", "COLOR_BRIGHTNESS", "COMPUTE_KEEP", "COLOR_CONTRAST", "COLOR_GAMMA",
"COLOR_PRESET", "COLOR_SATURATION", "CONTACT_DEBUG", "CONTACT_SHADOWS", "CORE_DIAG", "CRIT", "CRIT_OUT",
"DESC_TEMPLATE", "DEVICE_PROFILE", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_CAM_KEEP", "DLSS_IDLE_FREE", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR",
"DESC_TEMPLATE", "DEVICE_PROFILE", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_CAM_KEEP", "DLSS_IDLE_FREE", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TARGET_KEEP", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR",
"DUMP_LOG", "DUMP_RAW", "DUMP_SHADERS", "DUMP_FILE", "DS3", "LOG_CS_BINDS", "LOG_TEX_FLAGS", "LOG_MESH", "MESH", "POOL", "NATIVE_TENSOR", "LOG_RCOND", "LOG_RT_SIZES", "DUMP_WHITE", "DUMP_AFTER", "DUMP_MOVIE", "SUBMIT_FINISH", "ACQUIRE_WAIT", "CRASH_FILTER_GUARD", "CS_FALLBACK", "EXEFS", "FEEDBACK", "FIX_C0", "FIX_ZERO", "FLIGHT", "FLIGHT_AT", "FLIGHT_DIR", "FLIGHT_FRAMES",
"FFX_PIPE_CACHE", "FLIGHT_SPIKE_MS", "FLIGHT_THUMBS", "FLIGHT_EVERY", "FLUSH_SPAN", "FLUSH_UPLOAD", "FOG_CULL", "FOLIAGE_SHADOW_CULL", "FOLIAGE_SHADOW_VRS", "FOV", "FOV_PATCH", "FG_HUDLESS_SHOW", "FG_MULT", "FPS60", "FPS_LIMIT", "FRAMEGEN", "FRAMEGEN_MULTIPLIER", "FREEZE_IDLE", "FREE_CORES",
"FULLSCREEN", "FXAA", "GAME_ASPECT", "GAME_RES", "GPA", "GPA_EMPTY", "GPA_TWIN", "GPA_TWIN_MAX_KB", "GPL", "GPL_DRAW_BUILD", "GPL_FEEDBACK", "PIPE_AHEAD", "PIPE_FAST_WORKERS", "PIPE_FRAME_WAIT_MS", "PIPE_LINK_DRAW_MS", "PIPE_SKIP_STEADY", "PROG_LEAD", "GPU", "GPU_INDEX", "GPU_PASSES", "GPU_NAME", "HDR", "HDR_BLOWOUT", "HDR_CONTRAST",

View File

@@ -519,6 +519,7 @@ static struct {
int mv_ok; // -1 not built, 0 failed, 1 ready
uint64_t mv_frames, mv_none, masked; // masked: frames with the characters' bias mask
uint64_t why[3]; // history resets: scene size changed, no camera, scene target changed
uint64_t target_kept; // scene target changed and the history stayed (target_changed)
// frames without a camera and what mv_pass did about them (dlaa_cam_keep, cam_note)
uint64_t cam_none_draw, cam_none_snap; // no scene-context draw this frame / one, not in the evaluating submission's copy
uint64_t cam_at_draw; // camera taken from the bytes the draw read, where the evaluating submission lacks them
@@ -1510,21 +1511,23 @@ static int perf_quality(uint32_t w, uint32_t ow) {
// Every 300 frames DLSS ran, the history resets and camera gaps of those frames, while there were any (at most 400 lines a
// run): the measure for dlaa_cam_keep at one spot of the game.
static void window_line(void) {
enum { N_ = 10 };
enum { N_ = 11 };
static uint64_t last[N_];
static int lines;
if (D.evals % 300) return;
uint64_t now[N_] = {D.why[0], D.why[1], D.why[2], D.mv_none, D.cam_none_draw, D.cam_none_snap, D.cam_kept,
D.cam_at_draw, D.frames_missed, D.seconds}, d[N_], any = 0;
D.cam_at_draw, D.frames_missed, D.seconds, D.target_kept}, d[N_], any = 0;
for (int i = 0; i < N_; i++) d[i] = now[i] - last[i], last[i] = now[i];
for (int i = 0; i < N_; i++) any |= d[i];
if (!any || lines >= 400) return;
lines++;
rt_log("dlaa: frames %llu-%llu: resets %llu size, %llu camera, %llu target; %llu without a camera (%llu without a "
rt_log("dlaa: frames %llu-%llu: resets %llu size, %llu camera, %llu target (%llu target changes with the history "
"kept); %llu without a camera (%llu without a "
"scene-context draw, %llu not in DLSS's submission), %llu kept with zero motion; %llu cameras read at the draw; "
"%llu frames without the DLAA point, %llu with a second scene after DLSS ran",
(unsigned long long)(D.evals - 299), (unsigned long long)D.evals, (unsigned long long)d[0],
(unsigned long long)d[1], (unsigned long long)d[2], (unsigned long long)d[3], (unsigned long long)d[4],
(unsigned long long)d[1], (unsigned long long)d[2], (unsigned long long)d[10], (unsigned long long)d[3],
(unsigned long long)d[4],
(unsigned long long)d[5], (unsigned long long)d[6], (unsigned long long)d[7], (unsigned long long)d[8],
(unsigned long long)d[9]);
}
@@ -1532,14 +1535,27 @@ static void window_line(void) {
// dst: the target DLSS's picture goes to, NULL for the light target itself (DLAA in place).
static void hudless(VkCommandBuffer cb, struct Size *e, uint32_t w, uint32_t h);
// Another light target than last frame's: a new history. The first few are logged with the new target's size, to tell a
// target the game made anew from two it alternates between.
static void target_changed(const VkExecTarget *t) {
// Another light target than last frame's. The game draws its scene into one of a few pooled targets of the same size
// and moves to another whenever its pass list changes, in the middle of play with the camera and the scene carrying
// on: 35 times in a walk of a minute through Kokiri Forest, three of them within eight frames on the ladder below
// the tree house.
// The history is the upscaler's own and not in the target, so where this frame's motion vectors are valid (cont: the
// camera of this frame and of the last one, mv_pass 1) the history stays. A new history at each change showed as a few
// soft, grainy frames every time, a flicker over the whole picture. Without valid vectors, and with
// NX2NAVI_DLAA_TARGET_KEEP=0 (test), a new history as before. The first few are logged with the new target's size, to
// tell a target the game made anew from the ones it alternates between.
static void target_changed(const VkExecTarget *t, int cont) {
static int keep = -1;
if (keep < 0) keep = rt_knob("DLAA_TARGET_KEEP", "1");
int kept = keep && cont && D.last_color;
if (D.last_color && D.target_logged < 16)
D.target_logged++, rt_log("dlaa: frame %llu: the light target changed from %p to %p (%ux%u format %d): new history",
D.target_logged++, rt_log("dlaa: frame %llu: the light target changed from %p to %p (%ux%u format %d): %s",
(unsigned long long)__atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED) + 1,
(void *)D.last_color, (void *)t->image, t->width, t->height, (int)t->format);
D.reset = 1, D.why[2]++, D.last_color = t->image;
(void *)D.last_color, (void *)t->image, t->width, t->height, (int)t->format,
kept ? "the history stays (the camera carries on)" : "new history");
if (kept) D.target_kept++;
else D.reset = 1, D.why[2]++;
D.last_color = t->image;
}
// DLSS's own video memory, the features and their history (NGX's DLSS statistics callback with the capability
@@ -1638,7 +1654,7 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) {
if (timed) T.cpu_drain += kern_now_ns() - c0;
if (fsr) { // FSR 3.1 (vk_ffx.cpp) in DLSS's place: the same images, then the same blit below
if (t->level || t->base_layer || z->level || z->base_layer) return dl_fail("FSR 3.1 on a target that is not level 0, layer 0", 0);
if (D.last_color != t->image) target_changed(t);
if (D.last_color != t->image) target_changed(t, mv == 1);
uint64_t now = plat_now_ns();
double dt = D.last_eval_ns ? (now - D.last_eval_ns) / 1e6 : 0;
D.last_eval_ns = now;
@@ -1685,7 +1701,7 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) {
rt_log("dlaa: DLSS feature created at %ux%u -> %ux%u, quality value %d, preset %c (scene format %d, depth format "
"%d)", w, h, ow, oh, q, 'A' + pr - 1, (int)t->format, (int)z->format);
}
if (D.last_color != t->image) target_changed(t);
if (D.last_color != t->image) target_changed(t, mv == 1);
NgxResourceVK rc = res_image(cv, t->image, t->format, w, h, VK_IMAGE_ASPECT_COLOR_BIT, 0);
NgxResourceVK ro = res_image(e->out_view, e->out, VK_FORMAT_R16G16B16A16_SFLOAT, ow, oh, VK_IMAGE_ASPECT_COLOR_BIT, 1);
NgxResourceVK rz = res_image(zv, z->image, z->format, w, h, VK_IMAGE_ASPECT_DEPTH_BIT, 0);