Merge main into task/menu: the docs and comment cleanup, with the Dear ImGui set-up of menu.cpp kept in the LAS Recomp notices row

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-10-26 10:16:23 +03:00
commit b0805112ed
26 files changed
+407 -535

No files matched your search

+1 -1
View File
@@ -439,7 +439,7 @@ static void key_hex(const uint8_t key[32], char out[65]) {
}
// A .res.json the translator wrote: one JSON object that names its stage, no NUL inside. A file an interrupted write
// left zero-filled (3647 of build/v121-m4's 21924 were) fails this; reflect() would take it for a vertex shader with
// left zero-filled (3647 of 21924 in one cache were) fails this; reflect() would take it for a vertex shader with
// no resources, and its pipeline layout would lack the shader's buffers and textures.
static int reflection_valid(const char *res, uint64_t size) {
if (strlen(res) != size) return 0;
+2 -2
View File
@@ -280,7 +280,7 @@ static int core_allowed(const RtThread *t, int c) { return (int)((t->mask >> c)
// MacNativeGames contributors): Horizon gives a core to a strictly better thread the moment that thread is ready.
// Here a better waiter only marks the owner, which gives the core up at its next SVC or indirect call; an owner in a
// stretch of game code with neither keeps it (TOTK_CORE_DIAG: 0.5-1.1 ms of thread-time per frame, waits to 16 ms and
// more, build/v121-preempt/NOTES.md). With it on, three parts, all of which MacNativeGames found necessary:
// more). With it on, three parts, all of which MacNativeGames found necessary:
// - The waiter interrupts the owner (SuspendThread, GetThreadContext) when it has waited AP_FIRST_NS, then every
// millisecond: if the owner's host rip is in the lifted modules' code (g_gen_lo..g_gen_hi) and its host depth is 0
// (not in a host call or SVC, nor in game code a host call made), it holds no host lock, so its rip is moved to
@@ -777,7 +777,7 @@ static int core_better_waiter(const RtThread *t, int c) {
// Asks holders to give their cores up, one holder per waiter: waiters best first, each claims the worst holder worse
// than itself on a core it may run on that no better waiter claimed (a request already pending is reused). Asking
// every worse holder made several drop their cores for one waiter; the spare cores went to worse waiters, which asked
// again (build/v121-dpre/NOTES.md).
// again.
static void core_kick(void) {
RtThread *w[64];
int wp[64], op[NCORE], n = 0, claimed = 0;
+1 -1
View File
@@ -557,7 +557,7 @@ NVN_API(nvnQueueFinish) {
// first, and the GPU reads uniform memory only after it. The game's producer f_70008c6460 (thread 0x103e, p56)
// rewrites the half of its per-object uniform blocks that was front until the last flip, 14-23 ms after the submit
// that still reads it, with no fence: on hardware the GPU has read that half by then. Here the rewrite lands inside
// the replay, and that frame draws other objects' matrices (phantom rocks, flat far field; build/v121-lod NOTES.md).
// the replay, and that frame draws other objects' matrices (phantom rocks, flat far field).
// The guard makes the producer wait, at its commit point, until the newest submit has been replayed and completed.
// lod_entered / lod_issued count submits that entered QueueSubmitCommands / reached the back end; lod_fence holds
// the fence of the last LOD_RING. TOTK_LOD_GUARD=0 turns the wait off.
+1 -1
View File
@@ -688,7 +688,7 @@ static void ov_user_difference(Cpu *c) {
}
// ==== nn::pl shared fonts (shared_font.c). TotK asks for them only from its font loader, only with Simplified Chinese,
// Korean or Traditional Chinese text, and only for type 0 (build/v121-swkbd/NOTES.md); tools/extract_fonts.py writes
// Korean or Traditional Chinese text, and only for type 0; tools/extract_fonts.py writes
// them from the user's firmware. Each type is read on first use into guest-visible memory as the BFTTF file the pl
// shared memory holds; Address is 8 bytes past the file start (after the BFTTF header) and Size the decoded font size,
// as in MNG. The load state is always Loaded: the game spins until it is, so missing files stop with a named fatal at
+1 -1
View File
@@ -5,7 +5,7 @@
// nn::swkbd::ShowKeyboard: text entry for the game. On the Switch the call starts the keyboard library applet, which
// takes the screen until the player confirms or cancels. TotK calls it in one place, naming a horse at a stable
// (main+0x1ecbf64 -> main+0x1b2b3a0: UserName preset, at most 9 characters, '@' '%' '\' disabled, UTF-16 out, no
// header, guide or initial text; an empty answer counts as not named). See build/v121-swkbd/NOTES.md.
// header, guide or initial text; an empty answer counts as not named).
//
// Front end: a modal Win32 window owned by the game window, run on the guest thread that called (the call blocks, as
// on the Switch). The thread gives its virtual core up meanwhile, so the other guest threads keep running; it holds no
+1 -1
View File
@@ -139,7 +139,7 @@ void vk_mem_count(int cls, int use, uint64_t bytes);
void vk_mem_bound_note(void *pool);
#define VK_MEM_BOUND(sp) do { if ((rt_trace & RT_TRACE_PERF) && (sp).pool) vk_mem_bound_note((sp).pool); } while (0)
void vk_mem_dirty_submit(void); // vk_sync_submit, under its lock, before the replay
// VRAM mirror of buffer-bound pools (vk_memory.c, build/mem-plan.md). vk_mirror_on: TOTK_MEMORY=mirror|verify, or the
// VRAM mirror of buffer-bound pools (vk_memory.c). vk_mirror_on: TOTK_MEMORY=mirror|verify, or the
// device class is discrete and TOTK_MEMORY is unset or auto; set at device selection. The replay (submitting thread
// under vk_sync_submit's lock) calls:
// - VK_MEM_USE at a vertex, index, uniform, storage or indirect binding of a span vk_mem_resolve returned: the pool's
+2 -2
View File
@@ -11,12 +11,12 @@
// the frame's display time from the pacer (nvn_api_obj.c), so present-to-present intervals stay even whatever the
// replay took. The blit is already on the queue, so the wait blocks no submission.
//
// Asynchronous replay (TOTK_REPLAY_ASYNC, default 1; 0 keeps the synchronous path unchanged): nvnQueueSubmitCommands
// Asynchronous replay (TOTK_REPLAY_ASYNC, default 0; 1 turns it on): nvnQueueSubmitCommands
// and nvnQueuePresentTexture only queue. Each item gets its timeline value at enqueue (vk_sync_reserve), in queue
// order; the replay thread runs the synchronous submit and present bodies in that order, so every value is signalled
// by the submission it was handed out for. The game runs at most one frame ahead: queueing present N waits until the
// replay thread handled present N-1. Calls that read or free GPU state that queued work may use drain the queue first
// (replay_drain), each cause counted. Design and the orderings it keeps: build/v121-replayq/NOTES.md.
// (replay_drain), each cause counted.
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
+2 -2
View File
@@ -705,7 +705,7 @@ static void c0_table(uint8_t *at, const p_bind_buf b[16]) {
// candidate base from here and compares the global pointer against it. Compute: dispatch size at 0x200, the uniform
// buffer table at 0x210 + 16 r. Graphics: the largest point size (Maxwell's limit, GLSLC clamps gl_PointSize to it) at
// 0x610, the base instance at 0x644. Other stages: zeros. Unbound slots read zero, since the replay keeps them zero.
// Layout: nxnative dm/gfx/nvn/nvn_mtl.m:4395-4420 (MIT); TotK readers in build/lessons/census.md G2.
// Layout: nxnative dm/gfx/nvn/nvn_mtl.m:4395-4420 (MIT).
void vk_c0_fill(uint8_t bank[VK_C0_BYTES], int stage, const p_bind_buf ssbo[16], const p_bind_buf ubo[16],
const uint32_t dispatch[3], uint32_t base_instance) {
memset(bank, 0, VK_C0_BYTES);
@@ -815,7 +815,7 @@ static VkDescriptorBufferInfo ssbo_info(VkExec *ex, int st, const GfxShaderRes *
// TotK's G-buffer and terrain shaders sample targets of the pass that renders them, at their own pixel, after earlier
// draws of the pass wrote them (albedo, normals, R32F linear depth). Maxwell reads see those writes; in Vulkan the read
// is undefined without a barrier, and on the RX 9070 it showed as dark screen-aligned blocks on the island ground
// (build/v121-sq/SQUARES.md) and hid Tulin's sage spirit. Before a draw whose fragment shader samples an attachment of
// and hid Tulin's sage spirit. Before a draw whose fragment shader samples an attachment of
// the open pass that a draw or clear of the pass wrote since the pass began or the last barrier:
// - VK_FEEDBACK_LAYOUT: the image is learned (VkTexImage.fb_learned; it has the feedback usage since its creation), the
// pass restarts once with it in ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT, and from then on its passes attach it in that
+3 -3
View File
@@ -741,7 +741,7 @@ void vk_mem_snap_stats(uint64_t *checks, uint64_t *calls, uint64_t *untracked) {
}
// ---------------------------------------------------------------- dirty census (TOTK_TRACE=perf)
// What a device-local mirror of the buffer-bound pools would upload (build/mem-plan.md step 2). The replay notes every
// What a device-local mirror of the buffer-bound pools would upload. The replay notes every
// imported pool it binds as a vertex, index, uniform, storage or indirect buffer (vk_mem_bound_note). At the start of
// each submit one write-watch query per run of such pools stamps the pages written since with a new generation, in the
// shared generation table (no second consumer of the OS bits: texture checks see the stamps), and the pages of those
@@ -918,7 +918,7 @@ static void dirty_frame(uint64_t frame) {
}
// ---------------------------------------------------------------- VRAM mirror of buffer-bound pools
// build/mem-plan.md, "Design: VRAM mirror of buffer-bound pools". An imported pool keeps vertices, indices, constants
// An imported pool keeps vertices, indices, constants
// and storage buffers in system memory, so a discrete GPU reads them over PCIe on every draw (GTX 1050 Ti and RTX
// 3090 Ti: about 110 ms of GPU time per frame in the field). In mirror mode (device class discrete, TOTK_MEMORY) an
// imported pool gets a device-local buffer over its imported range the first time the replay uses it as a vertex,
@@ -1475,7 +1475,7 @@ static void mirror_log(uint64_t frame) {
qpc_ms(a.presnap_t) / f, qpc_ms(a.sync_t) / f, ver);
}
// Device class (build/mem-plan.md): INTEGRATED -> uma; a discrete GPU with a DEVICE_LOCAL heap of 1 GiB or more beside a
// Device class: INTEGRATED -> uma; a discrete GPU with a DEVICE_LOCAL heap of 1 GiB or more beside a
// heap that is not device-local (host memory) -> discrete; otherwise uma (import everywhere). Sets the mirror mode.
void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDeviceMemoryProperties *m) {
int big_local = -1, host_heap = -1;
+2 -2
View File
@@ -2548,7 +2548,7 @@ static Layout *compute_layout(const GfxShader *cs, Bindings *B, const char **why
// (shader-prepared.bin) the pre-rasterization library of a vertex shader, the fragment-shader library of a fragment
// shader and the pipeline of a compute shader, each built from a private shader copy and destroyed at once. What
// stays is the driver's own disk cache: on AMD a library built again in a later process takes 0.1 ms instead of
// 55 ms (vertex) / 28 ms (fragment) (build/v121-sl NOTES, lib bench). Our pipeline-cache.bin is not written there:
// 55 ms (vertex) / 28 ms (fragment). Our pipeline-cache.bin is not written there:
// it would grow by about 10 KB per library (~240 MB) and be read into memory at every boot.
// - boot (lb_worker), after the pipeline-key prewarm, on cpus/4 threads at THREAD_PRIORITY_IDLE (the short P.lock
// sections and shader loads at normal priority, so a preempted thread never holds the lock the replay needs):
@@ -2791,7 +2791,7 @@ static void lb_state(const uint32_t pr_hist[16], const uint32_t fs_hist[4]) {
uint32_t best = 0, bf = 0;
for (uint32_t i = 1; i < 16; i++) best = pr_hist[i] > pr_hist[best] ? i : best;
for (uint32_t i = 1; i < 4; i++) bf = fs_hist[i] > fs_hist[bf] ? i : bf;
if (!pr_hist[best]) best = 8; // no key file: TotK clips -w..w (all 2706 records of build/v121's key file)
if (!pr_hist[best]) best = 8; // no key file: TotK clips -w..w (all 2706 records of a recorded key file)
LB.clamp = (uint8_t)(best & 1), LB.poly = (uint8_t)(best >> 1 & 3), LB.minus_w = (uint8_t)(best >> 3 & 1);
LB.samples = (uint8_t)(1u << bf);
}
+3 -3
View File
@@ -311,8 +311,8 @@ static Tex *create_tex(const tex_t *t, const TexKey *k, int defer_init) {
if (block_views_ok(&bc)) ci = bc, usage = bc.usage, flags = bc.flags, block_views = 1;
}
// Feedback loops (vk.h VkCtx.feedback): every attachable image may be sampled by a draw of a pass that renders it,
// so it gets the usage now; adding it when a loop shows up would mean recreating the image (build/v121-fb lost the
// grass tile maps that way).
// so it gets the usage now; adding it when a loop shows up would mean recreating the image (that lost the
// grass tile maps once).
int fb_usage = c->feedback == VK_FEEDBACK_LAYOUT && !block_views &&
(usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT));
if (fb_usage) ci.usage = usage |= VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
@@ -1317,7 +1317,7 @@ void vk_texture_write_back(uint64_t addr, uint64_t size) {
// TotK's grass system renders a 128x128 RGBA8 map of cut and trampled grass into a CPU-cached pool every frame and its
// CPU code reads the pool bytes without nvnMemoryPoolInvalidateMappedRange (cut reactions: blades, insects, the cut
// itself; build/v121-bloom NOTES.md). On the Switch the bytes are there once the frame's fence has passed. So when the
// itself). On the Switch the bytes are there once the frame's fence has passed. So when the
// CPU waits for a fence, mirrored targets up to WB_SMALL bytes rendered by work up to that fence go back to their
// storage, unless the CPU rewrote it since. Larger targets still go back on an invalidate, memcpy or ReadTexels.
int vk_texture_small_dirty(void) { return __atomic_load_n(&small_pending, __ATOMIC_ACQUIRE); }