mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 23:59:59 -04:00
Raise the pipeline cache's size limit to 1024 MB, and leave never-drawn list pipelines to their first draw on a machine short of memory.
The limit was 512 MB, and a file over it starts the run empty until a play file replaces it. With the pipeline list of 0.9.1 one run builds more than that: on an RTX 2080 Ti (#722) pipeline-cache.bin held 551 MB and the play file the run then wrote 541 MB, so both were dropped at every start, 7,247 of 8,531 pipelines were built again each time (17 s of the boot) and 541 MB were written in every session. Seven of the players' logs read here have a file over 512 MB, five of them between 517 and 691 MB. At 1024 MB those are read, the play file is folded in once and the loop ends; a start that still finds both files over the limit now says so. pipe_seed_boot (auto, 1, 0) decides whether the boot builds the pipelines of the shared list that the install has never drawn. Each is a pipeline the driver holds for the whole run: the boot's pipeline stage went from about 1.6 GB of commit on 0.8.0 to 3.9-4.4 GB on NVIDIA cards with the list (1.5-1.8 GB on AMD's driver), and 0.3-0.6 GiB of video memory. auto, the default, builds them as before except on a machine that starts with less commit free than the game takes in play, the start's own memory warning: there they are made at their first draw from the pipeline cache and recorded as the install's own. Mesh pipelines are built at boot either way. Compiled; not run in the game. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -59,7 +59,7 @@ static const char *const known[] = {
|
||||
"MOTION_GUARD_DEGREES", "MOTION_POLICY_TRACE", "SELECTIVE_MOTION", "SELECTIVE_MOTION_RAW", // motion_owner.c, vk_fg_pose.inc
|
||||
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
|
||||
"MV_SURVEY",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OUTPUT_RES", "PAD_LAYOUT", "PACE_HZ", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_RES_FIXED", "PATCH_SCENE", "PATCH_WIDE_ASPECT", "PATCH_WIDE_HUD", "PATCH_WIDE_MOVIE", "PATCH_WIDE_OUT", "PATCH_FREECAM", "PATCH_WIDE_SCENE", "PCSS", "PCSS_K", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPELINE_CACHE_MAX_MB", "PIPELINE_CACHE_PLAY", "PIPELINE_CACHE_PLAY_MB", "PIPE_BINARIES", "PIPE_BINARIES_MAX_MB", "PIPE_FEEDBACK", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SEED", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "POWER_FULL", "TEX_SAME", "TEX_SAME_BIG", "TEX_FLAT3D", "TEX_KEEP_TAKEN", "TEX_STALE_KEPT", "PRESENT_HELD", "HELD_SYNC",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OUTPUT_RES", "PAD_LAYOUT", "PACE_HZ", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_RES_FIXED", "PATCH_SCENE", "PATCH_WIDE_ASPECT", "PATCH_WIDE_HUD", "PATCH_WIDE_MOVIE", "PATCH_WIDE_OUT", "PATCH_FREECAM", "PATCH_WIDE_SCENE", "PCSS", "PCSS_K", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPELINE_CACHE_MAX_MB", "PIPELINE_CACHE_PLAY", "PIPELINE_CACHE_PLAY_MB", "PIPE_BINARIES", "PIPE_BINARIES_MAX_MB", "PIPE_FEEDBACK", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SEED", "PIPE_SEED_BOOT", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "POWER_FULL", "TEX_SAME", "TEX_SAME_BIG", "TEX_FLAT3D", "TEX_KEEP_TAKEN", "TEX_STALE_KEPT", "PRESENT_HELD", "HELD_SYNC",
|
||||
"PREPARE_PIPELINES", "PREWARM_FULL", "PREWARM_WAIT_MS", "PREWARM_XLATE", "PROBE_MOVIE", "PROBE_MOVIE_SHOT", "PROFILE", "PROFILE_CHAINS", "PROFILE_DIR", "PROFILE_FRAMES", "PROFILE_REPLAY", "PROFILE_SLOW",
|
||||
"POOL_FAST", "POOL_GROUP", "POOL_GROUP_CHECK", "POOL_PRESNAP", "POOL_PRESNAP_RUNS",
|
||||
"SUBMIT_FINISH_GPU", "SVC_WAITS", "SNAP_WIDEN", "SUBMIT_FINISH_RESULTS", "SUBMIT_FINISH_KINDS", "FOLIAGE", "MIRROR_STAGE", "FLUSH_SKIP_CLEAN", "MIRROR_HOT", "MESH_EMULATION", "MESH_EMU_MB", "MESH_EMU_TASKS", "MESH_EMU_BATCH", "GUEST_OPT", "LOG_TEX_NEW", "DUMP_KEY", "VEC_INDEX_FIX", "PASS_TIMES",
|
||||
@@ -141,7 +141,7 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"TIMER_1MS", "performance"}, {"PIPE_WAIT", "performance"}, {"PIPE_SKIP", "performance"}, {"ONESHOT_BUDGET", "performance"},
|
||||
{"PIPE_FRAME_WAIT_MS", "performance"}, {"PIPE_SKIP_STEADY", "performance"},
|
||||
{"CACHE_DIE", "performance"}, {"ONE_PER_CORE", "performance"},
|
||||
{"LIB_PREBUILD", "performance"}, {"LIB_PREBUILD_THREADS", "performance"}, {"LIB_WARM", "performance"}, {"PIPE_LINK_MS", "performance"}, {"PIPE_LINK_DRAW_MS", "performance"}, {"PIPE_AHEAD", "performance"}, {"LINE_WIDTH", "performance"}, {"POOL_SHOWN_FIRST", "performance"}, {"TEX_REUSE_NAMED", "performance"}, {"TEX_OVERWRITTEN_USED", "performance"}, {"PIPE_FAST_WORKERS", "performance"}, {"GPL_FEEDBACK", "performance"}, {"FRAME_HOLD_MS", "performance"}, {"PACE_SMOOTH", "performance"}, {"OQ_BATCH", "performance"}, {"GATE_WAIT_MS", "performance"}, {"PIPE_PREBUILD", "performance"}, {"PIPE_SEED", "performance"},
|
||||
{"LIB_PREBUILD", "performance"}, {"LIB_PREBUILD_THREADS", "performance"}, {"LIB_WARM", "performance"}, {"PIPE_LINK_MS", "performance"}, {"PIPE_LINK_DRAW_MS", "performance"}, {"PIPE_AHEAD", "performance"}, {"LINE_WIDTH", "performance"}, {"POOL_SHOWN_FIRST", "performance"}, {"TEX_REUSE_NAMED", "performance"}, {"TEX_OVERWRITTEN_USED", "performance"}, {"PIPE_FAST_WORKERS", "performance"}, {"GPL_FEEDBACK", "performance"}, {"FRAME_HOLD_MS", "performance"}, {"PACE_SMOOTH", "performance"}, {"OQ_BATCH", "performance"}, {"GATE_WAIT_MS", "performance"}, {"PIPE_PREBUILD", "performance"}, {"PIPE_SEED", "performance"}, {"PIPE_SEED_BOOT", "performance"},
|
||||
{"COMPUTE_KEEP", "performance"},
|
||||
{"PREWARM_XLATE", "performance"}, {"GPL", "performance"}, {"ASTC", "performance"}, {"MEMORY", "performance"},
|
||||
{"TEX_ALIAS", "performance"}, {"DEPTH_INIT_INLINE", "performance"}, {"DEPTH_ALIAS_LOG", "diagnostics"}, {"TEX_DISUSE", "performance"}, {"TEX_DISUSE_EVICT", "performance"}, {"TEX_GEN_UNDO", "performance"}, {"TEX_REUSE", "performance"}, {"TEX_SPLIT_FILL", "performance"}, {"TEX_VRAM_PRESSURE", "performance"}, {"TEX_PROC_COMMIT_MB", "performance"}, {"ASTC_BC", "performance"}, {"LOD_GUARD", "performance"}, {"FIX_C0", "performance"}, {"FIX_ZERO", "performance"}, {"WATER_PROJECTIVE", "performance"},
|
||||
@@ -298,10 +298,10 @@ static const CfgMeta metas[] = {
|
||||
{"GATE_WAIT_MS", "10", "0..100", RESTART}, // vk_exec.c vk_exec_gate_wait
|
||||
{"LIB_PREBUILD", "1", "0|1", RESTART}, {"LIB_PREBUILD_THREADS", "", "1..64", RESTART},
|
||||
{"LIB_WARM", "1", "0|1|force", RESTART}, // vk_pipeline.c lw_start: the driver's cache of stage libraries, warmed when cold
|
||||
{"PIPE_PREBUILD", "1", "0|1", RESTART}, {"PIPE_SEED", "1", "0|1", RESTART}, // vk_pipeline.c keys_open_seed
|
||||
{"PIPE_PREBUILD", "1", "0|1", RESTART}, {"PIPE_SEED", "1", "0|1", RESTART}, {"PIPE_SEED_BOOT", "auto", "0|1|auto", RESTART}, // vk_pipeline.c keys_open_seed
|
||||
{"PREWARM_XLATE", "", "1..64", RESTART}, {"GPL", "", "0|1", RESTART}, // vk_caps.c vk_caps_gpl: by the driver, off with AMD's for RDNA 2 and older
|
||||
{"LIB_PREBUILD_BIG_BG", "1", "0|1", RESTART}, {"PIPE_FEEDBACK", "1", "0|1|2", RESTART},
|
||||
{"PIPELINE_CACHE_MAX_MB", "512", "0..65536", RESTART},
|
||||
{"PIPELINE_CACHE_MAX_MB", "1024", "0..65536", RESTART},
|
||||
{"FFX_PIPE_CACHE", "1", "0|1", RESTART}, // vk_ffx.cpp vk_ffx_proc_addr: FSR 3.1's pipelines through the pipeline caches
|
||||
{"PIPELINE_CACHE_PLAY", "1", "0|1", RESTART}, {"PIPELINE_CACHE_PLAY_MB", "64", "1..65536", RESTART}, // vk_pipeline.c "the play cache": what a run compiles goes into a file of its own
|
||||
{"PIPE_BINARIES", "0", "0|1", RESTART}, {"ONESHOT_WAIT_MS", "30000", "0..60000", RESTART}, {"ONESHOT_BUDGET", "1", "0|1", RESTART}, {"PIPE_BINARIES_MAX_MB", "1024", "0..65536", RESTART}, {"BIG_BUILD_FREE_MB", "8192", "0..262144", RESTART},
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "mesh_emu_spirv.h"
|
||||
#include "gfx.h"
|
||||
#include "host.h"
|
||||
#include "mem_need.h"
|
||||
#include "nvn_hmap.h"
|
||||
#include "platform/platform.h"
|
||||
#include "prp_file.h"
|
||||
@@ -746,8 +747,12 @@ static VkResult pipe_create(int kind, void *ci, VkPipeline *pipe) {
|
||||
// The data of the pipeline cache file at path for vkCreatePipelineCache (malloc'd, its size in *size), NULL when the
|
||||
// run starts without it, which the log says with the file's size. Cache data whose header names another device or
|
||||
// driver is dropped before Vulkan sees it.
|
||||
// NX2NAVI_PIPELINE_CACHE_MAX_MB (default 512; 0 no limit): a larger file starts the run empty, and the run's
|
||||
// saves replace it. The file only grows: entries of earlier translators and builds stay, and on NVIDIA
|
||||
// NX2NAVI_PIPELINE_CACHE_MAX_MB (default 1024; 0 no limit): a larger file starts the run empty, and the run's
|
||||
// saves replace it. The limit has to stay above what one run builds, or nothing ever replaces the file: at 512, with
|
||||
// the pipeline list of 0.9.1 (8,849 records), an RTX 2080 Ti's file held 551 MB and the play file the run then wrote
|
||||
// 541 MB, so both were dropped at every start, 7,247 of 8,531 pipelines were built again in each (17 s of the
|
||||
// boot) and 541 MB were written again in each session (cache_load says so when both files are over). The file only
|
||||
// grows: entries of earlier translators and builds stay, and on NVIDIA
|
||||
// (621.01) an entry another executable wrote is neither used nor written again, so a renamed or updated exe
|
||||
// compiles while the file keeps its size (2026-11-09: 650 MB, 15-18 % of the pipelines read from it). The
|
||||
// whole file sits in process memory twice at the boot (this read and the driver's copy) and is copied out
|
||||
@@ -830,6 +835,10 @@ static void cache_load(VkCtx *c) {
|
||||
int want = cfg_bool("NX2NAVI_PIPELINE_CACHE_PLAY") && !prep_mode, on = want && P.cache_control;
|
||||
size_t psize = 0, pkept = 0;
|
||||
void *pdata = cache_data_read(c, P.play_path, &psize);
|
||||
if (base_over && cache_over_cap) // what one run builds is over the limit: nothing will ever replace either file
|
||||
rt_log("vk_pipeline: both pipeline cache files are over NX2NAVI_PIPELINE_CACHE_MAX_MB, so what one run builds does "
|
||||
"not fit it: this start builds every pipeline again, and so will each one after it until the limit is "
|
||||
"raised above the play file's size (pipeline_cache_max_mb in nx2navi.ini; 0 = no limit)");
|
||||
VkPipelineCache play = psize || on ? cache_make(c, pdata, psize, &pkept) : VK_NULL_HANDLE;
|
||||
free(pdata);
|
||||
uint64_t fold_at = (uint64_t)strtoull(cfg_value("NX2NAVI_PIPELINE_CACHE_PLAY_MB"), NULL, 10) << 20;
|
||||
@@ -4173,6 +4182,7 @@ static struct {
|
||||
uint32_t pend_n, pend_cap;
|
||||
uint8_t *file; // the file as read at boot, until the prewarm is done with it
|
||||
size_t file_n; // records in it
|
||||
size_t own_n; // of them, the first ones: this install's own (keys_open); the shared list's follow
|
||||
PlatMutex io; // one writer
|
||||
// prebuild progress (under P.lock)
|
||||
int loading; // the prewarm still queues records
|
||||
@@ -4276,6 +4286,7 @@ static void keys_open_seed(void);
|
||||
static void keys_open_own(void);
|
||||
static void keys_open(void) {
|
||||
keys_open_own();
|
||||
K.own_n = K.file_n;
|
||||
if (K.path[0]) keys_open_seed();
|
||||
}
|
||||
|
||||
@@ -5287,6 +5298,30 @@ void vk_pipeline_prewarm(void) {
|
||||
__atomic_store_n(&pw_phase, 3, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
// NX2NAVI_PIPE_SEED_BOOT (auto, the default; 1; 0): whether the boot builds the pipelines of the shared list that this
|
||||
// install has never drawn (keys_open_seed), 1, or leaves them to their first draw, 0. Built at boot they are there
|
||||
// when a draw first needs them, which is what the list is for, and every one is a pipeline the driver holds for the
|
||||
// whole run: with the list of 0.9.1 the boot's pipeline stage went from about 1.6 GB of commit (0.8.0, 3,256
|
||||
// pipelines on an RTX 5080) to 3.9-4.4 GB (8,531 on an RTX 2080 Ti, 6,977 on an RTX 5070 Ti) and 0.3-0.6 GiB of
|
||||
// video memory, 1.5-1.8 GB of commit on AMD's driver, of which the list's share is half to nearly all. On a machine
|
||||
// that has that to spare it buys the first visit of every area without a wait. On one that starts short of the
|
||||
// commit the game takes in play (mem_need.h, the start's own warning) it is memory taken from the game for
|
||||
// pipelines that may never be drawn, and running out of commit ends the game (a failed allocation or a lost device).
|
||||
// auto leaves them out there and only there. A pipeline left out is made at its first draw as any new one is, from
|
||||
// pipeline-cache.bin when the preparation built it (0.5-0.8 ms on a worker), and is the install's own from then on:
|
||||
// the next start builds it at boot. Mesh pipelines are built at boot either way: they have no fast link, and a draw
|
||||
// waits for the whole build. The list's pairs still count in the vertex output unions, so the modules stay the ones
|
||||
// the preparation built.
|
||||
static int seed_boot(void) {
|
||||
static int on = -1;
|
||||
if (on >= 0) return on;
|
||||
const char *e = cfg_get("NX2NAVI_PIPE_SEED_BOOT");
|
||||
if (e && (!strcmp(e, "0") || !strcmp(e, "1"))) return on = e[0] == '1';
|
||||
double proc, used, limit, need = strtod(cfg_value("NX2NAVI_MEM_NEED_MB"), NULL);
|
||||
plat_commit_info(&proc, &used, &limit);
|
||||
return on = !mem_need_short(proc, used, limit, need);
|
||||
}
|
||||
|
||||
static void prewarm_run(void) {
|
||||
const char *gpu = rt_config()->gpu;
|
||||
uint32_t pr_hist[16] = {0}, fs_hist[4] = {0}; // library state of the recorded pipelines (lb_start)
|
||||
@@ -5354,7 +5389,8 @@ static void prewarm_run(void) {
|
||||
return;
|
||||
}
|
||||
pm_set();
|
||||
uint32_t queued = 0, dropped = 0, known = 0;
|
||||
uint32_t queued = 0, dropped = 0, known = 0, listed = 0;
|
||||
int at_boot = seed_boot();
|
||||
plat_mutex_lock(&P.lock);
|
||||
K.t0 = t1;
|
||||
K.loading = 1;
|
||||
@@ -5385,6 +5421,10 @@ static void prewarm_run(void) {
|
||||
pr_hist[(k.clamp & 1) | (k.poly_mode & 3) << 1 | (k.minus_w & 1) << 3]++;
|
||||
fs_hist[k.samples >= 8 ? 3 : k.samples >= 4 ? 2 : k.samples >= 2 ? 1 : 0]++;
|
||||
}
|
||||
if (!at_boot && i >= K.own_n && !is_mesh(&s)) { // of the shared list alone: made at its first draw (seed_boot)
|
||||
listed++;
|
||||
continue;
|
||||
}
|
||||
uint64_t h = key_hash(&k, sizeof k);
|
||||
int q = 0;
|
||||
if (pipe_find(&k, sizeof k, h)) known++;
|
||||
@@ -5392,6 +5432,13 @@ static void prewarm_run(void) {
|
||||
}
|
||||
K.loading = 0;
|
||||
plat_mutex_unlock(&P.lock);
|
||||
if (listed) {
|
||||
const char *e = cfg_get("NX2NAVI_PIPE_SEED_BOOT");
|
||||
rt_log("vk_pipeline: prewarm: %u records of the shared pipeline list that this install has not drawn are left to "
|
||||
"their first draw, when pipeline-cache.bin gives them (NX2NAVI_PIPE_SEED_BOOT=%s%s)", listed,
|
||||
e && !strcmp(e, "0") ? "0" : "auto",
|
||||
e && !strcmp(e, "0") ? "" : ": this machine started with less commit free than the game takes in play");
|
||||
}
|
||||
free(ids), free(sh);
|
||||
|
||||
__atomic_store_n(&pw_pipe_done, 0, __ATOMIC_RELAXED);
|
||||
|
||||
Reference in New Issue
Block a user