mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 13:09:57 -04:00
Release pass: fix crashes, freezes and races, cut VRAM use, and translate more shaders.
Crashes: the render-target heap (HeapDef DynamicTextureAllocatorMem and its parent) grows with the widescreen picture, so the pause menu no longer reads a null block at 5120x2160; texture uploads keep the game's memory mapped while they copy it, so UnmapPhysicalMemory no longer pulls it away mid-copy; DLSS Frame Generation no longer crashes in Streamline's set-up (physical devices and the window surface go through its proxies, its swapchain images are counted first, resources are tagged per frame); a stale core-wait target is cleared before its thread is freed. Freezes and races: a resize during a swapchain rebuild is kept, a failed frame generation swapchain is retried instead of replaced by a plain one, three acquire timeouts in a row rebuild the swapchain, device waits take the queue lock, a translator child that stops answering times out, an in-flight compute pipeline builds at normal priority, a save Commit started before the window closes finishes and none starts after, a settings change just before closing is saved, and a movie sample taken before a flush is dropped. HDR: Enhanced HDR extends the game's own tonemap so highlights go above the picture's white (the hue slider, which no longer applies, is gone from the menu); frame generation gets a HUD-less picture, the HDR flag and the HDR10 metadata under HDR too. Memory: ASTC textures are encoded to BC3 unless the PC has 20 GiB of VRAM and 48 GiB of RAM, as Windows charges video memory to the commit charge (a long session held 17 GiB of RGBA8 textures and 45.7 GiB of commit on a 32 GiB PC). Shaders: the translator lowers spill-mode programs with more than eight uniform register groups in a wider spill layout, and local loads and stores with a uniform-register address (36029 of the game's 36031 variants translate, 20 failed before). The launcher release ships the shader tools and AMD's FidelityFX library (make_launcher.py --ffx); windres there gets the toolchain on PATH. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -508,23 +508,52 @@ static uint64_t run_start(const uint8_t *p, uint64_t i, uint8_t v) { // first
|
||||
return i;
|
||||
}
|
||||
|
||||
// Whether every byte of [a, a + n) can be read: no free, inaccessible or no-access page (mem_query's regions). For
|
||||
// host reads of guest memory the guest itself may never make, such as a texture upload of a pool slot no shader
|
||||
// samples (vk_exec_draw.c, texture pools: stale slots point at unmapped memory).
|
||||
int mem_readable(uint64_t a, uint64_t n) {
|
||||
static void query_locked(uint64_t a, RtMemoryInfo *out);
|
||||
|
||||
static int readable_locked(uint64_t a, uint64_t n) {
|
||||
for (uint64_t end = a + n; a < end;) {
|
||||
RtMemoryInfo r;
|
||||
mem_query(a, &r);
|
||||
query_locked(a, &r);
|
||||
if (r.state == ST_FREE || r.state == ST_INACCESSIBLE || !(r.perm & PERM_R) || r.base + r.size <= a) return 0;
|
||||
a = r.base + r.size;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Whether every byte of [a, a + n) can be read: no free, inaccessible or no-access page (mem_query's regions). For
|
||||
// host reads of guest memory the guest itself may never make, such as a texture upload of a pool slot no shader
|
||||
// samples (vk_exec_draw.c, texture pools: stale slots point at unmapped memory).
|
||||
int mem_readable(uint64_t a, uint64_t n) {
|
||||
plat_mutex_lock_shared(&lock);
|
||||
int ok = readable_locked(a, n);
|
||||
plat_mutex_unlock_shared(&lock);
|
||||
return ok;
|
||||
}
|
||||
|
||||
// mem_readable for a read that takes a while on another thread than the guest's: with 1 the range stays mapped until
|
||||
// mem_read_release, as unmapping it (UnmapPhysicalMemory, a smaller heap, a moved stack) waits for the lock. A pool
|
||||
// slot's storage the game has just released could otherwise be decommitted halfway through the copy (a texture
|
||||
// upload faulted that way in tex_bl_copy). In between, the caller takes no lock of this file (mem_query, mem_readable
|
||||
// and the mapping calls would wait for themselves). 0: not readable, and nothing held.
|
||||
int mem_read_hold(uint64_t a, uint64_t n) {
|
||||
plat_mutex_lock_shared(&lock);
|
||||
if (readable_locked(a, n)) return 1;
|
||||
plat_mutex_unlock_shared(&lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mem_read_release(void) { plat_mutex_unlock_shared(&lock); }
|
||||
|
||||
uint32_t mem_query(uint64_t a, RtMemoryInfo *out) {
|
||||
plat_mutex_lock_shared(&lock);
|
||||
query_locked(a, out);
|
||||
plat_mutex_unlock_shared(&lock);
|
||||
return R_OK;
|
||||
}
|
||||
|
||||
static void query_locked(uint64_t a, RtMemoryInfo *out) {
|
||||
RtMemoryInfo r = {.base = a & ~(PAGE - 1), .size = PAGE};
|
||||
uint64_t low = L.aslr.base;
|
||||
plat_mutex_lock_shared(&lock);
|
||||
int mi;
|
||||
if (a >= RT_ADDRESS_LIMIT) {
|
||||
r.base = RT_ADDRESS_LIMIT;
|
||||
@@ -590,9 +619,7 @@ uint32_t mem_query(uint64_t a, RtMemoryInfo *out) {
|
||||
r.base = lo;
|
||||
r.size = hi - lo;
|
||||
}
|
||||
plat_mutex_unlock_shared(&lock);
|
||||
if (out) *out = r;
|
||||
return R_OK;
|
||||
}
|
||||
|
||||
// ---- GetInfo memory ids
|
||||
|
||||
Reference in New Issue
Block a user