Repository navigation
d3d12: the translator's test modules are no part of the shader cache key (D3D12-SHADER-KEY-NO-TESTS) - #2777
Conversation
…key (D3D12-SHADER-KEY-NO-TESTS) leonida-shader's build script hashed every .rs file of the crate, its *_tests.rs modules included, into LEONIDA_SHADER_SOURCE_HASH, and since 0baa927 that hash is part of the shader cache key (translation_fingerprint). A pull request that only adds a translator test made every player and tester translate all shaders again at the next start and make their early pipelines again, which 69837e5 had ruled out for leonida-gpu's own fingerprint. The switch-name scan in the same script also put the switches only tests read (LEONIDA_DIFF_ONLY, LEONIDA_EMIT_DUMP, LEONIDA_CONSOLE_DXC, LEONIDA_PROBE) into the key. The build script now leaves *_tests.rs out of both. Each of those modules is declared under a cfg with test, so none changes what the translator emits. Three portable tests: the hash recomputed without the test modules equals the built one; test-only switches are out of the key and the translator's own are in; every `mod *_tests;` is test-only.
|
Verified by OreoFR (another owner than TheGeogeo) on macOS 27.2.1, Apple M5, Rust (rustup),
AI-assisted: Claude Code |
|
Independent check on Windows (not the author), at
Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, Rust 1.98.1 pinned. AI-assisted: yes (opencode). |
|
RUN (independent run on Windows, #2777 head aec6998, merged locally into main 6cdc0a0 with Commands, in
The key no longer follows the test modules. I checked this with a local probe (a test I added locally, not pushed) that prints the built source hash and the number of switches in the key:
The translator's output does not change: the same probe translates 74 synthetic programs (VOP3 opcodes 0x100-0x17F, three registers each; the ones the translator refuses are skipped, the same on both sides) and hashes each DXIL. 74 programs on main, 74 on the merge, 74 identical byte for byte. Not covered: the title's own programs. That needs game data. The code that emits them is unchanged; only No runtime/ C++ or Python in this PR, so no link or import check applies. |
|
RUN - VERIFY-2777-RTX4060 - by MoonEyes (another person than the author) on head
Limits: one card, the character standing still, a session that did not reach the open world. Values only, no game data. AI-assisted (Claude Code). |
|
Merging. Head AI-assisted (Claude Code). |
Claimed in the coordination issue as: D3D12-SHADER-KEY-NO-TESTS (#2570 (comment))
What and why
leonida-shader/build.rshashes the crate's.rsfiles intoLEONIDA_SHADER_SOURCE_HASH, test modules (*_tests.rs) included. Since 0baa927 that hash is part of the shader cache key (translation_fingerprint,emit/mod.rs;shader_cache.rs).The effect: a pull request that only adds or edits a translator test makes every player and tester translate all of the title's shaders again at their next start, and make their early pipelines again. That is several minutes on a 4060-class machine, for a translator that emits the same code. 69837e5 had left test modules out of
leonida-gpu's own fingerprint for exactly this reason (see the comment inleonida-gpu/build.rs); the source hash brought them back in.The switch-name scan in the same script has the same issue. Four names are read only by tests (
LEONIDA_DIFF_ONLY,LEONIDA_EMIT_DUMP,LEONIDA_CONSOLE_DXC,LEONIDA_PROBE), and their values reached the key at run time.This change makes the build script leave
*_tests.rsout of both the hash and the scan. Each of those modules is declared under acfgwithtest, so none can change what the translator emits. A new test guards that rule.What it does not change: a real translator change still retranslates everything once, as #2710 did. That is legitimate. The key changes once with this pull request too.
Tested
On Windows 11, from
d3d12\:leonida-shader/src/source_hash_tests.rs, declared#[cfg(test)](they also run off Windows):the_source_hash_leaves_the_test_modules_outrecomputes the hash without the test modules and compares it with the built value;switches_only_tests_read_are_no_part_of_the_keychecks that test-only switches are out of the key and that the translator's own (LEONIDA_GROUP_PACK,LEONIDA_MESH_COUNTS) are in;every_test_module_is_built_for_tests_onlychecks everymod *_tests;declaration.main'sbuild.rs, the first two fail: the hash differs, andLEONIDA_DIFF_ONLY is in the key's switches. With the change, all three pass. The third already holds onmain; it is the guard.cargo test -p leonida-shader --locked: 389 passed, 5 ignored.cargo test -p leonida-gpu --locked --lib shader_cache: 5 passed.cargo clippy -p leonida-shader --all-targets --locked: nothing in the changed lines.git diff --checkandcheck_no_game_data.pyare clean.leonida-shader(git merge-tree).GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 10.0.26300 (the leonida-shader suite).
AI-assisted: yes
Checklist
mainand merges cleanly.docs/design.md, with how it was confirmed. (Not applicable: the translator's output does not change.)