Skip to content

rdna2spirv: do not cache a missing stage index - #2194

Closed
whoalin1 wants to merge 2 commits into
ProjectLeonida:mainfrom
whoalin1:shader-stage-cache-missing-index
Closed

whoalin1 wants to merge 2 commits into
ProjectLeonida:mainfrom
whoalin1:shader-stage-cache-missing-index

Conversation

@whoalin1

@whoalin1 whoalin1 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 and others added 2 commits November 26, 2026 02:19
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: ProjectLeonida#2154

AI-assisted.
@whoalin1

Copy link
Copy Markdown
Contributor Author

Additional focused verification on the stacked head c5c367a: 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.

@real-rusher

Copy link
Copy Markdown
Contributor

Verified on main a73a57e (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)

@Tauwni

Tauwni commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

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 rdna2spirv: cache shader stages per carve root #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.

@whoalin1

Copy link
Copy Markdown
Contributor Author

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 whoalin1 closed this Nov 26, 2026
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.

3 participants