rdna2spirv: do not cache a missing stage index #2194

Closed
github-bot wants to merge 2 commits from github-bot/gh-2194 into main AGit
Owner

@⁠whoalin1 on GitHub · 2026-11-26 04:46 UTC · original
whoalin1:shader-stage-cache-missing-index → main · +76 −4 · 2 files · 2 commits · closed without merging

Depends on: #2154
Claimed in the coordination issue as SHADER-STAGE-CACHE-MISSING-INDEX (comment 7182872123).

What

qhukz13's #2154 review noted a remaining edge case: even with the stage cache keyed by carve root, a missing index.json is cached as that root's empty table for the rest of the process. If the index is created later, stage_of() keeps using the fallback stage until _STAGES is reset.

This follow-up caches only successful index reads. A missing file is probed again on the next lookup; a root whose index did load is still cached exactly as #2154 intends.

Test

Adds a synthetic missing-then-created regression case to tests/test_rdna2spirv_stage_cache.py.

  • python -I tests/test_rdna2spirv_stage_cache.py — 3 tests OK
  • python -I tests/test_bvh_shaders_stage.py — 13 tests OK
  • python -I tests/test_exe_shaders_stage.py — 11 tests OK
  • python -I tests/test_shader_library.py — 22 run, 21 passed + 1 skipped
  • python -m compileall -q tools/rdna2spirv.py tests/test_rdna2spirv_stage_cache.py — PASS

No game data.

AI-assisted.

**@⁠whoalin1** on GitHub · 2026-11-26 04:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2194) `whoalin1:shader-stage-cache-missing-index` → `main` · +76 −4 · 2 files · 2 commits · closed without merging Depends on: #2154 Claimed in the coordination issue as `SHADER-STAGE-CACHE-MISSING-INDEX` (comment 7182872123). ## What qhukz13's #2154 review noted a remaining edge case: even with the stage cache keyed by carve root, a missing `index.json` is cached as that root's empty table for the rest of the process. If the index is created later, `stage_of()` keeps using the fallback stage until `_STAGES` is reset. This follow-up caches only successful index reads. A missing file is probed again on the next lookup; a root whose index did load is still cached exactly as #2154 intends. ## Test Adds a synthetic missing-then-created regression case to `tests/test_rdna2spirv_stage_cache.py`. - `python -I tests/test_rdna2spirv_stage_cache.py` — 3 tests OK - `python -I tests/test_bvh_shaders_stage.py` — 13 tests OK - `python -I tests/test_exe_shaders_stage.py` — 11 tests OK - `python -I tests/test_shader_library.py` — 22 run, 21 passed + 1 skipped - `python -m compileall -q tools/rdna2spirv.py tests/test_rdna2spirv_stage_cache.py` — PASS No game data. AI-assisted.
stage_of cached the first index.json it read in process-global _STAGES and
reused it for every later shader. A process that translates programs from two
carve roots can therefore pick the first root's stage for a shader in the
second root, changing stage-dependent codegen.

Keep the process-local cache, but key it by the resolved index.json path. The
synthetic two-root regression test fails on main with the second root reported
as the first root's stage and passes with the fix.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
A carve root without index.json cached an empty stage table for the rest of the process, so creating the index later still left every shader at its fallback stage. Cache only successful index reads; a missing file is probed again on the next lookup. Add a synthetic missing-then-created regression test on top of the per-root cache coverage.

Depends on: #2154

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:21:55 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-26 04:50 UTC · original

Additional focused verification on the stacked head c5c367a2a: tests/test_rdna2spirv_stage_cache.py 3/3 OK; tests/test_bvh_shaders_stage.py 13/13 OK; tests/test_exe_shaders_stage.py 11/11 OK; tests/test_shader_library.py 22 run, 21 passed + 1 skipped. compileall PASS. No game data.

**@⁠whoalin1** on GitHub · 2026-11-26 04:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2194#issuecomment-7182946990) Additional focused verification on the stacked head c5c367a2a: tests/test_rdna2spirv_stage_cache.py 3/3 OK; tests/test_bvh_shaders_stage.py 13/13 OK; tests/test_exe_shaders_stage.py 11/11 OK; tests/test_shader_library.py 22 run, 21 passed + 1 skipped. compileall PASS. No game data.
Author
Owner

@⁠real-rusher on GitHub · 2026-11-26 10:06 UTC · original

Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_rdna2spirv_stage_cache.py: 3 tests OK. The same test file against main's tools/rdna2spirv.py: 2 failures, so it fails on main and passes with the fix. compileall clean.

AI-assisted: yes (Claude Code)

**@⁠real-rusher** on GitHub · 2026-11-26 10:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2194#issuecomment-7188919257) Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_rdna2spirv_stage_cache.py: 3 tests OK. The same test file against main's tools/rdna2spirv.py: 2 failures, so it fails on main and passes with the fix. compileall clean. AI-assisted: yes (Claude Code)
Author
Owner

@⁠Tauwni on GitHub · 2026-11-26 12:50 UTC · original

Tested c5c367a2a on macOS 26.5.1 (Apple M3, Python 3.15). CPU only, synthetic fixtures.

  • tests/test_rdna2spirv_stage_cache.py: 3/3 pass, test_bvh_shaders_stage.py 13/13, test_exe_shaders_stage.py 11/11, and test_shader_library.py 22/22.
  • Control: with this PR's one-line change to tools/rdna2spirv.py reverted (back to #2154's head), test_a_missing_index_is_not_cached fails. With it, the test passes. So the new case does catch the cached miss.
  • The branch merges cleanly with main a73a57e13.

AI-assisted (Claude Code). No game data.

**@⁠Tauwni** on GitHub · 2026-11-26 12:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2194#issuecomment-7192531712) Tested `c5c367a2a` on macOS 26.5.1 (Apple M3, Python 3.15). CPU only, synthetic fixtures. - `tests/test_rdna2spirv_stage_cache.py`: 3/3 pass, `test_bvh_shaders_stage.py` 13/13, `test_exe_shaders_stage.py` 11/11, and `test_shader_library.py` 22/22. - Control: with this PR's one-line change to `tools/rdna2spirv.py` reverted (back to #2154's head), `test_a_missing_index_is_not_cached` fails. With it, the test passes. So the new case does catch the cached miss. - The branch merges cleanly with `main` `a73a57e13`. AI-assisted (Claude Code). No game data.
github-bot closed this pull request 2026-11-26 13:26:15 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-26 13:23 UTC · original

Consolidated into #2154 without rewriting: #2154 was fast-forwarded to this PR's exact head c5c367a2a, so the missing-index fix and regression test are preserved there. Closing this stacked follow-up to reduce review noise.

**@⁠whoalin1** on GitHub · 2026-11-26 13:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2194#issuecomment-7193277534) Consolidated into #2154 without rewriting: #2154 was fast-forwarded to this PR's exact head `c5c367a2a`, so the missing-index fix and regression test are preserved there. Closing this stacked follow-up to reduce review noise.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.