mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 07:09:57 -04:00
Merge the stability and memory pass into the 0.10.0 line.
Conflicts: the settings key lists and section maps take both sides' entries. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -121,6 +121,13 @@ memory runs short, it ends the process, so while less than the larger of 4 GB an
|
||||
drops stale textures and evicts idle ones. The log names the limits at the first check (`platform: memory limits`). That
|
||||
cannot give back what the game needs after its start: about 10 GB in Kokiri Forest at a 2160p game resolution.
|
||||
|
||||
Without NVIDIA's driver, the game hands its memory to the GPU through `/dev/udmabuf` instead of copying it there for
|
||||
every submission, which is faster on AMD cards (61 frames a second instead of 40 in Kokiri Forest on an RX 6800 XT).
|
||||
That needs the device readable and writable by you (recent systemd gives it to the logged-in user) and udmabuf's
|
||||
`size_limit_mb` (`/sys/module/udmabuf/parameters/size_limit_mb`) at 1024 or more (`udmabuf.size_limit_mb=1024` on the
|
||||
kernel command line raises it). Otherwise the game copies as before, and the log's `mem:` lines say why
|
||||
(`docs/building.md`, "Memory").
|
||||
|
||||
AMD FSR 3.1 loads AMD's `amd_fidelityfx_vk.dll`, which only the Windows build can use: on Linux the menu offers neither
|
||||
FSR 3.1 upscaling nor FSR 3.1 frame generation, and `taa = fsr3` or `framegen = fsr3` in `nx2navi.ini` leave the
|
||||
game's own scaling and swapchain as they are (the log says so). AMD FSR 4 is in the Windows build alone for the same
|
||||
|
||||
@@ -115,8 +115,14 @@ keeps per-core data without locks and relies on that, so the host models it (`ru
|
||||
`menu_boot_frame`). With the graphics pipeline library the boot builds recorded pipelines in record order for at
|
||||
most 20 s after the shaders are ready and leaves the rest to the pipeline workers below normal priority; a draw
|
||||
that meets one before it is built gets a fast-linked pipeline (`vk_pipeline.c` `PREWARM_PIPE_MS`).
|
||||
`NX2NAVI_PREWARM_FULL=1`, and drivers without the library, wait for every pipeline. `NX2NAVI_PREWARM_WAIT_MS` caps
|
||||
the whole wait, after which the rest finishes in the background.
|
||||
`NX2NAVI_PREWARM_FULL=1`, and drivers without the library, wait for every pipeline. A start that finds the
|
||||
pipeline cache written by another GPU or driver waits for the whole warm on that screen, since nothing is built
|
||||
then and all of it would compile beside the game: every recorded pipeline, the compute pipelines, and the
|
||||
prepared shader variants built into the driver's own cache when a sample says it lacks them (`vk_pipeline.c`
|
||||
`bf_decide`, `bf_wait`). `boot-warm-owed.txt` next to the caches lets a start go on with a warm that an earlier
|
||||
one began and did not end, three starts at most, and says when the warm for a GPU and driver is done
|
||||
(`runtime/boot_warm.h`); `NX2NAVI_PREWARM_FULL=0` turns it off.
|
||||
`NX2NAVI_PREWARM_WAIT_MS` caps the whole wait, after which the rest finishes in the background.
|
||||
- Translator updates: every cache key names the translator, so a new one has no translations. The cache carries the
|
||||
previous translator's (`NX2NAVI_SHADER_CARRY`, `runtime/gfx_shader.c` "Carry"): `shader-cache/identities.txt`
|
||||
lists the translators it holds translations of, and a shader the new translator has not translated yet uses the
|
||||
|
||||
@@ -279,7 +279,8 @@ folder can be deleted; `ocarina --warm-shaders` fills it again.
|
||||
|
||||
Memory: on Windows the GPU imports guest memory and `GetWriteWatch` tracks the CPU's writes to it. On Linux,
|
||||
re-protecting imported memory invalidates the driver's userptr buffer on every submit (about 1.3 ms per 16 MiB on
|
||||
amdgpu), and importing pins the pages, which drops their write protection. Each CPU-visible pool therefore gets a
|
||||
amdgpu), and importing pins the pages, which drops their write protection. Where guest memory cannot be imported as
|
||||
dma-bufs (below), each CPU-visible pool therefore gets a
|
||||
host-visible copy (shadow storage, `runtime/vk_memory.c`): the pages the CPU wrote go in before each submit, and the GPU's
|
||||
writes come back at its fence. Pages both sides write keep a base copy, so each direction moves only its own bytes;
|
||||
a VRAM mirror's write-back merge marks the pages it changed, and only those are compared at the fence; a lookup that
|
||||
@@ -295,6 +296,30 @@ copies are only the slower path. In Kokiri Forest on 0.7.1 (RTX 4090, driver 615
|
||||
51.9 frames a second and the copies at 27.4; on that version the copies also flickered between two looks almost every
|
||||
frame, which the wait for the write-backs under shadow storage (`vk_sync_exec_wait`) has since addressed.
|
||||
|
||||
On Linux the pools are imports after all where the system allows dma-bufs of guest memory (`runtime/platform/linux.c`,
|
||||
"Guest memory as a memfd's"; `runtime/vk_memory.c`, "dma-buf imports"). The watched reservations are then shared
|
||||
mappings of one memfd, `/dev/udmabuf` makes dma-bufs of page ranges of it, and the device imports those
|
||||
(`VK_KHR_external_memory_fd`, `VK_EXT_external_memory_dma_buf`). A dma-buf pins its pages once and is not tied to the
|
||||
process's page tables, so the write watch and the freezes leave the GPU's mapping alone, and nothing is copied. RADV
|
||||
puts every imported memory object into every submission (about 0.6 us each), and the game keeps over 4,000 pools, so
|
||||
pools share their imports: guest addresses are cut into spans of 64 MiB (`NX2NAVI_DMABUF_MB`), and a pool is a buffer
|
||||
bound into its span's memory at its offset. A new span is cut back at the spans already there, so spans overlap only
|
||||
where a pool itself lies across an older span's edge: amdgpu counts every span's pages in its GTT use, an overlap twice.
|
||||
A span pins all of its pages, those the game never touched included, until some frames after its last pool is gone. It
|
||||
takes `/dev/udmabuf` readable and writable by the player (recent systemd gives it to the logged-in user with its
|
||||
`uaccess` tag; elsewhere it is often `root` and group `kvm` only), udmabuf's `size_limit_mb`
|
||||
(`/sys/module/udmabuf/parameters/size_limit_mb`) at 1024 or more, since the largest pools need about 300 MiB in one
|
||||
dma-buf (where it is lower, `udmabuf.size_limit_mb=1024` on the kernel command line raises it), a device with both
|
||||
extensions, and NVIDIA's kernel module not loaded: NVIDIA's own driver imports host pointers without amdgpu's cost, as
|
||||
above. A start-up probe imports one page of guest memory as the pools will be; where anything is missing or refused, the
|
||||
pools keep their shadow copies and the log says why (`mem: dma-buf imports off`, `mem: guest memory is not a memfd's`).
|
||||
`NX2NAVI_DMABUF=0` keeps the copies, and `NX2NAVI_DMABUF=1` makes guest memory a memfd's even where NVIDIA's module is
|
||||
loaded; both only from the environment, since the reservations are made before `nx2navi.ini` is read. `NX2NAVI_SHADOW=1`
|
||||
still forces the copies. In Kokiri Forest (1.1.1, RX 6800 XT, Mesa 26.2) the imports ran at 60.7 frames a second and the
|
||||
copies at 40.3, in Hyrule Field at 55.7 and 42.4; the spans then held 8.0 to 9.6 GiB, and amdgpu counted 8.6 to 10.1 GiB
|
||||
of its 15.8 GiB host heap in use, against 5.2 to 5.6 GiB with the copies, which are memory of their own beside guest
|
||||
memory.
|
||||
|
||||
The device address table (`runtime/vk_gpa.c`) names a pool's shadow copy as it names an import, so shaders follow guest
|
||||
pointers into either. A shader that reads through the table resolves nothing, so the pool it reaches is not queued for
|
||||
the copy-in: a guest submission whose record binds the table (`vk_exec_draw.c` `ssbo_info`) brings the shadow of
|
||||
@@ -315,12 +340,13 @@ write-backs landed on pages the CPU had written since their copy-in, and what th
|
||||
plain CPU write and a guest submission that does not bind the table, and hold the written `0x2468ACE0` after one that
|
||||
does; and with `NX2NAVI_SHADOW_TABLE_STORES=1` the store: a GPU
|
||||
write into a shadow page that nothing notes must survive the CPU's writes of that page and reach guest memory. On
|
||||
Linux, run it for each backing:
|
||||
Linux, run it for each backing (with `NX2NAVI_DMABUF=1` and `NX2NAVI_SHADOW=0` the pools are dma-buf imports, with
|
||||
`NX2NAVI_DMABUF=0` and `NX2NAVI_SHADOW=0` host-pointer imports):
|
||||
|
||||
```sh
|
||||
for shadow in 0 1; do for memory in import mirror; do
|
||||
NX2NAVI_GPA=1 NX2NAVI_SHADOW=$shadow NX2NAVI_MEMORY=$memory ./ocarina --probe-vkmem
|
||||
done; done
|
||||
for dmabuf in 0 1; do for shadow in 0 1; do for memory in import mirror; do
|
||||
NX2NAVI_DMABUF=$dmabuf NX2NAVI_GPA=1 NX2NAVI_SHADOW=$shadow NX2NAVI_MEMORY=$memory ./ocarina --probe-vkmem
|
||||
done; done; done
|
||||
```
|
||||
|
||||
The Deck's GPU (Van Gogh) has no native ASTC, so its textures go through the compute decoder (`runtime/vk_astc.c`,
|
||||
@@ -385,6 +411,11 @@ waits on its event and leaves the others asleep, a wait on several handles repor
|
||||
the wait on it, timed waits keep their time, a cancel ends any wait, and 4,000 signals to eight looping waiters are
|
||||
each seen. It runs a second time with `NX2NAVI_SYNC_WAKE_ALL=1`. No game files.
|
||||
|
||||
A change to what a host thread gives back when it ends (`runtime/platform/win32.c` `thread_main`,
|
||||
`plat_thread_end_hook`) passes `python tests\thread_end_check.py`, which builds the platform layer alone: 416 threads
|
||||
sleep, read a file and end, half joined and half detached; the end hook runs once on each, and on Windows the process
|
||||
holds as many handles afterwards as before (each thread's sleep timer and read event are closed). No game files.
|
||||
|
||||
A change to the log queue (`runtime/logq.c`) passes `python tests\logq_check.py`, which builds it with the platform
|
||||
layer and a destination of its own: 160,000 lines from eight threads arrive whole and in each thread's order, a line
|
||||
logged while the queue's lock is taken waits and does not pass the lines queued before it, a destination that takes
|
||||
@@ -430,6 +461,13 @@ loss at the same moment end the process with exit code 72, one device report and
|
||||
device and opens no window; the device is not really lost, so what a driver answers after a loss is not covered.
|
||||
`device_lost_at = <n>` in `nx2navi.ini` ends a real run the same way at its n-th hand-over to the GPU queue.
|
||||
|
||||
A change to how a fault ends the process (`runtime/main.c` `crash_handler`, `mode_done`) passes
|
||||
`python tests\exit_fault_check.py <game exe>`, which runs two crash probes: a fault inside a library while a mode runs
|
||||
is a crash (one FATAL line, exit code 71), and the same fault after the mode has returned, while the process is ending,
|
||||
leaves the mode's own exit code and one `exit:` line. The second is what a library another program put into the
|
||||
process does when it faults in its detach: an injector's Vulkan layer did so at the end of every shader preparation on
|
||||
a player's PC, and the launcher took each finished preparation for a failed one. No game files, no GPU.
|
||||
|
||||
A change to the memory gate of the background pipeline builds (`runtime/vk_build_gate.h`, `runtime/vk_pipeline.c`
|
||||
`gate_enter`) passes `python tests\build_gate_check.py [<game exe>]`, which builds the header alone and checks what it
|
||||
admits and refuses and that builds under way count through their reservations. With the executable it also runs
|
||||
@@ -455,6 +493,14 @@ A change to the start's memory warning (`runtime/mem_need.h`, `runtime/memory.c`
|
||||
`python tests\mem_need_check.py [<game exe>]`, which builds the header alone and checks when the game's need counts
|
||||
as short. With the executable it also runs `--probe-memneed` (it prints the machine's commit and the answer and
|
||||
starts nothing) with `mem_need_mb` at 0, at 1 and at a value no machine has, and reads the warning line of the last.
|
||||
A change to when a start does the whole warm on the boot screen (`runtime/boot_warm.h`, `runtime/vk_pipeline.c`
|
||||
`bf_decide`) passes `python tests\boot_warm_check.py`, which builds the header alone: the warm after a driver change,
|
||||
its continuation by a later start, the end of the tries, and no second warm once one is done. The warm itself shows
|
||||
in `--probe-prewarm` on a copy of an install's caches whose `pipeline-cache.bin` has another driver's header (bytes
|
||||
8 to 15 of the file are the vendor and device ids, the 16 after them the driver's cache id): the log names the whole
|
||||
warm, the compute pipelines on every core and the library warm's answer, and `boot-warm-owed.txt` ends as "done".
|
||||
Run under an exe name the driver has not seen, the probe compiles everything, as after a real driver update. What
|
||||
the boot screen shows, and the builders' step down when the wait is cut short, need a start of the game.
|
||||
A change to how `pipeline-cache.bin` is read (`runtime/vk_cache_file.h`, `runtime/vk_pipeline.c` `cache_load`) passes
|
||||
`python tests\pipeline_cache_file_check.py`, which builds the header alone and reads a sparse file just over 2 GB
|
||||
through it: measured and read whole without a size limit, refused by its real size under one. No game files, no GPU;
|
||||
|
||||
Reference in New Issue
Block a user