Skip to content

texture_cache: env-gated stale write-backs for Ocarina's pause menu preview - #2660

Draft
zortos293 wants to merge 2 commits into
nx2from
capy/oot-stale-writeback
Draft

zortos293 wants to merge 2 commits into
nx2from
capy/oot-stale-writeback

Conversation

@zortos293

@zortos293 zortos293 commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Test build for #2056 (Ocarina of Time pause-menu item preview shows coloured noise). Both new behaviours are behind EDEN_NX2_OOT_STALE_WRITEBACK, apply only to Ocarina of Time (0400486024DEC000), and are off when the variable is unset. Refs #2056.

Evidence. In four Intel Iris Xe Ctrl+F12 bundles (builds 386 and 411), the item preview is a 1120x1333 B10G11R11_FLOAT texture. One draw in the UI pass samples it, and nothing in the frame renders it. Its contents are fragments of other images plus NaN and Inf texels, which is recycled host memory. That matches the collector dropping a GPU-written BadOverlap image without a write-back and then making a new image over the stale pages with no upload. Ocarina is kept out of WritebackDefault for performance (#2038, #818). This test build has not yet confirmed that the preview takes the stale-skip path. A bundle with EDEN_NX2_TC_TRACE=1 will show it.

Switch.

  • EDEN_NX2_OOT_STALE_WRITEBACK=1: the collector writes back only the BadOverlap images a later frame sampled after their last write. Each image now records the frame of its last GPU write (MarkModification) and of its last read preparation (PrepareImage without modification). Contents joined or alias-synchronized from other images carry the source's write frame, and an image with no known write frame is never written back. Render targets a frame writes and reads within that same frame stay excluded. Build 428 predates the write-frame carry, so in its mode 1 joined images could be written back too. Writes go through the existing async overlap-download path. The first 8 of every 256 log an OoT stale write-back line.
  • EDEN_NX2_OOT_STALE_WRITEBACK=2: Ocarina gets the full WritebackDefault set (collector and join write-backs, stale-page uploads), as texture_cache: turn on overlap write-backs and stale uploads for Kirby NS2E #2452 gave Kirby NS2E. Mode 2 is Vulkan only, matching texture_cache: write back dropped GPU-written overlaps in Fire Emblem #2206's Fortune's Weave gate; mode 1 runs on the same staging-map path texture_cache: turn on overlap write-backs and stale uploads for Kirby NS2E #2452 uses and is inert on OpenGL.
  • Unset or any other value: unchanged.

Checks. The [writeback] tests add parsing cases and still require WritebackDefault(0x0400486024DEC000, backend) to be false on every backend. The switch header passes -fsyntax-only -Wall -Werror on x86_64. The branch was rebased onto nx2 after #2206 landed, so WritebackDefault keeps its per-backend signature and Fortune's Weave stays on. The full aarch64 and macOS arm64 compile comes from this branch's release-binaries run.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copy link
Copy Markdown
Contributor

One potential confound for the mode-1 experiment at c33e435: JoinImages' non-alias GPU copy path sets new_image.flags |= GpuModified and inherits modification_tick, but doesn't inherit last_written_frame. SynchronizeAliases also inherits the tick/modified flag without that frame. A newly joined image can therefore be written indirectly and sampled in the same frame, yet pass last_sampled_frame > last_written_frame (with the latter still 0); the write-back log then prints an underflowed written frame.

A small synthetic predicate model of 1,632 inherited-write/sample combinations gave 256 same-frame misclassifications; propagating the source's write-frame stamp in that model eliminated them. No Vulkan/game execution was involved. For the diagnostic, it may help to log the zero sentinel explicitly and propagate write-frame provenance alongside the inherited modification tick (including alias synchronization), so mode 1 doesn't accidentally include the same-frame render targets it is intended to exclude.

zortos293 added a commit that referenced this pull request Nov 27, 2026
A joined or alias-synchronized image took the source's modification tick but kept last_written_frame 0, so EDEN_NX2_OOT_STALE_WRITEBACK=1 counted its same-frame contents as sampled after their write and logged an underflowed frame. Take the source's write frame there, and require a known write frame. Reported by RomainROCH on #2660.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai

capy-ai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Replying to #2660 (comment)

Confirmed and fixed in 62c9dea. Both JoinImages copy paths (alias and non-alias) and SynchronizeAliases now take the source's last_written_frame (the newest one, when several aliases are newer) beside the inherited modification tick. Those three, with MarkModification, are the only places that set GpuModified. Mode 1 now also needs a known write frame (last_written_frame != 0), so the log can't print an underflowed frame.

On build 428 (c33e435) the bug could only widen mode 1. Joined or alias-synced images were written back even when they were written and sampled in the same frame. So that build's visual result still stands, and its FPS cost is a worst case for mode 1. No new test build is planned for this.

atmanli added a commit to atmanli/Lichii that referenced this pull request Nov 27, 2026
atmanli added a commit to atmanli/Lichii that referenced this pull request Nov 27, 2026
atmanli added a commit to atmanli/Lichii that referenced this pull request Nov 28, 2026
atmanli added a commit to atmanli/Lichii that referenced this pull request Nov 28, 2026
atmanli added a commit to atmanli/Lichii that referenced this pull request Nov 28, 2026
atmanli added a commit to atmanli/Lichii that referenced this pull request Nov 29, 2026
zortos293 and others added 2 commits November 29, 2026 06:25
…review

EDEN_NX2_OOT_STALE_WRITEBACK=1 writes back the BadOverlap images the collector drops that a later frame sampled after their last write; =2 puts Ocarina in the WritebackDefault set. Off by default. Refs #2056.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A joined or alias-synchronized image took the source's modification tick but kept last_written_frame 0, so EDEN_NX2_OOT_STALE_WRITEBACK=1 counted its same-frame contents as sampled after their write and logged an underflowed frame. Take the source's write frame there, and require a known write frame. Reported by RomainROCH on #2660.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@zortos293
zortos293 force-pushed the capy/oot-stale-writeback branch from 62c9dea to e5c09fc Compare November 29, 2026 06:25
@capy-ai capy-ai Bot mentioned this pull request Nov 29, 2026
2 of 3 tasks
zortos293 added a commit that referenced this pull request Nov 29, 2026
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

# Conflicts:
#	src/video_core/texture_cache/image_base.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants