mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 01:49:58 -04:00
Let NX2NAVI_VRAM_BUDGET_MB lower the VRAM budget the memory decisions use, for testing.
With it set, the mirror budget check and the texture pressure checks compare with at most that many MiB, so a large card behaves as a small one does when video memory runs low. The heap lines still log what the driver reports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -58,7 +58,7 @@ static const char *const known[] = {
|
||||
"SHADER_MEMO", "SHADOW_COMPARE", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR",
|
||||
"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", "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", "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", "WINDOW_SIZE", "XLATE", "XLATE_ID", "XLATE_KEEP", "XLATE_PROCS",
|
||||
"ZSTD_CHECK", "ZSTD_NATIVE",
|
||||
|
||||
@@ -624,7 +624,21 @@ void vk_mem_census(uint64_t frame) {
|
||||
window_start = frame;
|
||||
}
|
||||
|
||||
int vk_mem_vram(uint64_t *used, uint64_t *budget, int *exact) {
|
||||
// NX2NAVI_VRAM_BUDGET_MB (test; unset or 0: the device's): the device-local budget every decision here and in
|
||||
// vk_texture.c compares with is at most this many MiB, so a large card behaves as a small one does under pressure
|
||||
// (mirrors refused or evicted, textures dropped). The heap lines still log what the driver reports.
|
||||
static uint64_t budget_cap(void) {
|
||||
static int64_t mb = -1;
|
||||
if (mb < 0) {
|
||||
const char *s = cfg_get("NX2NAVI_VRAM_BUDGET_MB");
|
||||
int64_t v = s && *s ? atoll(s) : 0;
|
||||
if (v > 0) rt_log("mem: the VRAM budget is taken as at most %lld MiB (NX2NAVI_VRAM_BUDGET_MB, a test)", (long long)v);
|
||||
mb = v > 0 ? v : 0;
|
||||
}
|
||||
return (uint64_t)mb << 20;
|
||||
}
|
||||
|
||||
static int vram_query(uint64_t *used, uint64_t *budget, int *exact) {
|
||||
VkCtx *c = vk_ctx();
|
||||
*used = *budget = 0, *exact = 0;
|
||||
if (!c) return 0;
|
||||
@@ -647,6 +661,13 @@ int vk_mem_vram(uint64_t *used, uint64_t *budget, int *exact) {
|
||||
return *budget != 0;
|
||||
}
|
||||
|
||||
int vk_mem_vram(uint64_t *used, uint64_t *budget, int *exact) {
|
||||
int ok = vram_query(used, budget, exact);
|
||||
uint64_t cap = budget_cap();
|
||||
if (ok && cap && *budget > cap) *budget = cap;
|
||||
return ok;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- page write generations
|
||||
// Two-level table over the guest address space (below 2^39): 256 MiB chunks of 65,536 page generations, allocated
|
||||
// when a page of the chunk is first stamped. 0 = never stamped.
|
||||
|
||||
Reference in New Issue
Block a user