mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 14:05:57 +00:00
Wait out a short out-of-memory spell instead of ending the game
Crash logs ended in fatal errors when the system's commit ran out for a moment: a staging buffer (-2), a guest commit with the system at 24442 of 24447 MB, image creation (-2). Windows grows a system-managed page file and some drivers charge device memory to the process commit, so the same request often succeeds a moment later. oom.c holds the wait nvn_api_cmd.c realloc_wait already used: it requests a release, retries every 10 ms for up to 30 s, logs the first 8 with the commit numbers. rt_oom_request sets a flag that vk_texture_new_submit takes (one atomic load per submit): it drops up to 256 released textures of the two kinds sweep_pressure drops (overwritten, clean mirrored), never GPU-written content, and frees the headroom blocks. vk_oom_release does at once what needs no submit: headroom blocks, finished upload batches and deferred objects. - memory.c commit: waits and retries without frz_lock between tries; every caller waits, boot ones too. - vk_staging and the draw-data chunks (vk_exec_draw.c scratch): release, then wait; the open upload batch is not submitted, its caller still records into it. - create_tex: release and one retry; no wait under the texture lock, the texture is asked for again at its next use. - the texture write-back buffer: release, then wait. - the headroom thread keeps no spare block for 30 s after a failure. TOTK_TEST_OOM=<site>:<n> (commit, staging, image, chunk) fails the first n attempts; probe-kernel forces 3 refused commits, probe-vkexec 2 staging buffers, 1 image and 1 chunk, and both pass through them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e479f593b
commit
213bc6af6a
13 files changed
+323
-32
No files matched your search
@@ -314,6 +314,8 @@ int vk_mem_uma(void); // 1: the device class is uma (vk_
|
||||
const VmaDeviceMemoryCallbacks *vk_headroom_callbacks(void);
|
||||
void vk_headroom_start(void);
|
||||
void vk_headroom_stop(void); // before vmaDestroyAllocator
|
||||
void vk_headroom_release(void); // after a failed allocation: frees the spare blocks and keeps none for a while;
|
||||
// any thread that holds no VMA lock (takes only the headroom lock)
|
||||
int vk_mem_resolve(uint64_t addr, uint64_t size, VkMemSpan *out); // 1 when all of [addr, addr+size) is backed
|
||||
// Changes whenever vk_mem_resolve plus VK_MEM_USE may give another span for an address: a pool added, finalized or
|
||||
// mapped, a mirror created, refused or forgotten, a submission started.
|
||||
@@ -402,6 +404,10 @@ int vk_mem_span_live(const VkMemSpan *sp);
|
||||
void vk_mem_note_fence(uint64_t timeline_value);
|
||||
void vk_mem_fault_log(void); // vk_device_fault_report: the deferred-free state, lock-free
|
||||
void vk_mem_collect(void); // frees what has completed
|
||||
// After a failed allocation, on a thread that may hold the texture lock and the upload lock (cmd_lock) but no VMA
|
||||
// lock: frees the headroom blocks and the completed upload batches and deferred objects, and requests the release
|
||||
// of released textures at the next submit (rt_oom_request).
|
||||
void vk_oom_release(void);
|
||||
typedef struct { uint64_t imported_pools, physical_pools, virtual_pools, import_failures, upload_batches; } VkMemStats;
|
||||
void vk_mem_stats(VkMemStats *s);
|
||||
void vk_mem_shutdown(void); // before vk_shutdown: waits idle, frees every memory and texture object
|
||||
|
||||
Reference in new issue
Block a user