mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-24 13:45:57 +00:00
heap_lazy also commits the chunks a Vulkan import widens into when the driver's host pointer alignment is above 4 KiB, and the memory.c comment names mem_heap_commit for save writes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d66aeef75c
commit
a0587b59e7
2 files changed
+5
-2
No files matched your search
+2
-2
@@ -210,8 +210,8 @@ static void commit(uint64_t a, uint64_t n, const char *what) {
|
||||
// SetHeapSize adds stays reserved: the first read or write of a reserved page faults, and heap_fault commits its
|
||||
// LAZY_CHUNK and retries. Freshly committed pages read as zero, as the Switch's heap does. Access by the kernel or the GPU
|
||||
// driver does not fault: a file read into the heap, a save written from it and a Vulkan import of it would fail on a
|
||||
// reserved page. All of them call mem_thaw first, so mem_thaw commits the reserved chunks of its range too
|
||||
// (heap_commit_range). Linux backs mprotect'ed pages on first use by itself and keeps committing eagerly.
|
||||
// reserved page. File reads and Vulkan imports call mem_thaw first, so mem_thaw commits the reserved chunks of its
|
||||
// range too (heap_commit_range); save writes only need the pages to exist and call mem_heap_commit. Linux backs mprotect'ed pages on first use by itself and keeps committing eagerly.
|
||||
//
|
||||
// lazy_map holds one byte per chunk, set once the chunk is committed, so neither path asks the OS for the page state:
|
||||
// a VirtualQuery costs tens of microseconds here, and the write faults of frozen pool regions (thaw_fault) come through
|
||||
|
||||
@@ -128,6 +128,9 @@ static int import_pool(VkCtx *c, PoolRec *r, uint64_t addr, uint64_t size) {
|
||||
r->import_lo = addr & ~(al - 1);
|
||||
r->import_hi = (addr + size + al - 1) & ~(al - 1);
|
||||
uint64_t n = r->import_hi - r->import_lo;
|
||||
// TOTK_HEAP_LAZY: the caller's mem_thaw committed the pool's own chunks; an alignment above 4 KiB can widen the
|
||||
// import into a neighbouring chunk the game never touched, and the driver refuses reserved pages.
|
||||
mem_heap_commit(r->import_lo, n);
|
||||
VkMemoryHostPointerPropertiesEXT hp = {.sType = VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT};
|
||||
VkResult res = p_host_props ? p_host_props(c->device, VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT,
|
||||
(void *)(uintptr_t)r->import_lo, &hp)
|
||||
|
||||
Reference in new issue
Block a user