NX2NAVI_FOLIAGE (full, reduced, off): reduced skips the indirect mesh draws with a task stage (small grass and moss), off every indirect mesh draw (all foliage); a Lama patches row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tobim6
2026-11-12 16:23:05 +01:00
parent 4718997313
commit 306de50589
5 changed files with 40 additions and 3 deletions

View File

@@ -91,6 +91,7 @@ static const char *const known[] = {
// The nx2navi.ini section a key cfg_set may write goes to when the file lacks it (nx2navi.ini.example's sections).
static const struct { const char *key, *section; } sections[] = {
// the menu's Lama patches tab (ui/menu.cpp tab_lama)
{"TEX_RELEASED_MAX", "performance"}, {"MIRROR_HOT", "performance"}, {"FREEZE_IDLE", "performance"}, {"SUBMIT_FINISH_KINDS", "performance"}, {"FOLIAGE", "performance"},
{"ZSTD_NATIVE", "performance"},
{"MESH_EMU_MB", "performance"}, {"MESH_EMU_TASKS", "performance"}, {"MESH_EMU_BATCH", "performance"}, {"VEC_INDEX_FIX", "performance"},
{"GUEST_OPT", "performance"}, {"PASS_TIMES", "diagnostics"}, {"DUMP_KEY", "diagnostics"},
@@ -303,6 +304,7 @@ static const CfgMeta metas[] = {
{"TEX_RELEASED_MAX", "", NULL, RESTART}, // vk_texture.c released_max: "" by the video memory budget, else 1..16384
{"MIRROR_HOT", "25", "0..1000", RESTART}, {"FREEZE_IDLE", "1800", "0..100000", RESTART},
{"SUBMIT_FINISH_KINDS", "31", "0..31", RESTART}, // vk_sync.c res_mask
{"FOLIAGE", "full", "full|reduced|off", RESTART}, // vk_exec_draw.c foliage_skip
{"VRAM_HEAP_LIMIT", "auto", NULL, RESTART}, // vk_device.c vram_heap_limits: auto, 0 or MiB
{"UPLOAD_BATCH_MB", "256", NULL, RESTART}, // vk_memory.c: MiB of staging before a batch goes early, 0 no limit
{"MESH_EMULATION", "1", "0|1", RESTART}, {"MESH_EMU_MB", "256", "32..2048", RESTART},

View File

@@ -1645,21 +1645,28 @@ static void tab_lama(float scale) {
static const char *const values[] = {"128", "256", "512", "1024", "0"};
const char *names[] = {"128 MB", "256 MB", "512 MB", "1024 MB", menu_text(UI_MENU_LAMA_NO_LIMIT)};
opt_choice_list("NX2NAVI_UPLOAD_BATCH_MB", UI_MENU_LAMA_UPLOAD_BATCH, values, names, 5, UI_MENU_LAMA_UPLOAD_BATCH_DESC);
}
opt_toggle("NX2NAVI_ASTC_SCRATCH_KEEP", UI_MENU_LAMA_ASTC_KEEP, UI_MENU_LAMA_ASTC_KEEP_DESC);
{ // vk_memory.c freeze_pass: submissions a region stays unwritten before it is frozen
static const char *const values[] = {"1800", "1200", "600", "60", "0"};
const char *names[] = {"1800", "1200", "600", "60", menu_text(UI_MENU_OFF)};
opt_choice_list("NX2NAVI_FREEZE_IDLE", UI_MENU_LAMA_FREEZE, values, names, 5, UI_MENU_LAMA_FREEZE_DESC);
}
{ // vk_sync.c res_mask: the result kinds the submit wait counts (31 all, 30 all but events)
static const char *const values[] = {"31", "30"};
const char *names[] = {menu_text(UI_MENU_LAMA_RESULTS_ALL), menu_text(UI_MENU_LAMA_RESULTS_NO_EVENTS)};
opt_choice_list("NX2NAVI_SUBMIT_FINISH_KINDS", UI_MENU_LAMA_RESULTS, values, names, 2, UI_MENU_LAMA_RESULTS_DESC);
}
opt_toggle("NX2NAVI_ZSTD_NATIVE", UI_MENU_LAMA_ZSTD, UI_MENU_LAMA_ZSTD_DESC); // ov_zstd.c trusted
opt_group(UI_MENU_LAMA_RENDER);
opt_toggle("NX2NAVI_REPLAY_ASYNC", UI_MENU_LAMA_ASYNC, UI_MENU_LAMA_ASYNC_DESC); // vk_backend.c
const bool native = vk_mesh_shader_native() != 0; // vk_exec_draw.c: the emulation only where the GPU lacks them
if (native) opt_disable_next(UI_MENU_LAMA_MESH_NATIVE);
opt_toggle("NX2NAVI_MESH_EMULATION", UI_MENU_LAMA_MESH_EMU, UI_MENU_LAMA_MESH_EMU_DESC);
{ // vk_exec_draw.c foliage_skip
static const char *const values[] = {"full", "reduced", "off"};
const char *names[] = {menu_text(UI_MENU_LAMA_FOLIAGE_FULL), menu_text(UI_MENU_LAMA_FOLIAGE_REDUCED), menu_text(UI_MENU_OFF)};
opt_choice_list("NX2NAVI_FOLIAGE", UI_MENU_LAMA_FOLIAGE, values, names, 3, UI_MENU_LAMA_FOLIAGE_DESC);
}
if (native) opt_disable_next(UI_MENU_LAMA_MESH_NATIVE);
opt_slider("NX2NAVI_MESH_EMU_MB", UI_MENU_LAMA_MESH_MB, 64, 2048, UI_MENU_LAMA_MESH_MB_DESC, 64, "%.0f MB");

View File

@@ -144,6 +144,11 @@ static const char *const text_en[UI_TEXT_COUNT] = {
"tracking can skip it. 1800 (about 15 s): few thaws and small tracking queries. 60: "
"the game thaws regions all the time and every thaw stalls a frame. Off: no stalls, but "
"the tracking scans all memory every frame.",
[UI_MENU_LAMA_FOLIAGE] = "Foliage",
[UI_MENU_LAMA_FOLIAGE_DESC] = "Full: all of it. Reduced: no small grass or moss on the ground; ferns, leaves and "
"other plants stay. Off: no foliage. Terrain, rocks and buildings always stay.",
[UI_MENU_LAMA_FOLIAGE_FULL] = "Full",
[UI_MENU_LAMA_FOLIAGE_REDUCED] = "Reduced",
[UI_MENU_LAMA_RESULTS] = "Wait for GPU results",
[UI_MENU_LAMA_RESULTS_DESC] = "After a frame's first submission the game waits until the GPU wrote the results it "
"reads back. All: events, counter and occlusion reports, write-backs. Without events: "

View File

@@ -336,6 +336,7 @@ typedef enum {
UI_MENU_TAB_LAMA, UI_MENU_LAMA_INTRO, UI_MENU_LAMA_MEMORY, UI_MENU_LAMA_RENDER, UI_MENU_LAMA_BUILD,
UI_MENU_LAMA_DIAG,
UI_MENU_LAMA_FREEZE, UI_MENU_LAMA_FREEZE_DESC, UI_MENU_LAMA_ZSTD, UI_MENU_LAMA_ZSTD_DESC,
UI_MENU_LAMA_FOLIAGE, UI_MENU_LAMA_FOLIAGE_DESC, UI_MENU_LAMA_FOLIAGE_FULL, UI_MENU_LAMA_FOLIAGE_REDUCED,
UI_MENU_LAMA_RESULTS, UI_MENU_LAMA_RESULTS_DESC, UI_MENU_LAMA_RESULTS_ALL, UI_MENU_LAMA_RESULTS_NO_EVENTS,
UI_MENU_LAMA_ASYNC, UI_MENU_LAMA_ASYNC_DESC,
UI_MENU_LAMA_RELEASED, UI_MENU_LAMA_RELEASED_DESC,

View File

@@ -5775,21 +5775,43 @@ static int mesh_ring_entry(VkExec *ex, VkCommandBuffer cb, const p_draw_mesh_ind
return 1;
}
// NX2NAVI_FOLIAGE (full, reduced, off; default full; the Lama patches tab): Ocarina draws its foliage with
// DrawMeshTasksIndirect, the instances its compute passes culled on the GPU. With a task stage: the small grass and moss
// that carpet the ground; without one: ferns, leaves, clover and the other plants. Its other mesh draws (DrawMeshTasks
// with a count: terrain, rocks, buildings, doors) are not foliage. reduced skips the indirect draws with a task stage,
// off every indirect one, in every pass (their shadows too). In a frame dump of Kokiri Forest on an RX 580
// (f8118, 2026-11-10) the grass and moss were one draw with task stage 2ddf7b0bf74e5a05; the plants nine without.
static int foliage_skip(VkExec *ex) {
static int mode = -1;
if (mode < 0) {
const char *v = cfg_get("NX2NAVI_FOLIAGE");
mode = v && !strcmp(v, "off") ? 2 : v && !strcmp(v, "reduced") ? 1 : 0;
rt_log("vk: foliage %s (NX2NAVI_FOLIAGE)", mode == 2 ? "off" : mode ? "reduced: no small grass or moss" : "full");
}
if (!mode) return 0;
if (mode == 2) return 1;
const uint8_t *ctl, *code;
uint32_t len;
return ex->prog && find_stage(ex->dc, ex->prog, NVN_STAGE_TASK, &ctl, &code, &len);
}
// DrawMeshTasksIndirect: one draw from its ring entry (mesh_ring_entry); x2-x4 of the call vary like leftovers, so they
// are not read as a count or stride.
static void op_draw_mesh_ind(VkExec *ex, const p_draw_mesh_ind *d) {
PFN_vkCmdDrawMeshTasksIndirectEXT fn = draw_mesh_ind_fn();
int fallback = vk_ctx()->mesh_fallback;
if (!fn && !fallback) return warn_once(W_MESH, "mesh draws need VK_EXT_mesh_shader: skipped");
int emu = !fn && mesh_emu_on(), fallback = !emu && vk_ctx()->mesh_fallback;
if (!fn && !emu && !fallback)
return warn_once(W_MESH, "mesh draws need VK_EXT_mesh_shader (mesh_emulation = 1 emulates them): skipped");
static int on = -1;
if (on < 0) on = rt_knob("MESH", "1");
if (!on) return;
if (!on || foliage_skip(ex)) return;
VkMemSpan ip;
if (!vk_mem_resolve(d->ind, 12, &ip) || ip.offset % 4)
return warn_once(W_INDIRECT, "indirect mesh draw arguments at %#llx are not backed or not aligned: skipped",
(unsigned long long)d->ind);
ex->dc->c0_binst = 0;
VK_MEM_USE(ip);
if (emu) { // emulated: a ring entry {count, 1, 1}, made where the stages run, is the first stage's dispatch
mesh_emu_draw(ex, 0, NULL, &ip);
vk_mem_count(ip.cls, VK_MUSE_IND, 4);
VK_MEM_BOUND(ip);