From a8fa1a93705a3ae531d3c22f18b06a2491bdbdf3 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Wed, 11 Nov 2026 11:28:36 -0500 Subject: [PATCH 1/3] Point the AppImage runner's package sources at Ubuntu's own archive and try apt three times, since the runner's mirror host stopped resolving. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/linux-appimage.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux-appimage.yml b/.github/workflows/linux-appimage.yml index 55f9b57e..687fffb2 100644 --- a/.github/workflows/linux-appimage.yml +++ b/.github/workflows/linux-appimage.yml @@ -35,7 +35,16 @@ jobs: - uses: astral-sh/setup-uv@v6 - name: Shader compilers # make_appimage.py compiles the runtime's own shaders (tools/build_shaders.py: glslc, spirv-as, spirv-val) - run: sudo apt-get update && sudo apt-get install -y glslc spirv-tools + # The runner's sources go through a mirror list whose first host (azure.archive.ubuntu.com) stopped resolving + # on 2026-11-11, and apt then failed every fetch: the sources name Ubuntu's own archive instead. + run: | + sudo sed -i 's|mirror+file:/etc/apt/apt-mirrors.txt|http://archive.ubuntu.com/ubuntu/|' \ + /etc/apt/sources.list.d/*.sources /etc/apt/sources.list 2>/dev/null || true + for i in 1 2 3; do + sudo apt-get update && sudo apt-get install -y glslc spirv-tools && exit 0 + echo "apt failed ($i), trying again in 30 s"; sleep 30 + done + exit 1 - name: Shader translator and VMA run: | uv venv -q --python 3.12 .venv From bdcf07bbf624971d3d8edd27acf92610c571241a Mon Sep 17 00:00:00 2001 From: chrg6 Date: Wed, 11 Nov 2026 11:39:52 -0500 Subject: [PATCH 2/3] Take the AppImage's shader compilers from LunarG's Vulkan SDK when Ubuntu's archive does not resolve on the runner. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/linux-appimage.yml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linux-appimage.yml b/.github/workflows/linux-appimage.yml index 687fffb2..79c245e0 100644 --- a/.github/workflows/linux-appimage.yml +++ b/.github/workflows/linux-appimage.yml @@ -35,16 +35,29 @@ jobs: - uses: astral-sh/setup-uv@v6 - name: Shader compilers # make_appimage.py compiles the runtime's own shaders (tools/build_shaders.py: glslc, spirv-as, spirv-val) - # The runner's sources go through a mirror list whose first host (azure.archive.ubuntu.com) stopped resolving - # on 2026-11-11, and apt then failed every fetch: the sources name Ubuntu's own archive instead. + # On 2026-11-11 the runners could not resolve Ubuntu's archive hosts (azure.archive.ubuntu.com, then + # archive.ubuntu.com) and apt failed every fetch for hours. When they do not resolve, the three tools come from + # LunarG's Vulkan SDK for Linux instead, which holds all of them. run: | - sudo sed -i 's|mirror+file:/etc/apt/apt-mirrors.txt|http://archive.ubuntu.com/ubuntu/|' \ - /etc/apt/sources.list.d/*.sources /etc/apt/sources.list 2>/dev/null || true - for i in 1 2 3; do + if getent hosts azure.archive.ubuntu.com >/dev/null || getent hosts archive.ubuntu.com >/dev/null; then sudo apt-get update && sudo apt-get install -y glslc spirv-tools && exit 0 - echo "apt failed ($i), trying again in 30 s"; sleep 30 + echo "::warning::apt failed: the shader compilers come from the Vulkan SDK" + else + echo "::warning::Ubuntu's archive does not resolve: the shader compilers come from the Vulkan SDK" + fi + sdk="$RUNNER_TEMP/vulkan-sdk" + mkdir -p "$sdk" + for f in vulkan-sdk.tar.xz vulkan-sdk.tar.gz; do + curl -fsSL --retry 3 -o "$RUNNER_TEMP/$f" "https://sdk.lunarg.com/sdk/download/latest/linux/$f" && + tar -xf "$RUNNER_TEMP/$f" -C "$sdk" && break done - exit 1 + bin=$(dirname "$(find "$sdk" -type f -name glslc -path '*/bin/*' | head -1)") + test -x "$bin/glslc" && test -x "$bin/spirv-as" && test -x "$bin/spirv-val" + echo "$bin" >> "$GITHUB_PATH" + if ! "$bin/spirv-as" --version >/dev/null 2>&1; then # the SDK's tools may link its own shared libraries + echo "LD_LIBRARY_PATH=$(cd "$bin/../lib" && pwd)${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV" + fi + "$bin/glslc" --version | head -1 - name: Shader translator and VMA run: | uv venv -q --python 3.12 .venv From ae0c8140a2f6200cab5c3db26b16d7765ce08540 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Wed, 11 Nov 2026 12:18:52 -0500 Subject: [PATCH 3/3] Finalize only the slots a texture object registered itself, so the next streamed piece of ground keeps its heightmap. Ocarina streams its terrain heightmaps (R32F, 260x260) through a fixed set of storage. It initializes the next piece's texture at the storage of the one before, registers it in the texture pool, and only then finalizes the old texture object, which has the same parameters. vk_texture.c vk_texture_release marked every slot at the storage with the same parameters as finalized, the new registration too. A finalized CPU-written slot takes no image made from its storage again (slot_resolve's stale rule), so the new piece drew the zero stand-in and was drawn at height zero, far below the ground around it: the holes and stretched ground of issues #453 and #569, through which the sky shows. A finalize now marks only the slots registered with its own texture object (the initialization serial); a slot registered with another texture object at the same storage names that one, which is still live. From pull request #535 by MartinIsla, in its final form, which no longer skips the whole release while another texture with the same parameters is live (that kept textures the game had released and drew dark lines in Kakariko's fog). --probe-vkmem gets the pull request's check: a release leaves another live texture's slot current and marks its own; it fails on the old rule and passes with this one, with and without shadow storage. Added here: under the perf trace a line every 60 frames counts the slots a finalize marked, the slots of another live texture it left current and the lookups the stale rule answered with the stand-in, the terrain's heightmaps counted apart, so a run shows whether the case comes up and whether stand-ins are still drawn. Co-Authored-By: Claude Opus 5.5 --- docs/architecture.md | 4 +++- runtime/tex_probe.c | 9 +++++++++ runtime/vk_texture.c | 30 ++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index eada8886..0eceb60a 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -100,7 +100,9 @@ keeps per-core data without locks and relies on that, so the host models it (`ru (`vk_exec_draw.c pool_sync`); slots that resolve alike share one lookup. Finalization is retained on registered slots independently of image-cache eviction: a stale CPU-backed descriptor cannot recreate an image from freed storage or follow newly reused CPU bytes. Registration makes it current again; - finalized descriptors may still follow live GPU-owned content. + finalized descriptors may still follow live GPU-owned content. A finalize marks only the slots its own texture + object registered (by initialization serial): the game initializes and registers the next terrain heightmap at the + storage of the previous one before it finalizes that one (`vk_texture.c vk_texture_release`). - Shaders: Ampere (SM86) code is lowered to Maxwell (`tools/xlate/AmpereLowering.cs`) and translated to SPIR-V by the pinned shader translator (`tools/vendor/ryujinx`, 1.3.2) with our patches (`tools/xlate/patches/`), built with .NET 10 NativeAOT as `nx2navi_xlate.exe` and run as separate processes. Translations are cached on disk; shaders and pipelines seen in diff --git a/runtime/tex_probe.c b/runtime/tex_probe.c index 0e0c53dc..3905c530 100644 --- a/runtime/tex_probe.c +++ b/runtime/tex_probe.c @@ -961,7 +961,16 @@ static int test_textures(pool_t *tpool, pool_t *phys) { const VkTexImage *renewed = vk_texture_by_id(5, NULL, NULL); GCHECK(renewed && renewed->format == VK_FORMAT_BC1_RGBA_UNORM_BLOCK && renewed->width == 64 && renewed->height == 48, "re-registered CPU slot 5 did not resolve its own descriptor"); + // A release finalizes only the slots of its own texture object: another texture initialized at the same storage + // with the same parameters before the finalize keeps its slot (vk_texture_release, terrain heightmaps). + tex_t bn = b; + bn.serial = 6; + vk_texture_register(6, &bn, NULL); vk_texture_release(&b); + const VkTexImage *kept = vk_texture_by_id(6, NULL, NULL); + GCHECK(kept && kept->width == 64 && kept->height == 48 && !vk_texture_by_id(5, NULL, NULL), + "a release finalized slot 6 of another live texture, or left its own slot 5 current"); + vk_texture_release(&bn); // Once the live texture at its storage holds GPU content the storage bytes lack, the finalized CPU slot follows it. // The live texture is cleared on the GPU and noted as rendered into, as a draw into it would be; the slot's image // must then show the clear, which neither the storage bytes nor a recreated image of the slot's own descriptor hold. diff --git a/runtime/vk_texture.c b/runtime/vk_texture.c index 90c74c11..c2032b53 100644 --- a/runtime/vk_texture.c +++ b/runtime/vk_texture.c @@ -1537,6 +1537,15 @@ int vk_texture_pool_fresh_locked(void) { // slot_resolve's last answer was none because of its stale rule (vk_texture_slot_retry_locked) static int resolve_stale; +// NX2NAVI_TRACE=perf, since the last perf line: slots a finalize marked (its own texture object's), slots at the storage +// with the same parameters registered with another texture object, which a finalize leaves current +// (vk_texture_release), and lookups the stale rule answered with the stand-in (slot_resolve). _hm: of them, the +// terrain's streamed heightmaps (R32F 260x260), whose stand-in draws a chunk of ground at height zero. +static uint64_t n_fin_own, n_fin_other, n_fin_other_hm, n_stale, n_stale_hm; +static int terrain_heightmap(const tex_t *t) { + return t->d.format == NVN_FORMAT_R32F && t->d.width == 260 && t->d.height == 260; +} + int vk_texture_slot_retry_locked(int id) { if (id < 0 || id >= ntslots || !tslots[id].used || !tslots[id].t.mem) return -1; resolve_stale = 0; @@ -3545,6 +3554,11 @@ void vk_texture_release(const tex_t *t) { // Staleness belongs to the registered descriptor, not the cached image: a released Tex can be destroyed before the // slot looks again (eviction, the released cap, start_at for a mirrored one). A registered texture may also be // finalized before its image is created. + // Only the slots this texture object registered (its initialization serial): a slot registered with another + // texture initialized at the same storage with the same parameters names that one, which is still live. Ocarina + // streams terrain heightmaps (R32F 260x260) through a fixed set of storage and initializes and registers the next + // chunk's texture there before it finalizes the previous one; finalizing the new registration left the slot stale, + // the draws sampled the zero stand-in, and the chunk was drawn at height zero, tens of metres below the ground. int changed = 0; if (sinfo) for (int id = bucket_head[agen_idx(k.addr)]; id >= 0; id = slot_next[id]) { @@ -3552,7 +3566,13 @@ void vk_texture_release(const tex_t *t) { if (s->finalized || (uintptr_t)s->t.mem != k.addr) continue; TexKey sk; make_key(&s->t, &sk); - if (!memcmp(&sk, &k, sizeof k)) s->finalized = 1, s->ce = NULL, changed = 1; + if (memcmp(&sk, &k, sizeof k)) continue; + if (s->t.serial != t->serial) { // another texture object's registration: it stays current + n_fin_other++, n_fin_other_hm += terrain_heightmap(&s->t); + continue; + } + s->finalized = 1, s->ce = NULL, changed = 1; + n_fin_own++; } if (e && !e->released) { mark_released(e); @@ -3701,7 +3721,7 @@ static Tex *slot_resolve(TexSlot *s, view_t *view, int *has_view) { // after its released image was evicted; registering the descriptor again makes it current. if (!e && any) e = any; else if (!e && !cpu_slot) e = own && own->superseded ? NULL : own; // a superseded one: entry_of takes it back - else if (!e && cpu_slot && s->finalized) stale = 1; + else if (!e && cpu_slot && s->finalized) stale = 1, n_stale++, n_stale_hm += terrain_heightmap(&s->t); } resolve_stale = stale; if (!e && s->t.mem && !stale) { @@ -3957,6 +3977,12 @@ void vk_texture_new_submit(void) { (unsigned long long)n_mark_empty, (unsigned long long)n_mark_none); memset(n_drop_by, 0, sizeof n_drop_by), memset(n_cpu_empty, 0, sizeof n_cpu_empty); n_mark_empty = n_mark_none = 0; + rt_log("perf: frame %llu: texture finalizes: slots marked %llu; slots of another live texture with the same " + "parameters at the storage, left current %llu (terrain heightmaps %llu); lookups the stale rule gave the " + "stand-in %llu (terrain heightmaps %llu)", (unsigned long long)f * 60, (unsigned long long)n_fin_own, + (unsigned long long)n_fin_other, (unsigned long long)n_fin_other_hm, (unsigned long long)n_stale, + (unsigned long long)n_stale_hm); + n_fin_own = n_fin_other = n_fin_other_hm = n_stale = n_stale_hm = 0; if (split_mode > 0) rt_log("perf: frame %llu: split fill: entries the CPU does not write started with their storage's bytes: " "copied from the released entry they replaced %llu, filled from storage %llu (%.1f MiB, %.2f ms), "