mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 05:49:57 -04:00
Give Linux a memory limit that the low-memory handling can read.
Linux overcommits, so plat_commit_enforced was 0 there and nothing the runtime does when memory runs short ever ran: no stale-texture drops, no idle or disuse eviction. plat_commit_info on Linux now reports the limit with the least headroom of the cgroup v2 limits the process lives under (memory.max, memory.high, against memory.current less its file cache), the machine's RAM (MemAvailable against MemTotal) and, with vm.overcommit_memory = 2, the commit limit; a read is reused for 250 ms and the first one is logged. The spare VRAM blocks stand down under low memory only where device memory counts against that limit (plat_commit_counts_vram: Windows, and any integrated GPU). Windows behaves as before. Pull request #378 by mooki000, taken as it is. The Windows files compile; the Linux code is not compiled or run here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -19,8 +19,11 @@
|
||||
// until the next free of its type, and these types seldom free anything.
|
||||
// Under VRAM pressure no headroom is kept: the spare block counts against the budget that decides whether a pool gets
|
||||
// its VRAM mirror (vk_memory.c), so while use plus two blocks passes 85% of the budget the anchor goes and nothing new
|
||||
// is allocated. Nor while the system's commit is low (vk_texture_commit_low): the driver charges device memory to it,
|
||||
// and a spare block of each type held up to 256 MiB of it empty when an allocation that failed there ended the game.
|
||||
// is allocated. Nor while the system's commit is low (vk_texture_commit_low) where device memory counts against it:
|
||||
// on Windows the driver charges device memory to the commit, and a spare block of each type held up to 256 MiB of it
|
||||
// empty when an allocation that failed there ended the game; an integrated GPU's memory is the machine's RAM. Linux's
|
||||
// limits (plat_commit_counts_vram) do not count a discrete card's own memory, so dropping its spare would free nothing
|
||||
// they count and only put the block allocations back on the render thread.
|
||||
// NX2NAVI_VRAM_HEADROOM=0 turns it off.
|
||||
|
||||
#include "cfg.h"
|
||||
@@ -106,7 +109,9 @@ static VkDeviceSize block_size(const VkCtx *c, uint32_t type) {
|
||||
}
|
||||
|
||||
static int room(const VkCtx *c, uint32_t type, VkDeviceSize block) {
|
||||
if (vk_texture_commit_low()) return 0;
|
||||
if (vk_texture_commit_low() &&
|
||||
(plat_commit_counts_vram() || c->props.deviceType != VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU))
|
||||
return 0;
|
||||
VmaBudget b[VK_MAX_MEMORY_HEAPS];
|
||||
vmaGetHeapBudgets(c->vma, b);
|
||||
const VmaBudget *h = &b[c->mem_props.memoryTypes[type].heapIndex];
|
||||
|
||||
Reference in New Issue
Block a user