mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 04:19:57 -04:00
Add mem_budget: one place that says how much room the card and the system have.
A thread samples every two seconds the video memory budget against this process's use (vk_mem_vram) and the system's commit headroom and free physical memory (plat_commit_info, plat_mem_info), and turns each side into a level: roomy, normal, tight or critical, with five points of hysteresis upward and a 256 MiB floor. Changes are logged, and the memory report's system line ends with both levels. MEM_BUDGET_TEST_VRAM_MB and MEM_BUDGET_TEST_RAM_MB pretend a side is that small, so that what gives memory back can be tried on a large machine; the texture cache's rules are unchanged. tests/mem_budget_check.py checks the levels and the hysteresis. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "mem_budget.h"
|
||||
#include "vk.h"
|
||||
#include "platform/platform.h"
|
||||
#include "vk_dlaa.h"
|
||||
@@ -763,7 +764,8 @@ int vk_init(void) {
|
||||
plat_mutex_lock(&g_lock);
|
||||
if (!g_ready) {
|
||||
memset(&g_vk, 0, sizeof g_vk);
|
||||
if (create_instance() && pick_device() && create_device()) g_ready = 1, vk_headroom_start(), vk_dlaa_init();
|
||||
if (create_instance() && pick_device() && create_device())
|
||||
g_ready = 1, vk_headroom_start(), vk_dlaa_init(), mem_budget_vram(1);
|
||||
else destroy_all();
|
||||
}
|
||||
int ok = g_ready;
|
||||
@@ -773,7 +775,7 @@ int vk_init(void) {
|
||||
|
||||
void vk_shutdown(void) {
|
||||
plat_mutex_lock(&g_lock);
|
||||
if (g_ready) { destroy_all(); g_ready = 0; }
|
||||
if (g_ready) { mem_budget_vram(0); destroy_all(); g_ready = 0; }
|
||||
plat_mutex_unlock(&g_lock);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user