mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 22:19:57 -04:00
Evict idle textures when the system's commit runs low, not only under VRAM pressure.
The driver charges device memory to the commit, and idle live textures went only above NX2NAVI_TEX_VRAM_PRESSURE of the device's budget: on a 16-32 GB card the textures of every area visited stayed until the commit ran out, in 27-37 GB processes that then failed an allocation or lost the device (#177, #203, #215). While commit_is_low holds and the released entries are down to their low-commit size, evict_idle now runs too, 256 MiB at a time (NX2NAVI_TEX_COMMIT_EVICT=0 turns it off). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,7 +60,7 @@ static const char *const known[] = {
|
||||
"SVC_SLOW_MS",
|
||||
"SHOTS_FULL", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "SPV_OVERRIDE", "STICK_DEADZONE", "STICK_SENS",
|
||||
"SWKBD_ANSWER",
|
||||
"SET_AT", "SWKBD_TEST", "TAA", "TEST_PAD", "TEST_PAD_AT", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_MEMO", "TEX_VRAM_PRESSURE", "TEX_RELEASED_MB", "TEX_COMMIT_FREE_MB", "TEX_EVICT", "MIRROR_EVICT", "VRAM_BUDGET_MB", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UPSCALER", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NOOPT", "VK_NO_FLOAT64",
|
||||
"SET_AT", "SWKBD_TEST", "TAA", "TEST_PAD", "TEST_PAD_AT", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_MEMO", "TEX_VRAM_PRESSURE", "TEX_RELEASED_MB", "TEX_COMMIT_FREE_MB", "TEX_EVICT", "TEX_COMMIT_EVICT", "MIRROR_EVICT", "VRAM_BUDGET_MB", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UPSCALER", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NOOPT", "VK_NO_FLOAT64",
|
||||
"VK_PRESENT", "VK_RECONVERGE", "VK_RECORDER", "VK_SSBO_ALIGN", "VK_SUBGROUP", "VK_SUBGROUP_PIN", "VK_VALIDATION", "VOLUME", "VRAM_HEADROOM", "VS_OUTS",
|
||||
"WALK_KEY", "WALK_SCALE", "WB_EXACT", "WB_FENCE_LIMIT", "WB_MERGE", "WB_NO_REUP", "WB_MERGE_MAX", "WINDOW_SIZE", "XLATE", "XLATE_ID", "XLATE_KEEP", "XLATE_PROCS",
|
||||
"ZSTD_CHECK", "ZSTD_NATIVE",
|
||||
|
||||
@@ -872,6 +872,22 @@ static void evict_idle(uint64_t want, uint64_t used, uint64_t budget) { // tex
|
||||
}
|
||||
}
|
||||
|
||||
// NX2NAVI_TEX_COMMIT_EVICT (default on; 0 = off): while the system's commit is low (commit_is_low), idle live textures
|
||||
// go as under VRAM pressure (evict_idle), COMMIT_EVICT_STEP at a time, once the released entries are down to
|
||||
// COMMIT_LOW_KEEP. The driver charges device memory to the commit too, and the eviction above starts only at
|
||||
// NX2NAVI_TEX_VRAM_PRESSURE of the device's budget: on a 16-32 GB card the textures of every area visited stayed until
|
||||
// the commit ran out (27-37 GB processes, then a failed allocation or a device lost, #177 #203 #215), as nothing else
|
||||
// gave them back while they stayed below that share of the video memory.
|
||||
#define COMMIT_EVICT_STEP ((uint64_t)256 << 20)
|
||||
static int commit_evict_on = -1;
|
||||
static void commit_evict(void) { // tex_lock held
|
||||
if (commit_evict_on < 0) commit_evict_on = rt_knob("TEX_COMMIT_EVICT", "1") == 1;
|
||||
if (!commit_evict_on || !tex_evict || rel_bytes > COMMIT_LOW_KEEP || !commit_is_low()) return;
|
||||
uint64_t used = 0, budget = 0;
|
||||
vk_mem_vram_live(&used, &budget);
|
||||
evict_idle(COMMIT_EVICT_STEP, used, budget);
|
||||
}
|
||||
|
||||
static void sweep_pressure(void) { // tex_lock held
|
||||
if (vram_pressure < 0) {
|
||||
const char *s = cfg_get("NX2NAVI_TEX_VRAM_PRESSURE");
|
||||
@@ -901,10 +917,12 @@ static void sweep_pressure(void) { // tex_lock held
|
||||
}
|
||||
if (tex_evict && freed < over) evict_idle(over - freed, used, budget);
|
||||
}
|
||||
if (!rel_head) return;
|
||||
uint64_t cap = released_cap_bytes();
|
||||
if (rel_bytes > cap) drop_stale(cap, &n_cap_drops);
|
||||
if (rel_bytes > COMMIT_LOW_KEEP && commit_is_low()) drop_stale(COMMIT_LOW_KEEP, &n_commit_drops);
|
||||
if (rel_head) {
|
||||
uint64_t cap = released_cap_bytes();
|
||||
if (rel_bytes > cap) drop_stale(cap, &n_cap_drops);
|
||||
if (rel_bytes > COMMIT_LOW_KEEP && commit_is_low()) drop_stale(COMMIT_LOW_KEEP, &n_commit_drops);
|
||||
}
|
||||
commit_evict();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- per-frame texture work (vk.h VK_TS_*)
|
||||
|
||||
Reference in New Issue
Block a user