mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 17:29: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:
@@ -1675,7 +1675,13 @@ void plat_child_stop(PlatChild *c) {
|
||||
// A child that died makes the write fail with EPIPE; SIGPIPE is ignored for the process (main.c), as Windows has none.
|
||||
int plat_child_write(PlatChild *c, const void *data, size_t n) { return write_all(c->in, data, n); }
|
||||
|
||||
// See win32.c plat_child_read: a child that never answers fails the read after PLAT_CHILD_READ_MS.
|
||||
long plat_child_read(PlatChild *c, void *buf, size_t cap) {
|
||||
struct pollfd pf = {.fd = c->out, .events = POLLIN};
|
||||
int r;
|
||||
do r = poll(&pf, 1, PLAT_CHILD_READ_MS);
|
||||
while (r < 0 && errno == EINTR);
|
||||
if (r <= 0) return -1; // timed out or failed
|
||||
ssize_t k;
|
||||
do k = read(c->out, buf, cap);
|
||||
while (k < 0 && errno == EINTR);
|
||||
|
||||
@@ -425,7 +425,8 @@ typedef struct PlatChild PlatChild;
|
||||
PlatChild *plat_child_start(const char *exe, const char *arg, uint32_t *err);
|
||||
void plat_child_stop(PlatChild *c); // kills the child and frees c
|
||||
int plat_child_write(PlatChild *c, const void *data, size_t n); // 1 when all n bytes were written
|
||||
long plat_child_read(PlatChild *c, void *buf, size_t cap); // bytes read (at least 1); 0 or negative: pipe broke
|
||||
#define PLAT_CHILD_READ_MS 120000 // plat_child_read gives up on a child that sends nothing for this long
|
||||
long plat_child_read(PlatChild *c, void *buf, size_t cap); // bytes read (at least 1); 0 or negative: pipe broke or timed out
|
||||
|
||||
// ---- local IPC: a stream connection to another program of this machine, one listen location per name (Discord's
|
||||
// Rich Presence, discord_rpc.c). On Windows the named pipe \\.\pipe\<name>; on Linux the Unix domain socket
|
||||
|
||||
@@ -693,6 +693,19 @@ static LONG CALLBACK crash_veh(EXCEPTION_POINTERS *ep) {
|
||||
DWORD w;
|
||||
if (n > 0) WriteFile(GetStdHandle(STD_ERROR_HANDLE), b, (DWORD)n, &w, NULL);
|
||||
}
|
||||
// the caller's registers (the object a call through a table read its pointer from is often one of them)
|
||||
const CONTEXT *x = ep->ContextRecord;
|
||||
char b[600];
|
||||
int n = snprintf(b, sizeof b,
|
||||
"[host] crash_veh: rax %#llx rbx %#llx rcx %#llx rdx %#llx rsi %#llx rdi %#llx rbp %#llx r8 %#llx "
|
||||
"r9 %#llx r12 %#llx r13 %#llx r14 %#llx r15 %#llx\n",
|
||||
(unsigned long long)x->Rax, (unsigned long long)x->Rbx, (unsigned long long)x->Rcx,
|
||||
(unsigned long long)x->Rdx, (unsigned long long)x->Rsi, (unsigned long long)x->Rdi,
|
||||
(unsigned long long)x->Rbp, (unsigned long long)x->R8, (unsigned long long)x->R9,
|
||||
(unsigned long long)x->R12, (unsigned long long)x->R13, (unsigned long long)x->R14,
|
||||
(unsigned long long)x->R15);
|
||||
DWORD w;
|
||||
if (n > 0) WriteFile(GetStdHandle(STD_ERROR_HANDLE), b, (DWORD)n, &w, NULL);
|
||||
}
|
||||
const char *what = code == EXCEPTION_ACCESS_VIOLATION ? "access violation"
|
||||
: code == EXCEPTION_ILLEGAL_INSTRUCTION ? "illegal instruction"
|
||||
@@ -1719,7 +1732,18 @@ int plat_child_write(PlatChild *c, const void *data, size_t n) {
|
||||
return WriteFile(c->in, data, (DWORD)n, &put, NULL) && put == n;
|
||||
}
|
||||
|
||||
// A child that stays alive but never answers (a translator stuck on one program) used to block the reader for good,
|
||||
// and with it the draw or dispatch waiting for that shader: after PLAT_CHILD_READ_MS without a byte the read fails,
|
||||
// and the caller stops the child (gfx_shader.c svc_request). The pipe is anonymous, so readiness is polled.
|
||||
long plat_child_read(PlatChild *c, void *buf, size_t cap) {
|
||||
ULONGLONG t0 = GetTickCount64();
|
||||
for (unsigned spins = 0;; spins++) {
|
||||
DWORD avail = 0;
|
||||
if (!PeekNamedPipe(c->out, NULL, 0, NULL, &avail, NULL)) return -1; // broken: the child exited
|
||||
if (avail) break;
|
||||
if (GetTickCount64() - t0 > PLAT_CHILD_READ_MS) return -1;
|
||||
Sleep(spins < 50 ? 0 : 1);
|
||||
}
|
||||
DWORD got = 0;
|
||||
if (!ReadFile(c->out, buf, (DWORD)cap, &got, NULL)) return -1;
|
||||
return (long)got;
|
||||
|
||||
Reference in New Issue
Block a user