Skip to content

Refresh uniform handle tables after inline updates and new submissions - #2228

Closed
akratch wants to merge 1 commit into
seedds:mainfrom
akratch:contrib/htab-update-20261110
Closed

akratch wants to merge 1 commit into
seedds:mainfrom
akratch:contrib/htab-update-20261110

Conversation

@akratch

@akratch akratch commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

What and why

A draw can encode fresh arguments after an inline uniform update yet keep the previous texture/sampler handle table. The TEXH/SAMPH snapshot fast path checked pass, registrations and size but not the queued writes. Compute-only submissions can also share the last render-pass serial and reuse a prior submission's table.

Require the same submission and pending-write count, with no tracking overflow, before taking that fast path. Otherwise the existing inline-update reader reconstructs the handles and compares results. A changed table gets a new immutable GPU buffer; earlier commands retain their table. Equal handles/resource IDs still reuse their buffer.

This is a scoped inline-update/submission fix. GPU-produced, copied or filled handles retain their separately diagnosed CPU-visibility limitation. No shader translation, rendering quality or pacing policy is changed. No frame-rate gain or attribution to OOT's white glow/floor captures is claimed.

Checked

  • Exact base 4c574a6f055217ac0b6d5fbeccd1eb22b86dbe90; standalone head 4761bd9bc6c0c30fe178cd2f5eec35f9aeb18931.
  • t_htab_update: 62 checks, zero failures, both DM_NVN_ENC_THREAD=0 and 1, with Metal validation. Production argument encoding feeds real render and compute submissions. Literal red/green textures and distinct clamp/repeat samplers expose stale selection; the first draw's pixels must remain unchanged. Covers full/partial inline updates, an unrelated-write control, two dispatches and a new compute submission with unchanged render-pass serial.
  • With only the production file restored to the exact upstream base and builds forced, the same fixture fails 8 of 62 in both modes. Restoring the exact candidate and rebuilding passes again. The earlier integrated b0-based version independently showed the same eight failing checks.
  • Standalone Mac host build passes; unchanged cached libvpx/dav1d archives reused, current host sources compiled. Six documentation tests pass. Focused LLVM 23.1.5 analysis of backend/fixture has zero new findings against the unchanged 223-finding baseline; fixture has zero findings.
  • Apple M4 Max, macOS 27.2 (26B123), Xcode 27.2 (27B52).
  • No game was run on this standalone head. An inventory of all 42,848 locally completed OOT reflections found five shaders with both table kinds (four fragment, one compute); that establishes potential reach, not their execution during any reported visual defect.
  • regress.py impact: Breath of the Wild, Pokémon Scarlet and Tears of the Kingdom use affected entry points; 153 profiles lack usage manifests. No multi-game or iOS gameplay sweep. The literal-pixel synthetic oracle validates this narrow resource-selection contract; broader regressions and long play remain unchecked.

Docs

A TEXH/SAMPH snapshot's same-pass fast path ignored queued uniform writes.
Later draws could encode fresh argument blocks yet retain the earlier texture
or sampler selection. Compute submissions also share the last render-pass
serial, allowing a prior submission's table to survive into a fresh one.

Match the submission and pending-write count before reusing the CPU lookup.
Read existing inline overlays otherwise, retaining immutable prior GPU tables
and preserving identical-table reuse. GPU-produced/copied/filled handles have
an independent existing CPU-visibility limitation and are not repaired here.

The real argument-encoding/render/compute fixture passes 62 checks in both
encoder modes under Metal validation; the exact same fixture fails eight with
only the production source restored to b0cb24ee. Six docs tests pass and focused
LLVM 23.1.5 analysis has zero new findings against the unchanged baseline.

Co-authored-by: Adam Kratch <70729875+akratch@users.noreply.github.com>
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation game: 0400486024DEC000 A game labels Nov 10, 2026
seedds added a commit that referenced this pull request Nov 13, 2026
…or a new submission (PR #2228)

htab_gpu kept a table of a uniform buffer's handles while the pass serial,
the registrations and the size stayed the same. An inline update deferred in
an open pass, a copy or a fill could change the handles in between, and a
compute-only submission keeps the last pass's serial, so later draws and
dispatches sampled the earlier texture or sampler.

A table is now kept only in the same submission and when no write queued
since its last look lands on its bytes (htab_written, which scans only the
writes since through pend_since). Writes to other uniform blocks, which games
make before nearly every draw, keep the table without reading it again; the
table log line counts the reads.

t_htab_update (from the PR) encodes real draws and dispatches: 67 checks pass
with and without the encoder thread under Metal validation; main failed 8,
and checking every queued write instead of the overlapping ones fails the
write-beside-the-table check. No game run: no local build reads handle tables.

Co-authored-by: Adam Kratch <70729875+akratch@users.noreply.github.com>
@seedds

seedds commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Thanks — landed on main as 41acde7, with you as co-author. The diagnosis, the fixture and the submission/queued-write checks are yours.

One change: the fast path is now invalidated only by a queued write that overlaps the table's own bytes (htab_written, which scans the writes since the last look through pend_since), not by any queued write in the submission. Games update other uniform blocks before nearly every draw, so the any-write check would have re-read up to 32–64 KB per table per draw. The fixture gained checks that a write beside the table keeps it without a re-read (the any-write version fails that), and the table log line now counts re-reads.

The reference entry moved to docs/reference/shaders.md, next to the other handle-table entries ("A handle table kept past a write to its handles"). The Ocarina of Time note was dropped, since no symptom there is attributed to it. Fixture 67/67 in both encoder modes, gfx test list, docs tests and lint pass. No game was run: no local build reads handle tables.

@seedds seedds closed this Nov 13, 2026
kingbumi31 pushed a commit to kingbumi31/no-lag-kart that referenced this pull request Nov 15, 2026
…e updates and new submissions (seedds)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcmewFJDrDUooyBk9ygMAv
kingbumi31 pushed a commit to kingbumi31/no-lag-kart that referenced this pull request Nov 15, 2026
seedds#2182, seedds#2225, seedds#2194, seedds#2273 (mkw/sets.tsv)

Each corrects wrong behaviour on code this game runs and brings a test that fails without it or a measurement; none changes the shader chain. Built on this Mac with 58 warnings as upstream; t_fstep passes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcmewFJDrDUooyBk9ygMAv
kingbumi31 added a commit to kingbumi31/no-lag-kart that referenced this pull request Nov 15, 2026
…e updates and new submissions (seedds)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcmewFJDrDUooyBk9ygMAv
kingbumi31 added a commit to kingbumi31/no-lag-kart that referenced this pull request Nov 15, 2026
seedds#2182, seedds#2225, seedds#2194, seedds#2273 (mkw/sets.tsv)

Each corrects wrong behaviour on code this game runs and brings a test that fails without it or a measurement; none changes the shader chain. Built on this Mac with 58 warnings as upstream; t_fstep passes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcmewFJDrDUooyBk9ygMAv
kingbumi31 added a commit to kingbumi31/no-lag-kart that referenced this pull request Nov 15, 2026
…e updates and new submissions (seedds)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcmewFJDrDUooyBk9ygMAv
kingbumi31 added a commit to kingbumi31/no-lag-kart that referenced this pull request Nov 15, 2026
seedds#2182, seedds#2225, seedds#2194, seedds#2273 (mkw/sets.tsv)

Each corrects wrong behaviour on code this game runs and brings a test that fails without it or a measurement; none changes the shader chain. Built on this Mac with 58 warnings as upstream; t_fstep passes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcmewFJDrDUooyBk9ygMAv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0400486024DEC000 A game nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants