Repository navigation
Conversation
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>
|
Full semantic verification on the PR head |
|
Checked at
Looks right to me. AI-assisted (Claude Code). |
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.
|
Thanks for the detailed check. The missing-index edge you called out is carried in the stacked follow-up #2194: it caches only successful index reads, so a root whose |
|
Verified on main a73a57e (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. python -I tests/test_rdna2spirv_stage_cache.py: 2 tests OK with this PR; the same file against main's translator: 1 failure, so it fails on main and passes with the change. compileall clean. #2194 (do not cache a missing stage index) touches the same cache: the two merge together cleanly, and with both merged, each PR's version of tests/test_rdna2spirv_stage_cache.py passes. AI-assisted: yes (Claude Code) |
wavehs
left a comment
There was a problem hiding this comment.
macOS arm64 check of #2154 (rdna2spirv stage cache per carve root). A small tool change with a focused test; runs here without a GPU.
Tested head c5c367a2a merged onto main bdbc7e923 as merge 0a5f09382 (clean, no conflicts).
Environment: Apple M3 Pro arm64, macOS 27.2.1, CPython 3.15.2.
On the merge
python -I tests/test_rdna2spirv_stage_cache.py: 3 tests OK - two roots with the same shader name get their own stages (psthencs), the same root stays cached (deleting itsindex.jsonafterwards still answers), and a missing index is not cached (creating it later is picked up).- Whole semantic suite:
500 files, 6367 tests, 0 files failed- no change, as expected. - The cache now keys on
os.path.normcase(os.path.realpath(index.json)), so two spellings of one root share an entry on Windows and two carve roots cannot cross-contaminate. The bug was real in the in-process users (tools/image_bvh_census.py:753,tools/ptr_truncation_census.py:147,tools/wave32_pixel_scan.py:232,tools/wave64_graphics_scan.py:121): a census over several roots would answer the second root's same-named shaders from the first root's index.
Negative control (new test kept, tools/rdna2spirv.py reverted to main)
FAILED (failures=2)in the new file: the second-root case and the missing-index case both fail on the old global cache, which is exactly the regression.
Nits
- The cache key is the path, not the file's mtime/size: if a process rewrites
index.jsonafter a firststage_ofcall, the answer stays stale. None of the current callers do that (they are one-shot census/scan tools, and_translatereads it once), so this is a note for future reuse rather than a defect; a comment on the function saying "the index is assumed immutable for the process lifetime" would make the assumption explicit. normcaseonly folds case on Windows. macOS's default filesystem is case-insensitive too, so two case-different spellings of the same root create two cached copies here; harmless (an extra parse), and folding it would need more thannormcase.- The module-global
_STAGESreset in older tests (tests/test_bvh_shaders_stage.py:78,tests/test_exe_shaders_stage.py:87) still works because it is re-created as a dict; nothing to change.
Not run: the game corpus (needs a copy), and the census tools over multiple real roots, which is the case the fix targets - the new test reproduces it synthetically with four files.
python -I scripts/check_no_game_data.py on both changed files: clean.
No game files. AI-assisted.
|
#2154 | head c5c367a (merged cleanly with main 039870e) | Audited |
Claimed in the coordination issue as: SHADER-STAGE-CACHE-CROSS-ROOT (#1608 (comment))
What and why
rdna2spirv.stage_ofcached the first carveindex.jsonit read in process-global_STAGESand reused that one mapping for every later shader in the process. When one process translates listings from multiple carve roots, a shader in the second root can inherit the first root's stage, changing stage-dependent translation decisions. This is a concrete cross-shader mutable-state hazard in the area of jean-melikian's shard-only invalid-OpSelectreport.The process-local cache is kept, but is now keyed by the resolved
index.jsonpath. Existing tests that reset_STAGES = Noneremain compatible.Regression test
tests/test_rdna2spirv_stage_cache.pybuilds two synthetic roots with the same shader stem but different stages. Before the fix it failed with:After the fix the second root resolves to its own
csstage. It also checks that repeated lookups in one root still use the cache.Tested
Windows 11, Python 3.14, under the machine coordination lock:
python -m compileall -q tools/rdna2spirv.py tests/test_rdna2spirv_stage_cache.py— pass.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 tests, OK (1 skipped).No GPU or game data used. AI-assisted with Devin.
Consolidated follow-up
This branch now also contains the missing-index follow-up formerly opened as #2194: only successful
index.jsonreads are cached, so an index created later in the same process is probed again instead of being hidden by a cached empty table. The added regression covers missing-then-createdindex.json; the branch head is exactly the previously reviewed #2194 head (c5c367a2a).