mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 02:39:57 -04:00
Raise the frame rate: fewer copies into the VRAM mirrors, earlier GPU starts, render target images reused.
From the local fixes package (fix 11), measured in Kokiri Forest at 4K on an RTX 4090 over PCIe 3.0: 40.5 to 62.6 fps native and 45.6 to 74.9 fps with DLSS Quality, the mirror copies from 6.5 to 0.3 ms of GPU time a frame. - Pages a VRAM mirror wrote back into guest memory are not copied up into it again: the mirror sync reads page stamps of their own that a mirror's write-back leaves alone (vk_gpu_written_back, decided at record time by vk_mem_mirrored). This replaces the lookup table NX2NAVI_WB_NO_REUP had, keeps its name, and is now on by default. - The game's flushes of mirrored memory are not copied where the write watch covers the region, as every page the game wrote there is stamped already (47-57 MiB a frame); NX2NAVI_FLUSH_UPLOAD=1 copies them as before. - Written storage ranges up to NX2NAVI_WB_MERGE_MAX (now 32 MiB) are merged in 4 MiB pieces, so a range is no longer bound to what one dispatch covers; the snapshot pool keeps its budget-scaled size with 128 slots. - A submission's first part goes to the GPU at the first pass boundary while the GPU is idle (split_idle), long passes are split too (split_in_pass), and the part's time limit reads the clock less often. - A render target that needs an image of its own takes the image of a released one with the same parameters, released two or more frames before (tex_reuse); memory requirements are kept per parameter set; a released entry another descriptor's entry replaced at its address is kept and taken back. - The memory check reads a page's write-watch bit and stamp under the lock that keeps them together. - The launcher reads the gamepad only while its own window is in front, and does not start a second copy of the game. - make_game.py says why a Python package did not load, not only that it is missing. The fix's per-pass GPU timing is left out: NX2NAVI_GPU_PASSES does the same in main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -115,7 +115,7 @@ typedef struct {
|
||||
uint32_t aspect, level0, levels, layer0, layers, swz;
|
||||
} ViewKey;
|
||||
_Static_assert(sizeof(ViewKey) == 40, "ViewKey is hashed as bytes: no padding");
|
||||
typedef struct { uint64_t addr, size; } Range;
|
||||
typedef struct { uint64_t addr, size; int back; } Range; // back: written into a VRAM mirror (vk_mem_mirrored)
|
||||
typedef struct {
|
||||
Chunk *chunks;
|
||||
int nchunks, cchunks;
|
||||
@@ -222,7 +222,9 @@ static uint64_t bind_gen = 1; // bumped by every bind op that writes
|
||||
static void cb_done(void *arg) { // completion thread
|
||||
CbRes *r = arg;
|
||||
VkCtx *c = vk_ctx();
|
||||
for (int i = 0; i < r->nwritten; i++) vk_gpu_written(r->written[i].addr, r->written[i].size);
|
||||
for (int i = 0; i < r->nwritten; i++)
|
||||
if (r->written[i].back) vk_gpu_written_back(r->written[i].addr, r->written[i].size);
|
||||
else vk_gpu_written(r->written[i].addr, r->written[i].size);
|
||||
for (int i = 0; i < r->npools; i++) {
|
||||
vkResetDescriptorPool(c->device, r->pools[i], 0);
|
||||
plat_mutex_lock(&spare_lock);
|
||||
@@ -319,7 +321,7 @@ static void note_written(VkExec *ex, uint64_t addr, uint64_t size) {
|
||||
for (int i = 0; i < r->nwritten; i++)
|
||||
if (r->written[i].addr == addr && r->written[i].size == size) return;
|
||||
if (r->nwritten == r->cwritten) r->written = grow(r->written, &r->cwritten, sizeof *r->written);
|
||||
r->written[r->nwritten++] = (Range){addr, size};
|
||||
r->written[r->nwritten++] = (Range){addr, size, vk_mem_mirrored(addr, size)};
|
||||
vk_mem_gpu_pending(addr, size);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user