Merge release 0.7.0 into the test line: version 0.7.0 and its notes, and GitHub main d1bebd3 (the previous picture kept on screen for a frame that lacks draws, the game's own VRAM in the overlay).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 05:38:34 -05:00
13 changed files with 268 additions and 36 deletions

View File

@@ -1 +1 @@
0.6.1
0.7.0

View File

@@ -145,6 +145,10 @@ of them.
93 ms (vertex) and 242 ms (fragment) on average against 0.3 and 0.6 ms from the cache, and a first walk through a
village skipped 11,180 draws and made 94 draws wait 5.5 s in all, against 1,605 skipped (1,473 of them in the
scene's first frames) and 60 ms of waits with the cache warm.
A frame that still lacks draws when it is presented is not shown: the previous picture stays on screen
(`runtime/vk_backend.c` `frame_hold`, `NX2NAVI_FRAME_HOLD_MS`, an allowance of 120 ms that fills again at an eighth
of the clock's rate). On a first walk through a village with nothing recorded, 21 of the 23 such frames were held
back; in a player's session a hit by a boulder had shown one black frame, its lighting pass skipped after 50 ms.
When the driver's shader compiler crashes on a variant (NVIDIA 615.78.08 on an RTX 5080 does, issue #30),
`prepare_shaders.py` runs the driver step again with `--warm-shaders`, up to three times, without the variants the
driver was building at the crash. `shader-prepare-skip.txt` next to the exe lists them with the GPU and driver

View File

@@ -1,29 +0,0 @@
Draft notes for the release after 0.6.1. The version number is not decided yet.
## New
- Share a save: *Saves* in the launcher (*Export Save*, *Import a Save*) and *Saves* on the Game tab of the settings
menu write your save into one zip in your Downloads folder, with the game's log and settings for a bug report, and
import a zip someone shared. Attach the bug report zip to a report from a place in the game, so it can be reached
and checked quickly. An import copies your current save to the `saves` folder of the game folder first; in the game
it takes effect at the next start.
- Customize Launcher (on the launcher's home screen): six colour schemes, a background picture of your own with
adjustable dimming, animations (a gliding cursor, sliding screens, drifting sparks) and sound effects: the game's
own select and back sounds, read from your game, quiet (Low) unless you pick another loudness or turn them off.
- Three more settings take effect without a restart: HDR between off and the tone mapper (only the game's native
HDR still waits for one), the camera's stick sensitivity, and the speakers (stereo or 5.1).
## Fixed
- Ground, walls and characters that appeared and disappeared, black or unlit frames, and stalls of up to two seconds
wherever something was shown for the first time (a new area, a cutscene). The graphics driver's cache had lost the
shader libraries prepared at install, so every new pipeline compiled during play: after a driver update, or after
an update of NX2navi that changes how the libraries are built (this one does on AMD RX 7000 and RX 9000 cards,
where it also ends the 20 second start). The game now checks the driver's cache at every start and fills it again in the background by
itself, an update fills it again before you play, draws wait a moment for a pipeline that only needs linking
instead of being left out, and lighting passes are no longer left out at all.
- Textures out of view for 11 seconds at 165 fps (30 seconds were meant) could show a blank stand-in for a few frames
when they came back while memory was short. The wait is now two minutes of real time at any frame rate.
- Settings menu, mouse: a setting changes only on the two framed arrows beside its value, and the arrows stay in one
place. A click anywhere on a row used to step the setting, and the left arrow moved with the value's width, so
clicking through the values landed on the row and stepped the wrong way. Holding the button on an arrow repeats.

142
docs/releases/v0.7.0.md Normal file
View File

@@ -0,0 +1,142 @@
A performance and feature release for *The Legend of Zelda: Ocarina of Time* for Nintendo Switch 2 (game version
1.1.1): a much higher frame rate in open areas and towns, less memory, DLSS Multi Frame Generation, save sharing, a
launcher you can restyle, and many fixes. **No game files are included**: the setup builds the game on your PC from
your own dump.
## Install or update
- **Already have 0.6.0 or 0.6.1:** start the launcher; it offers 0.7.0, updates itself and keeps the game it compiled
and the shaders it prepared. Only what changed is compiled again, and the update fills the graphics driver's cache
again before you play.
- **Already have 0.5.0:** the same, and the game's code 0.5.0 compiled is kept as it was compiled (for any x86-64
processor); *Rebuild the Game* in the launcher's home compiles it again for yours.
- **New install:** download **`NX2navi-Setup-0.7.0.exe`** below, put it next to your `.nup` dump of the game and start
it. Windows SmartScreen warns on the first start because the setup is not signed: choose *More info* and *Run
anyway*. The launcher checks your game files, builds the game (10 to 25 minutes, once), prepares every shader and
starts it.
**Requirements:** Windows 10 or 11; an x86-64 CPU with SSE4.2; 16 GB of RAM; about 30 GB free for the game and 1.5 GB
for the launcher; a GPU with Vulkan 1.3, `VK_EXT_external_memory_host` and `VK_EXT_mesh_shader` (current NVIDIA and AMD
cards).
## Faster
- **Open areas.** What the game's shaders write into its memory was copied back from the video card after every GPU
submission, in case the game's CPU code reads it: 66 MiB a frame in Hyrule Field, more than half of the frame's GPU
time. It is now copied once and after that only when the CPU touches it. Standing in Hyrule Field on our test PC
(RTX 5090, 3416x1440, DLAA) that is 76 fps instead of 57. `wb_lazy = 0` in `nx2navi.ini` brings the old behaviour
back; on Linux it is off unless you set `wb_lazy = 1`.
- **Towns.** Large towns release and take back thousands of textures a second, and every one made the game's texture
table look up about 10,000 entries again. A texture that comes back unchanged now leaves the table alone.
- **Every frame.** The wait after a frame's first GPU submission no longer includes the copy back to memory (3 to 4 ms
a frame), the command recorder no longer spins while it has nothing to do, and work a draw repeats is skipped.
- **Less stutter.** Textures are created over several frames instead of all at once, shaders are read from the disk
off the render thread, a controller that connects or disconnects no longer stalls the game for 100 ms and more, and
DLSS Frame Generation no longer makes 100 to 150 ms frames after menus and cutscenes.
- **Less memory.** With a full shader cache the game holds about 1.7 GiB less video memory from the title screen on
(twenty very large shaders the game never runs were created at every start), video memory blocks are smaller, DLSS
models that are not in use are freed, textures no shader has sampled for two minutes give way when memory runs low,
and textures give way before the game's buffers lose their place in video memory.
## New
- **DLSS Multi Frame Generation** at 2x, 3x and 4x on cards that support it (*Frame generation* on the Screen tab).
With frame generation on and no frame limit chosen, the game limits itself to the display's refresh rate.
- **Share a save:** *Saves* in the launcher (*Export Save*, *Import a Save*) and *Saves* on the Game tab of the
settings menu write your save into one zip in your Downloads folder, with the game's log and settings for a bug
report, and import a zip someone shared. Attach the bug report zip to a report from a place in the game, so it can
be reached and checked quickly. An import copies your current save to the `saves` folder of the game folder first;
in the game it takes effect at the next start.
- **Customize Launcher** (on the launcher's home screen): six colour schemes, a background picture of your own with
adjustable dimming, animations (a gliding cursor, sliding screens, drifting sparks) and sound effects: the game's
own select and back sounds, read from your game, quiet (Low) unless you pick another loudness or turn them off.
- **Texture filtering** on the Screen tab: anisotropic filtering, applied while the game runs.
- More settings take effect without a restart: HDR between off and the tone mapper (only the game's native HDR still
waits for one), the camera's stick sensitivity, the speakers (stereo or 5.1), and the texture sharpness that goes
with the DLSS or FSR 3.1 mode.
- The setup checks every game file and stands in for damaged textures instead of failing later in play.
- On processors whose two dies differ (AMD's two-die X3D models) the game runs on the die with the larger cache.
`cache_die = 0` in `nx2navi.ini` turns that off.
## Fixed
- Ground, walls and characters that appeared and disappeared, black or unlit frames, and stalls of up to two seconds
wherever something was shown for the first time (a new area, a cutscene). The graphics driver's cache had lost the
shader libraries prepared at install, so every new pipeline compiled during play: after a driver update, or after
an update of NX2navi that changes how the libraries are built (this one does on AMD RX 7000 and RX 9000 cards,
where it also ends the 20 second start). The game now checks the driver's cache at every start and fills it again
in the background by itself, an update fills it again before you play, draws wait a moment for a pipeline that only
needs linking instead of being left out, and lighting passes are no longer left out at all.
- A black or unlit frame, or a light or a piece of ground missing for a frame, when something new came on screen (a
hit, a new effect, a new enemy). A draw whose pipeline was not ready in time was left out of that frame, a lighting
pass among them once its 50 ms were spent, and the frame was shown without it. Such a frame is no longer shown:
the previous picture stays for the frame or two it takes, while the game runs on (`frame_hold_ms`, 120 by default;
0 shows every frame as before).
- The performance overlay's VRAM line counted every program on the graphics card as if it were the game. It now
shows the game's own share beside it (*game 6.8 GB* of 10.4 GB in use, in one measurement).
- Textures that turned dark or blank for a moment: textures out of view were dropped after 11 seconds at 165 fps (30
seconds were meant) and came back as a stand-in for a few frames. The wait is two minutes of real time at any frame
rate now, and the scene's textures are kept through a pause.
- Black frames about once a second while the camera turned, and black frames when a picture's memory was handed to a
new texture.
- Red flashing on some screens: the picture the game's last pass really writes is shown.
- The fog no longer leaves dark trails behind nearby objects.
- Above 60 fps, moving platforms should no longer drop you and enemies should track you again: the physics solver's
step count is rounded up and the game gets a steady step. Tell us where it still goes wrong.
- A crash when opening the quick menu at very high frame rates: with the limit unlimited or higher, the game holds
itself to 240 frames a second.
- Crashes when switching between AMD's and NVIDIA's frame generation, and when picking a DLSS mode while FSR 3.1 runs.
FSR 3.1 also keeps running when the render scale changes more than a few times.
- DLSS and DLAA now start on installs whose registry does not say where NVIDIA's NGX library is.
- A crash on Intel GPUs while the pipeline cache was saved.
- A crash on draws with large mesh tables, a rare corruption of vector registers when a game thread was interrupted
(processors without AVX use were unaffected), and seven smaller runtime faults a tester's report named.
- Long sessions: the table of the game's memory addresses no longer runs out, and when the system's memory is nearly
full the game frees textures it can get back instead of only its cache of released ones.
- A movie frame is dropped, or a sound sample tried again, when memory runs out, instead of the game stopping.
- A fault in an audio voice that was released twice.
- A crash report written while the game was closing, although nothing had gone wrong.
- An update over an install that began with 0.5.0 keeps the processor level the game was compiled for, *Rebuild the
Game* compiles for the processor you have now, and the game's code is lifted again after *Keep Build Cache* was off.
- Launcher downloads that end early are tried again.
- Settings menu, mouse: a setting changes only on the two framed arrows beside its value, and the arrows stay in one
place. Holding the button on an arrow repeats.
- Linux: the SDL window honours the monitor setting, a Wayland fullscreen window reports where the compositor put it,
NVIDIA's NGX is released before the device, the runtime library builds and installed tools refresh correctly, and
NVIDIA's shader disk cache is kept beside the game with a limit that holds the prepared set (the driver builds its
cache once more after this update).
## Known issues
- The first visit to an area after an install can still pause while the graphics driver builds what it has not seen.
- When the system's memory is nearly full, towns re-upload many textures and the frame rate drops; closing other
programs helps. Machines with 16 GB of RAM can run out of system memory in Hyrule Field.
- Integrated AMD GPUs can fail at the title screen (their host memory heap is too small for the game's memory).
- Opening the game's settings menu can crash on some AMD Radeon GPUs.
- A rare crash in the game's particle code.
- The new copy-on-touch of shader-written memory is the largest change in this release. If something behaves wrong
that did not before (physics, effects, a picture), set `wb_lazy = 0` in `nx2navi.ini`, and tell us whether that
cures it.
## For builders
- The repository holds the runtime's own shaders as source only; the build compiles them (`tools/build_shaders.py`),
so a build from source needs `glslc` and `spirv-as` (MSYS2 `shaderc` and `spirv-tools`).
- New diagnostics: `gpu_passes = 1` times what a submission spends on the GPU outside the game's passes, `wb_probe = 1`
reports who reads what the GPU wrote back, `wb_lazy_touch` reads lazily written ranges on purpose, `tex_disuse = 2`
tells the freeing of unsampled textures from their marking, and the profile report names the exe's functions from a
GNU ld map too.
- `--boot` and `--seconds` work on game 1.1.1, and the world clock starts there.
- `dlss_idle_free`, `compute_keep`, `lib_prebuild_big` and `wb_split` are described in `nx2navi.ini.example`.
## Thanks
Pull requests in this release came from ajcohn716, DeepDaddyTTV, epicmeme546, itaskaev2, Leyukaka, mooki000,
ordinarybob, peigongdsd, schoperena, TophC7 and twisted89, and JEDGIT18 tracked down the audio voice fault. Thanks to
everyone who sent logs, memory reports and test reports.
Report problems as issues, with the game's log (`logs\nx2navi.log` in the game folder) and what you were doing; *Export
Save* with the bug report box ticked packs the log, your settings and your save into one zip.
NX2navi is an independent, non-commercial fan project, not affiliated with or endorsed by Nintendo. *The Legend of
Zelda*, *Ocarina of Time* and *Nintendo Switch* are trademarks of Nintendo.

View File

@@ -47,7 +47,7 @@ static const char *const known[] = {
"HDR_EXPOSURE", "HDR_FLARE", "HDR_GAMMA", "HDR_GAME_NITS", "HDR_GRADE", "HDR_HIGHLIGHT_SAT", "HDR_HIGHLIGHTS", "HDR_HUE",
"HDR_LIVE",
"HDR_PEAK_NITS", "HDR_SATURATION", "HDR_SHADOWS", "HDR_TONEMAP", "HDR_UI_NITS", "HIGHFPS_FIX", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "LANG", "LIB_PREBUILD",
"BIG_BUILD_FREE_MB", "BIG_BUILD_MAX_MB", "LIB_PREBUILD_BIG", "LIB_PREBUILD_BIG_BG", "LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LIB_WARM", "PIPE_LINK_MS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MEMORY", "MEM_CENSUS", "MENU_LANG", "MENU_SOUND_VOLUME", "MENU_TEST",
"BIG_BUILD_FREE_MB", "BIG_BUILD_MAX_MB", "LIB_PREBUILD_BIG", "LIB_PREBUILD_BIG_BG", "LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LIB_WARM", "PIPE_LINK_MS", "FRAME_HOLD_MS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MEMORY", "MEM_CENSUS", "MENU_LANG", "MENU_SOUND_VOLUME", "MENU_TEST",
"MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_CLICK", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MICROPHONE", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MONITOR", "MOTION", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_HOST", "MOVIE_PACE",
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
"MV_SURVEY",
@@ -114,7 +114,7 @@ static const struct { const char *key, *section; } sections[] = {
{"POOL_CREATE_MS", "performance"},
{"TIMER_1MS", "performance"}, {"PIPE_WAIT", "performance"}, {"PIPE_SKIP", "performance"}, {"ONESHOT_BUDGET", "performance"},
{"CACHE_DIE", "performance"}, {"ONE_PER_CORE", "performance"},
{"LIB_PREBUILD", "performance"}, {"LIB_PREBUILD_THREADS", "performance"}, {"LIB_WARM", "performance"}, {"PIPE_LINK_MS", "performance"}, {"PIPE_PREBUILD", "performance"},
{"LIB_PREBUILD", "performance"}, {"LIB_PREBUILD_THREADS", "performance"}, {"LIB_WARM", "performance"}, {"PIPE_LINK_MS", "performance"}, {"FRAME_HOLD_MS", "performance"}, {"PIPE_PREBUILD", "performance"},
{"COMPUTE_KEEP", "performance"},
{"PREWARM_XLATE", "performance"}, {"GPL", "performance"}, {"ASTC", "performance"}, {"MEMORY", "performance"},
{"TEX_ALIAS", "performance"}, {"TEX_DISUSE", "performance"}, {"TEX_GEN_UNDO", "performance"}, {"TEX_REUSE", "performance"}, {"TEX_VRAM_PRESSURE", "performance"}, {"TEX_PROC_COMMIT_MB", "performance"}, {"ASTC_BC", "performance"}, {"LOD_GUARD", "performance"}, {"FIX_C0", "performance"}, {"FIX_ZERO", "performance"},
@@ -215,6 +215,7 @@ static const CfgMeta metas[] = {
// shaders and pipelines
{"PIPE_WAIT", "default", "default|draw", RESTART}, {"PIPE_SKIP", "any", "strict|any|fullscreen", RESTART},
{"PIPE_LINK_MS", "6", "0..100", RESTART}, // vk_exec_draw.c link_budget
{"FRAME_HOLD_MS", "120", "0..500", RESTART}, // vk_backend.c frame_hold
{"LIB_PREBUILD", "1", "0|1", RESTART}, {"LIB_PREBUILD_THREADS", "", "1..64", RESTART},
{"LIB_WARM", "1", "0|1|force", RESTART}, // vk_pipeline.c lw_start: the driver's cache of stage libraries, warmed when cold
{"PIPE_PREBUILD", "1", "0|1", RESTART}, {"PREWARM_XLATE", "", "1..64", RESTART}, {"GPL", "1", "0|1", RESTART},

View File

@@ -145,6 +145,9 @@ static uint8_t g_gpu_luid[8];
static int g_gpu_luid_ok;
static int g_gpu_bus = -1;
static float g_vram_total_mb = -1;
static float (*g_vram_game)(void);
void perfmon_set_vram_game(float (*used_mb)(void)) { __atomic_store_n(&g_vram_game, used_mb, __ATOMIC_RELEASE); }
void perfmon_set_gpu(const char *name, const uint8_t *luid, int pci_bus, float vram_total_mb) {
plat_mutex_lock(&g_lock);
@@ -308,6 +311,7 @@ static void machine_clear(PerfStats *s) {
s->cpu_total_pct = s->cpu_game_pct = s->cpu_temp_c = -1;
s->ram_used_mb = s->ram_total_mb = s->ram_game_mb = -1;
s->gpu_pct = s->gpu_temp_c = s->gpu_power_w = s->gpu_clock_mhz = s->vram_used_mb = s->vram_total_mb = -1;
s->vram_game_mb = -1;
}
static void machine_copy(PerfStats *d, const PerfStats *s) {
@@ -317,6 +321,7 @@ static void machine_copy(PerfStats *d, const PerfStats *s) {
d->ram_used_mb = s->ram_used_mb, d->ram_total_mb = s->ram_total_mb, d->ram_game_mb = s->ram_game_mb;
d->gpu_pct = s->gpu_pct, d->gpu_temp_c = s->gpu_temp_c, d->gpu_power_w = s->gpu_power_w;
d->gpu_clock_mhz = s->gpu_clock_mhz, d->vram_used_mb = s->vram_used_mb, d->vram_total_mb = s->vram_total_mb;
d->vram_game_mb = s->vram_game_mb;
}
static void sampler(void *arg) {
@@ -343,6 +348,8 @@ static void sampler(void *arg) {
plat_mem_info(&s.ram_used_mb, &s.ram_total_mb, &s.ram_game_mb);
plat_gpu_load(l, &s.gpu_pct, &s.vram_used_mb);
s.vram_total_mb = vram_total;
float (*game)(void) = __atomic_load_n(&g_vram_game, __ATOMIC_ACQUIRE);
if (game) s.vram_game_mb = game();
nvml_sample(&s);
adl_sample(&s);
plat_mutex_lock(&g_lock);

View File

@@ -28,6 +28,9 @@ typedef struct {
// ADL (AMD)
char gpu_name[96];
float gpu_pct, gpu_temp_c, gpu_power_w, gpu_clock_mhz, vram_used_mb, vram_total_mb;
// of vram_used_mb, which counts every program on the card, what this process holds (the driver's figure for
// the device-local heaps, perfmon_set_vram_game); -1 unknown
float vram_game_mb;
// per frame, averaged over the last half second: replay (NVN to Vulkan recording), GPU busy time (timestamps; -1
// without them), the render thread's waits for pipeline builds, shader translation and texture uploads, and the
// textures uploaded
@@ -41,6 +44,9 @@ void perfmon_mode(int mode);
// The Vulkan device the game renders on: its name, its LUID (8 bytes; NULL when the driver gives none), its PCI bus
// (-1 unknown) and its device-local memory. Before the first perfmon_mode(2).
void perfmon_set_gpu(const char *name, const uint8_t *luid, int pci_bus, float vram_total_mb);
// How the sampling thread asks for the device-local memory this process holds, in MB (vk_memory.c
// vk_mem_device_used_mb; negative when the driver does not report it). Called twice a second while the overlay is full.
void perfmon_set_vram_game(float (*used_mb)(void));
// A game frame was presented (perf_present, the render thread, only while the overlay is on): the time since the last
// one, the render thread's waits of this frame (PERF_N entries, host.h), its replay time and the running count of
// texture uploads.

View File

@@ -93,7 +93,9 @@ void machine_and_frames(const PerfPanel *p, float scale) {
label(UI_MENU_OV_VRAM);
cell(UI_MENU_OV_FMT_GB, gb(s.vram_used_mb));
cell(UI_MENU_OV_FMT_GB_OF, gb(s.vram_total_mb));
cell(UI_MENU_OV_FMT_MHZ, s.gpu_clock_mhz);
// the card's figure counts every program on it: this game's own share beside it, the clock where that is unknown
if (s.vram_game_mb >= 0) cell(UI_MENU_OV_GAME_GB, gb(s.vram_game_mb));
else cell(UI_MENU_OV_FMT_MHZ, s.gpu_clock_mhz);
label(UI_MENU_OV_CPU);
cell(UI_MENU_OV_FMT_PCT, s.cpu_total_pct);
cell(UI_MENU_OV_FMT_TEMP, s.cpu_temp_c);

View File

@@ -344,6 +344,8 @@ void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDevic
int vk_mem_class_of(uint64_t addr); // VK_MCLS_* of the pool at addr (NONE when unbacked)
void vk_mem_census(uint64_t frame); // at each present: pool census and traffic, logged at frame 1800 and,
// with NX2NAVI_TRACE=perf, every 1800 frames
float vk_mem_device_used_mb(void); // device-local memory this process holds (the driver's budget
// figure), MB; -1 without VK_EXT_memory_budget. Any thread.
void vk_mem_stage_log(const char *stage); // one line after a boot stage: device memory, process commit
// VRAM in use and its budget, summed over the DEVICE_LOCAL heaps. exact 1: VK_EXT_memory_budget (the whole process),
// 0: this allocator's own allocations against the heap sizes. 0 when unknown.

View File

@@ -26,6 +26,7 @@
#include "gfx.h"
#include "host.h"
#include "nvn_api.h"
#include "perfmon.h"
#include "vk.h"
#include "vk_exec.h"
#include "platform/platform.h"
@@ -97,11 +98,64 @@ void vk_present_drain(void) {
perf_end(PERF_DRAIN, p0);
}
// NX2NAVI_FRAME_HOLD_MS (default 120; 0 = off): a frame whose draws were skipped because a shader or pipeline was
// still building (vk_exec_draw.c pending_draws) is not shown: the previous picture stays on screen until a frame is
// complete again. Such a frame lacks what was skipped, which showed for a frame or two as a black or unlit picture with
// the interface intact (a lighting pass), a light going out, or ground and walls missing and then back. The game runs
// on meanwhile, so nothing waits. The hold comes from an allowance of this many milliseconds, used up by the time
// held and filled again at an eighth of the clock's rate: a pipeline that takes longer, or a run of them on a first
// visit with nothing recorded, shows its incomplete frames as before and does not freeze the picture. Not with DLSS
// Frame Generation, which is told about every frame.
static struct { int64_t limit_ns, left_ns; uint64_t last_ns, held, runs, shown; int holding; } FH = {.limit_ns = -1};
static void frame_hold_refill(uint64_t now) {
if (FH.limit_ns < 0) {
long long ms = cfg_int("NX2NAVI_FRAME_HOLD_MS");
FH.limit_ns = (int64_t)(ms < 0 ? 0 : ms > 500 ? 500 : ms) * 1000000;
FH.left_ns = FH.limit_ns, FH.last_ns = now;
if (FH.limit_ns)
rt_log("vk: a frame with draws skipped for a pipeline is not shown, the previous picture stays up to %lld ms "
"(NX2NAVI_FRAME_HOLD_MS)", (long long)(FH.limit_ns / 1000000));
}
if (!FH.holding) FH.left_ns += (int64_t)(now - FH.last_ns) / 8;
else FH.left_ns -= (int64_t)(now - FH.last_ns);
if (FH.left_ns > FH.limit_ns) FH.left_ns = FH.limit_ns;
FH.last_ns = now;
}
// Whether a frame that skipped draws now would be held (vk_exec_draw.c: a full-screen draw is skipped only then).
int vk_frame_hold_left(void) {
frame_hold_refill(kern_now_ns());
return FH.left_ns > 0 && !vk_dlssg_active();
}
// 1: this frame is not shown. skipped: the draws it lacks.
static int frame_hold(uint32_t skipped, uint64_t frame) {
frame_hold_refill(kern_now_ns());
int hold = skipped && FH.left_ns > 0 && !vk_dlssg_active();
if (hold && !FH.holding) FH.runs++;
if (skipped && !hold) FH.shown++;
FH.holding = hold;
if (hold) FH.held++;
static uint64_t logged_at, logged_held, logged_shown;
if (!hold && FH.held + FH.shown != logged_held + logged_shown && frame - logged_at >= 600) {
rt_log("vk: frame %llu: %llu frames with skipped draws held back so far in %llu runs, %llu shown incomplete "
"(allowance used up)", (unsigned long long)frame, (unsigned long long)FH.held,
(unsigned long long)FH.runs, (unsigned long long)FH.shown);
logged_at = frame, logged_held = FH.held, logged_shown = FH.shown;
}
if (hold && (rt_trace & RT_TRACE_PRESENT))
rt_log("present: frame %llu held back, %u draws skipped", (unsigned long long)frame, skipped);
return hold;
}
// The present after the frame count: resolves the image and hands the blit to the present thread. queued: when the game
// presented; value: the timeline value queued for this present (asynchronous replay), 0 for the next one (synchronous).
static void present_image(const tex_t *t, const int crop[4], uint64_t at_ns, uint64_t queued, uint64_t frame,
uint64_t value) {
static volatile int32_t n_skipped;
static int vram_probe;
if (!vram_probe) vram_probe = 1, perfmon_set_vram_game(vk_mem_device_used_mb); // the overlay's "game" beside VRAM
vk_exec_frame_log(t, frame);
dynres_frame(); // before vk_dlaa_frame reads the DLSS mode it may override
vk_dlaa_frame();
@@ -113,8 +167,9 @@ static void present_image(const tex_t *t, const int crop[4], uint64_t at_ns, uin
if (vk_dump_armed) vk_dump_present(frame);
__atomic_store_n(&gfx_counters.validation_errors, (uint64_t)vk_validation_errors_total(), __ATOMIC_RELAXED);
const VkTexImage *img = vk_texture_get(t);
if (!img || !(img->aspect & VK_IMAGE_ASPECT_COLOR_BIT)) {
if (plat_inc32(&n_skipped) <= 8)
int held = frame_hold(vk_exec_pending_draws_take(), frame);
if (held || !img || !(img->aspect & VK_IMAGE_ASPECT_COLOR_BIT)) {
if (!held && plat_inc32(&n_skipped) <= 8)
rt_log("vk: present of texture %p (format %#x) skipped: no colour image", (const void *)t, t ? t->d.format : 0);
if (value) { // the queued value is still signalled, in order
vk_present_drain();

View File

@@ -185,6 +185,10 @@ extern VkExecFrame vk_exec_frame;
void vk_exec_frame_written(const tex_t *t); // vk_texture_gpu_written: t rendered or copied into
uint64_t vk_exec_recording_fence(void); // fence of the submission this thread records, else 0
void vk_exec_frame_log(const tex_t *presented, uint64_t frame);
// The draws skipped since the last call because a shader or pipeline was still building (vk_exec_draw.c), and whether
// a frame lacking them would be held back at its present (vk_backend.c frame_hold).
uint32_t vk_exec_pending_draws_take(void);
int vk_frame_hold_left(void);
// NX2NAVI_DUMP=<frame> (vk_dump.c): between presents frame-1 and frame, every pass's targets and every dispatch's storage
// images are copied out and written as PNGs to NX2NAVI_DUMP_DIR (default "dump"), with passes.txt (targets, pipelines,

View File

@@ -3254,7 +3254,9 @@ static void foliage_shadow_cull(const VkExec *ex, VkPipeState *s) {
// Full-screen draws into such passes wait from their budget of 50 ms a presented frame. The default: a skipped
// full-screen draw is a lighting, fog or tone mapping pass that leaves its target as it was, which shows as a black
// or unlit frame with the interface intact, and with the stage libraries in the driver's cache the wait is a
// millisecond (vk_pipeline.c lw_start keeps them there).
// millisecond (vk_pipeline.c lw_start keeps them there). One that is skipped once its budget is spent leaves a frame
// that is not shown (vk_backend.c frame_hold); where that cannot hold the picture any longer, the draw waits on
// (FULLSCREEN_LAST_MS).
// fullscreen (2): as any, and full-screen draws into such passes are skipped instead of waiting from their
// budget. A full-screen pass whose stage libraries are cold in the driver cache took 86 ms on average (up to 194 ms)
// in a fight on an RX 9070: three frames in a row each spent the 50 ms budget, and some of the draws were skipped
@@ -3285,6 +3287,9 @@ static int pipe_skip_mode(void) {
// this much and no more. Measured on an RX 7900 XT, first walk through a village with no pipeline recorded: 2,349
// draws skipped without the budget, with the libraries warm in both runs.
#define LINK_DRAW_MS 3u
// How long a full-screen draw waits on for its pipeline once its frame budget is spent and the previous picture
// cannot be held any longer (prepare_draw_ex): the longest optimised build of such a pipeline measured was 194 ms.
#define FULLSCREEN_LAST_MS 500u
static uint64_t *link_budget(void) {
static uint64_t frame = ~0ull, left, per_frame = ~0ull;
if (per_frame == ~0ull) {
@@ -3384,8 +3389,19 @@ static void draw_stats_tick(void) {
DRS.frame = f;
}
// The draws skipped since the last present because their shader or pipeline was still building: the picture of that
// frame lacks them (a light, a wall, a whole lighting pass). vk_backend.c frame_hold reads it at the present and keeps
// the previous picture on screen instead. Written and read on the replay thread.
static uint32_t pending_draws;
uint32_t vk_exec_pending_draws_take(void) {
uint32_t n = pending_draws;
pending_draws = 0;
return n;
}
static int draw_skipped(const VkExec *ex, int mesh, int why) {
DRS.skipped[mesh][why]++;
if (why == SK_SHADER_PENDING || why == SK_PIPE_PENDING) pending_draws++;
if (!(DRS.first[mesh] >> why & 1)) {
DRS.first[mesh] |= 1u << why;
rt_log("vk: first %s draw skipped because: %s (program %llu)", mesh ? "mesh" : "vertex", sk_names[why],
@@ -3553,6 +3569,14 @@ static int prepare_draw_ex(VkExec *ex, int prim, int32_t count, int restart, int
p = vk_pipeline_graphics_async(&s, &info, &pending, ONESHOT_WAIT_MS);
}
}
// A full-screen draw still pending after its budget: skipped, it leaves the frame black or unlit. While the
// previous picture can stay on screen in its place (vk_frame_hold_left) that is what happens; once that time
// is used up the draw waits on, FULLSCREEN_LAST_MS at most, so that no such frame is shown.
if (pending && budget == &wait_left_ns && !vk_frame_hold_left()) {
why = "full-screen, nothing left to hold the picture";
if (!w0) w0 = kern_now_ns();
p = vk_pipeline_graphics_async(&s, &info, &pending, FULLSCREEN_LAST_MS);
}
PM.valid = !pending && p && info;
if (PM.valid) PM.s = s, PM.info = info;
}

View File

@@ -2854,6 +2854,20 @@ static void outside_watch(uint64_t frame) {
last = out, seen = 1;
}
// The overlay's "game" figure beside the card's memory in use (perfmon.c, its sampling thread): what the driver
// counts for this process on the device-local heaps, the same figure vram_use_log splits by use.
float vk_mem_device_used_mb(void) {
VkCtx *c = vk_ctx();
if (!c || !c->has_memory_budget) return -1;
VkPhysicalDeviceMemoryBudgetPropertiesEXT bp = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT};
VkPhysicalDeviceMemoryProperties2 p2 = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2, .pNext = &bp};
vkGetPhysicalDeviceMemoryProperties2(c->phys, &p2);
uint64_t usage = 0;
for (uint32_t h = 0; h < c->mem_props.memoryHeapCount && h < VK_MAX_MEMORY_HEAPS; h++)
if (c->mem_props.memoryHeaps[h].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) usage += bp.heapUsage[h];
return (float)(usage / 1048576.0);
}
// One line per boot stage (vk_pipeline.c calls it after the pipeline cache load, the shader prewarm, the recorded
// pipelines and the compute pipeline prebuild): the device-local memory in use, the part of it VMA did not allocate
// (outside_watch's "outside VMA": pipelines and the driver's own, before the swapchain and the upscaler exist), and the