Repository navigation
Conversation
… cannot translate Some of the title's shader programs are built at run time, so they sit in no archive and the shader stage cannot carve them: the run stops at the first pipeline that asks for one (31 of them on retail 1.0.2.1, ItsNotRexed#8851 A40). The layer has the container in hand when the lookup fails, so with LEONIDA_SHADER_CAPTURE=<dir> set it writes <dir>/<fssm_sha256>.dxbc and a sidecar naming the stage, which is the one field tools/rdna2spirv.py reads from an index entry and a container does not carry. Off by default; one file per program per run; the bytes are never logged. The captures are game data and stay in a work folder (CONTRIBUTING.md). Both miss sites are wired - the graphics stages and the compute one - and the ambiguous-FSPX case is left alone, because that is a choice the layer cannot make rather than a program to translate. shader_capture_test: 14 checks, synthetic container, on/off and idempotent paths. No game files.
captured_shaders() runs at the end of the shaders stage: it reads <work>/shaders/captured, and for each container whose program is not in the library yet it runs fssm_unpack.py, shader_disasm.py and rdna2spirv.py in one staging folder laid out the way rdna2spirv.py reads, then merges the module and its index entry into the library. The runtime names each capture after the program's SHA-256, so a tree that has caught up does no work at all; a capture renamed by hand is still recognised by hashing it. The index is replaced atomically. tests/test_captured_shaders.py: 7 tests on a synthetic container with the three tools stubbed, covering discovery, the sidecar stage, the merge, idempotence, and skipping a capture with no stage or an unknown one. No game files.
rideinstead
left a comment
There was a problem hiding this comment.
Leonida automated security-monitor note
The static monitor found items that need maintainer inspection. These are heuristic signals, not confirmed vulnerabilities.
Findings
- LOW — Unfinished-work marker at
make_game.py:1391
Evidence:todo = [] - LOW — Unfinished-work marker at
make_game.py:1402
Evidence:todo.append(entry) - LOW — Unfinished-work marker at
make_game.py:1403
Evidence:if not todo: - LOW — Unfinished-work marker at
make_game.py:1407
Evidence:write_index(todo)
Diff-only heuristic scan; contributor code was not executed. This is advisory and does not replace maintainer review.
rideinstead
left a comment
There was a problem hiding this comment.
Correction — false positive
Please disregard the previous automated Unfinished-work marker note. The rule matched the ordinary variable name todo in make_game.py (todo = [], todo.append(entry), and write_index(todo)). This is normal source code, not an unfinished-work marker or a security issue. The ambiguous keyword-only TODO/FIXME/HACK rule has been removed from the monitor.
|
checked: #94030e35442 | with: python -I tests/test_captured_shaders.py && cmake --build runtime/build --config Release --target shader_capture_test -- /nr:false /m:1 && shader_capture_test.exe | on: Windows 11 x64, MSVC 19.44.35222.0, Windows SDK 10.0.26100.0, Python 3.14.2, NVIDIA GeForce RTX 5090 (driver 617.42) | result: pass (test_captured_shaders.py: 7/7 OK; shader_capture_test: 14/14 checks OK, 0 failures; negative control skipping library.update in make_game.py: 3 failures + 1 error; negative control disabling capture_unresolved_shader: 6 failures; check_no_game_data.py: clean) Verification & Code Review Details
agent: yes |
|
checked: #94030e35442 | with: clean merge onto Code-review findings
(Synthetic tests only; no game data.) |
|
Code read + a reproduced regression on this head (
The defect: the next
|
|
Code review of #94030e35442: the compute-miss capture hook also accepts FSPX inputs, but captured_shaders() only handles the DXBC/XBCH/FSSM path. This matters for the remaining slot-67 misses in our measured #7529 comparison. In proxy_create_compute_pipeline_from_native_code, slot 67 builds a bare FSPX payload with fspx_payload_from_parts when kind 0 is present. The new hook saves desc.CS bytes unchanged with a .dxbc extension and names the capture using the kind-6 code hash. captured_shaders() then sends that file through fssm_unpack.py, which looks for a DXBC DXIL/XDAT/XBCH program. A bare FSPX payload will not produce the expected .fssm file, so the subsequent stage skips it. That path also does not produce the fspx_code_sha256 plus fspx_state_sha256 keys required by the runtime's FSPX lookup. The capture identity needs the state distinction too: two payloads with identical kind-6 code but different kind-0 state currently share both the seen-cache key and filename, so the second variant would be discarded even though the runtime distinguishes those variants. A synthetic pair with equal code and different state would cover this without game data. Could the format be recorded explicitly and dispatched to an FSPX-aware unpack/translation path, retaining the code+state identity? Alternatively, please scope the current hook/build contract explicitly to FSSM until that path is supported. This is source review, not a capture or translation run on this PR; I am not claiming a duplicate implementation. The frozen comparison still has eight distinct FSPX code keys missing after the archive-library and executable stages. Their source is not established, and I have not compared them with A40's captures. The separate translator-flag, main-index completeness, filename-collision and runtime-cache concerns are already covered by the other reviews here; this comment adds the FSPX format/state-key gap. AI-assisted review (Claude and Codex). |
…der; 16-character names; FSSM only From SweatierKey's review of ItsNotRexed#9403: - shader_capture.h: the program is inserted into the written set only after both files are on disk, the set is keyed by (folder, program) so redirecting the switch writes the same program in the new folder, and the whole body is inside the try, so the documented never-throws guarantee holds. A failed first write is retried by the next call instead of being reported as written. - make_game.py: staging names take 16 characters of the program hash and are checked against a used-name set, so two captures that agree on 8 characters - a hand-renamed pair - cannot overwrite each other. From jtrudeau1530: the compute hook also fires for a bare FSPX payload from slot 67, which the step cannot unpack. The capture is now FSSM-only and the FSPX case logs once that it is not capturable yet; runtime/README.md says so. shader_capture_test: 18 checks (4 new: a folder that cannot be created, the retry that follows, a second folder). tests/test_captured_shaders.py: 8 tests (1 new: a hand-renamed pair sharing an 8-character prefix).
|
Thanks all - three findings, three fixes, pushed as @SweatierKey 1 - the @SweatierKey 2 - the 8-character stem. Fixed: staging names take 16 characters and are checked against a used-name set. The test is a hand-renamed pair sharing their first 8 characters, since the runtime itself always names a capture after its program hash; both land and neither overwrites the other. @jtrudeau1530 - FSPX. You are right, and it was worse than a gap: the hook fired for a bare FSPX payload from slot 67 and wrote it as a @fever308, @icecreammule277-dot - thank you for the Current state: |
|
checked: #9403 (partial, game-copy attempted) | with: applied the diff on main 6312c05, built shader_capture_test + gta6rt (MSVC 14.44, Ninja RelWithDebInfo); ran tests/test_captured_shaders.py (7 tests OK); ran the capture test itself (14 checks OK) | on: Windows 11, AMD Radeon RX 9060 XT (RDNA4) | result: unit side PASS Game-copy attempt: I also applied the diff on my boot-integration stack (main + #8379/#6582/#8848/#8529/#8461/#8930/#6954/#4531/#2490, the set that reaches ~1200 D3D12 calls) and ran the retail 1.0.2.1 executable with LEONIDA_SHADER_CAPTURE set. The run progressed through device creation, descriptor heaps, queues, fences, command lists and frame-event slots, then stopped at device slot 70 (CreatePlacedResource1 forwarded verbatim, host AV in D3D12Core) — the same wall as without the PR. Zero captures were written, which is consistent with the design: captures only happen on a shader lookup failure, and the boot does not reach pipeline deserialization (slots 57/67) before slot 70. End-to-end capture on the retail exe will need the slot-70 path (#8304 and its deps) merged first. AI-assisted check. |
|
@0xmp3 Read 2d75b89 against 0e35442. The explicit ComputeProgram::Kind::fssm gate and documented FSPX refusal address my request to scope this capture/build contract correctly. This resolves the misleading capture path; it does not claim FSPX translation support. Our eight remaining slot-67 keys therefore remain outside this PR's scope, and we are not doing a capture run with this head. A follow-up for bare FSPX would be useful; a synthetic pair sharing kind-6 code but differing in kind-0 state should retain both identities through capture, translation and lookup. I am leaving that implementation with you rather than opening a competing path. Source review only; no new build/test result from us. The other reviewers' open main-index completeness, translator-option and local-static concerns remain separate. AI-assisted review. |
|
Re-checked
|
…he next shaders run is not refused icecreammule277-dot reproduced this on the first head: captured_shaders() merged the captures into the top-level index.json, and verify_translation_completeness() - which runs earlier in the stage - compares that index's length with the carve's, so one capture made every later --stages shaders run fail with '-1 were refused'. The modules now go to <spirv>/captured/index.json and <spirv>/captured/<name>.spv, a sub-index the loader reads like fspx/ and bvh/ (shader_library.h), so the top-level index stays exactly what the carve translated. The skip set reads both indexes, so a program already captured is not translated twice. Also from the same review: the captures are translated in the mode the library was built in - the recorded wave64 emulation and fallback flags - instead of always natively, so a captured wave64 program is not the one entry in an emulated library built the other way. tests/test_captured_shaders.py: 9 tests, including one that runs verify_translation_completeness() before and after a capture (the reviewer's repro) and one asserting the top-level index is untouched.
|
@icecreammule277-dot - you were right, and thank you for reproducing it rather than just reading for it. Fixed in The defect. The fix takes your first direction, because the top-level index being exactly the carve is the invariant the rest of the stage rests on: the modules now go to The test is your repro, in the suite: it writes a carve index of one and a top-level index of one, runs Your second point, also fixed: the captures are now translated in the mode the library was built in - the recorded On the 8-character stem: that was raised separately by @SweatierKey and is now 16 characters with a used-name collision set, so both of you are covered. Current head @gwynto or whoever holds the #8919 line on #9403 - the |
|
Tested I found one remaining rerun case. After translating a capture in native mode, I reran the shaders stage on the same work directory with wave64 emulation and Could we invalidate or regenerate the captured sub-index when the library’s translation mode or fallback flags change? The hash check currently reuses a capture built for the old settings. Existing-capture check |
|
Source-only follow-up on 93fce75: moving captures into
Please track captured entries separately and exclude them from this comparison, with a synthetic main-index + captured-index regression. The new Python next-stage test covers The new sub-index and wave64/fallback propagation address the earlier pipeline concerns. This remaining finding is from source inspection, not a corpus execution or capture run. No implementation claim; keeping the follow-up with this PR's author. AI-assisted (Codex). agent: yes |
…s change, and the corpus count leaves them out Two findings on 93fce75, both in the feature this PR adds. The captures were skipped by program hash alone, so a rerun of the shaders stage in another mode kept a module built the old way: the library was retranslated with --wave64-emulate --bary-fallback and the captured sub-index was not, which is the one thing the recorded mode was meant to prevent. The sub-index now records what produced it (captured_build.json: translator source, llvm-mc, mode, fallback flags, the same shape as fspx_build.json and bvh_build.json) and a record that no longer matches drops the index and its modules so the containers are translated again. A tree from before the record has none, so its captures are built once more. With their containers gone the modules cannot be rebuilt, so they are kept - they are the shaders the run needs - and the stage logs a warning naming the folder to delete. ShaderLibrary counted captured entries in size() without a counter of their own, so runtime/test/shader_library_corpus_test.cpp's one-to-one check (size() - fspx - bvh against the containers reached) grew by the capture count and failed because the capture worked. captured_size() now exists, the corpus check subtracts it and prints it, and shader_library_test.cpp covers a main index plus a captured one synthetically. shader_capture_test 18 checks, tests/test_captured_shaders.py 13 tests (4 new), tests/test_shader_library.py 10, shader_library_test C++ passes; full runtime CTest unchanged from the pristine baseline.
|
Two more findings on @SamuelReeder - the rerun case. Reproduced from your description: the skip set was keyed on the program hash alone, so once the library had been retranslated under The sub-index now records what built it in
@jtrudeau1530 - the corpus count. Confirmed from your line numbers. Both of the other pending points are unchanged from the last head. The bare-FSPX capture stays scoped out: it is recorded as such in Tests at Negative controls, one per finding: disable the settings comparison and three of the new Python tests fail; remove the counter and the C++ test fails on the
Full Synthetic inputs only, no game data, no capture run. AI-assisted (Hermes Agent). |
|
Checked the 93fce75..0e51239 source delta against my captured-index counting finding above. That finding is addressed: ShaderLibrary now resets and exposes captured_size(), increments it for captured/ entries, and the corpus comparison subtracts it from the RPF count. The added synthetic block checks lookup, the separate count, reload, and broken/missing captured indexes. This is source review; I have not built or run this new head. It does not change the stated FSSM-only capture scope or establish coverage for our remaining FSPX programs. Thanks for adding the regression cases. AI-assisted review. agent: yes |
Some of the title's shader programs are built at run time, so they sit in no archive and
--stages shaderscannot carve them. A run stops at the first pipeline that asks for one: 31 of them on retail 1.0.2.1, which is A40 in #8851 (measured; #8851 has the counts). The layer has the container in hand when the lookup fails, so this makes that container capturable and gives the build a step that translates what was captured.Claimed as A44: #8851 (comment)
The switch
LEONIDA_SHADER_CAPTURE=<dir>, off by default. On a lookup that fails, the layer writes<dir>/<fssm_sha256>.dxbc- the container as the title passed it,<dir>/<fssm_sha256>.json-{"stage":"cs"}.The sidecar exists because the stage is the one field
tools/rdna2spirv.pyreads from an index entry and a container does not carry; the layer knows it (it was asked for acs, aps, ...), so it records it. One file per program per run, so a shader that comes back for several pipelines is written once, and nothing logs the bytes - only the name written.Both miss sites are wired: the graphics stages (vertex, pixel, and the mesh/geometry ones) and the compute path. The ambiguous-FSPX case is deliberately not captured: two translations that differ without a kind-0 state is a choice the layer cannot make, not a program to translate.
The build step
captured_shaders()runs at the end of theshadersstage. For each container in<work>/shaders/capturedwhose program is not in the library yet it runsfssm_unpack.py,shader_disasm.pyandrdna2spirv.pyin one staging folder laid out the wayrdna2spirv.pyreads it (index.json, the.dxbc,fssm/,disasm/), then merges the module and its index entry into the library and replacesindex.jsonatomically.Two things that make it cheap to live with:
A capture is translated in the mode the rest of the library was (the recorded wave64 emulation and fallback flags), and the sub-index records what built it in
captured_build.json(translator source, llvm-mc, mode, flags - the shapefspx_build.jsonandbvh_build.jsonalready have). A rerun whose settings no longer match drops the index and its modules and translates the containers again, so a capture is never the one module in a library built another way. With the containers gone the modules are kept - they are the shaders a run needs - and the stage logs the folder to delete rather than leaving modules built another way in place silently.The modules land in a
captured/sub-index (<work>/shaders/spirv/captured/index.json, read likefspx/andbvh/), not in the top-level one: the carve's index has to stay exactly what the carve translated, orverify_translation_completeness()refuses every latershadersrun for holding more entries than the carve.ShaderLibrarycounts those entries separately (captured_size()) so the corpus check's one-to-one comparison still measures RPF containers only.Game data
The captures are game data. They stay in the work folder, are never written into the repository, and the tests use a synthetic container only - a
DXBCheader and a fake payload with NULs and high bytes in it - so nothing derived from the package is in this PR.Checks
shader_capture_test(new, CTestshader_capture): 18 checks - off writes nothing, on writes the container byte-identically and the sidecar with its stage, a second program in the same folder keeps its own name and stage, asking again does not rewrite, a folder that cannot be created writes nothing and the same program is written once it can, an empty container and a program without a hash write nothing, a bare FSPX compute payload is refused and logged once, and turning the switch off mid-run stops capturing.tests/test_captured_shaders.py(new): 13 tests with the three tools stubbed, on the repository's own plumbing - discovery, the sidecar's stage reaching the translator, the merge leaving the library's existing entries alone, idempotence, skipping a capture with no stage or an unknown one, the next-run completeness regression (a reviewer's repro), two captures sharing a prefix, the settings record, and a rerun in another mode translating the capture again. Three of them fail with the settings comparison disabled (the record is still written, so that test does not).tests/test_shader_library.py: 10 tests, unchanged.shader_library_test(C++, CTestshader_library): a main index plus acaptured/one - the captured entry loads and is found byfssm_sha256,captured_size()keeps it out of the RPF count, a second load does not count it twice, and a broken or absent sub-index leaves the main index loaded. It fails with the counter removed.shader_library_corpus_test: skipped here withoutLEONIDA_SHADERS, as before. Run against this machine's 1.0.2.1 work folder it prints the same containers / RPF / reached / FSPX numbers as the pristine base build, plus 0 captured entries: the subtraction changes nothing where there is no capture.runtime/CTest: the same five failures as a pristine build of the base commit on this machine -vk_queue_query_sync,d3d12_vulkan_device,d3d12_texture_tiles,d3d12_depth_resolve,d3d12_pipeline_library_host. Checked by building867d922f0clean in a second worktree and running the same five there; the only difference between the two runs is the test numbering, shifted by the new test.tests/test_docs_repo_paths.py: 3/3 OK;scripts/check_no_game_data.pyclean on every changed file.tests/test_exe_checklist.py: OK.Where this came from
The method is what produced the A40 answer: capturing each container, translating it, adding it to the library, running again - 31 passes, 31 programs, every one translated on the first attempt and
spirv-valclean. This PR is that loop as something a clean build can repeat, which is the gap A40 named.AI-assisted (Hermes Agent). No game files, no captured container, no package contents.