Repository navigation
Recompiler: direct DXIL cache entries change when its sources do - #1947
Conversation
The translated cache's identity covers the HLSL path's sources (XCL_TRANSLATOR_SOURCE_ID), but of gpu/dxil only TRANSLATOR_VERSION, which is bumped by hand. Two changes that bump it to the same number, or one that does not bump it (xcl-dev#1900), leave containers of the old translator in use. build.rs hashes every .rs file of gpu/dxil but the *tests.rs ones into XCL_DIRECT_DXIL_SOURCE_ID, which only the direct entries' identity includes (and the per-lane entries', which extend it). The HLSL path's entries keep theirs, as with bfb8133 for the per-lane sources. The directory is listed rather than named file by file, so that a new file is not left out. TRANSLATOR_VERSION stays, for changes of pso.rs's direct_compute / direct_graphics; edits of gpu/dxil no longer need it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-dev#1947) The translated cache's identity covers the HLSL path's sources (XCL_TRANSLATOR_SOURCE_ID), but of gpu/dxil only TRANSLATOR_VERSION, which is bumped by hand. Two changes that bump it to the same number, or one that does not bump it (xcl-dev#1900), leave containers of the old translator in use. build.rs hashes every .rs file of gpu/dxil but the *tests.rs ones into XCL_DIRECT_DXIL_SOURCE_ID, which only the direct entries' identity includes (and the per-lane entries', which extend it). The HLSL path's entries keep theirs, as with bfb8133 for the per-lane sources. The directory is listed rather than named file by file, so that a new file is not left out. TRANSLATOR_VERSION stays, for changes of pso.rs's direct_compute / direct_graphics; edits of gpu/dxil no longer need it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
RTX 3070 (Ampere, driver 616.56, Windows 11, debug) at A live example of the "bumps it to one already used" case: three open PRs each bump AI-assisted (Claude Code). |
|
CPU-only build-script validation on exact head Tested
Not tested AI use |
|
Tested Clean PR head cargo test --locked -p xcl --lib -j 2 -- --nocapture --test-threads=2 translated_identity_tracks_sources_and_dxc translated_namespace_tracks_every_request_input translations_on_disk_need_the_same_bytes_and_identity translated_v2_ignores_valid_entries_outside_its_namespace direct_dxil_identity_never_collides_with_hlsl direct_dxil_identity_tracks_its_sources direct_and_hlsl_disk_entries_are_separate7 passed, 0 failed, 0 ignored, 0 skipped (946 filtered out). This exercised source and backend identities, cache hits and misses across namespaces and rejection of truncated entries. I also ran Not tested Full workspace suite, release build, DXC or shader execution on the GPU, retail-title cache reuse or smoke runs. AI use Codex ( |
…n the GPU Two loop shapes (two returns to one head; a nested loop with returns to either head), wave32 and split wave64, against HLSL + DXC and explicit expected values. The test of anes66's companion commit b780cdd, taken without its cache-version bump, which xcl-dev#1947 makes unnecessary.
Track each memory write's pointer, value, and control block when computing input-to-output dependencies for dx.viewIdState and PSV0. Preserve the fixed-point traversal merged in xcl-dev#1966. The direct-DXIL source hash from xcl-dev#1947 accounts for the changed output without a manual version bump. Refs xcl-dev#1892
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
`Module::optimize` replaces a phi only when it is trivial on its own
(every incoming value the phi itself or one other value). A loop whose
body sets a register back to the value it had before the loop (a copy,
a constant, or two copies of one expression that CSE merges) leaves a
cycle of phis that name each other plus that one value: the loop
header's phi takes the value and the join's phi, the join's phi takes
the header's phi and the value. Neither is trivial alone, so both were
written, with their uses.
Remove such groups as Braun et al. ("Simple and Efficient Construction
of Static Single Assignment Form", CC 2013) do: Tarjan's strongly
connected components over the phi operand graph, operands first; a
component whose operands outside it are all one value becomes that
value; a component with several outside values is a real merge, and
the phis in it that name only its members are searched again for such
a group. The step runs after the trivial phis (so CSE sees the
replacements) and once more after CSE (groups whose definitions CSE
merged). `XCL_DXIL_NO_OPT=scc` skips it. No TRANSLATOR_VERSION change:
the translation cache's identity includes a hash of the `gpu/dxil`
sources (xcl-dev#1947).
Tests build the IR by hand: a redundant two-phi loop cycle, the same
loop with a real second value (kept), a redundant inner group inside a
real outer merge, and a cycle that is redundant only after CSE.
…n the GPU Two loop shapes (two returns to one head; a nested loop with returns to either head), wave32 and split wave64, against HLSL + DXC and explicit expected values. The test of anes66's companion commit b780cdd, taken without its cache-version bump, which xcl-dev#1947 makes unnecessary.
…n the GPU Two loop shapes (two returns to one head; a nested loop with returns to either head), wave32 and split wave64, against HLSL + DXC and explicit expected values. The test of anes66's companion commit b780cdd, taken without its cache-version bump, which xcl-dev#1947 makes unnecessary.
…n the GPU Two loop shapes (two returns to one head; a nested loop with returns to either head), wave32 and split wave64, against HLSL + DXC and explicit expected values. The test of anes66's companion commit b780cdd, taken without its cache-version bump, which xcl-dev#1947 makes unnecessary.
The on-disk translated cache is keyed by the HLSL path's sources (
XCL_TRANSLATOR_SOURCE_ID), but ofgpu/dxilonly byTRANSLATOR_VERSION, which is bumped by hand. Unless something merged with it changes the HLSL path's sources, agpu/dxilchange that doesn't bump the number, or bumps it to one already used, leaves the old translator's containers in use underXCL_DIRECT_DXIL.mainhas such a case now: #1900 (20cf130) puts the MSAAtextureLoadbeforegetDimensions, because AMD's driver compiler crashes on the other order, and doesn't bump it. For a program with an MSAA image load, a direct cache written at 689f2db still gives the old order at 20cf130 (see Tested).This does for the direct path what bfb8133 (#1745) did for the per-lane sources, by listing the directory. MatyEjsr noted the gap on #1714 and IgorAntunes66 on #1741.
Related to #1269: it asks for shaders compiled directly into DXIL, and a direct-translator change tested over an existing cache can run and measure the old containers. If
goal:world-loadfits, please set it.What is in it
build.rs: hashes every.rsfile ofgpu/dxilbut the test files (*tests.rs) intoXCL_DIRECT_DXIL_SOURCE_ID. Tests inside the other files are hashed with them. A new file (Direct DXIL: make multi-wave Compute and Mesh s_barrier early-exit-safe #1793 adds one) is not left out.recomp/pso.rs: that hash is part of the direct entries' identity only (and the per-lane entries', which extend it). HLSL-path entries keep theirs. A unit test.dxil/kernel.rs: the comment ofTRANSLATOR_VERSION. The constant stays, for changes inpso.rs.Cost
gpu/dxiledit, even a comment, makes the next run withXCL_DIRECT_DXILtranslate again (programs that fall back to HLSL still hit the DXC cache).gpu/dxiledit would re-key those entries too. imnicho raised that on Recompiler: route huge compute programs through the direct DXIL translator #1809 for the hand bumps, and it now tags compute entries only. This PR makes it happen on every edit rather than on every bump.Tested
cargo test --workspace --locked --no-fail-fast -- --test-threads=4at1831ec4a: 977 passed, 0 failed, 45 ignored (22 SKIPPED lines: 18 no wave64, 3 wave32 per-lane forms refused, 1 no heap windows)direct_dxil_identity_tracks_its_sourcesfails with the source left out ofdirect_versionand passes with it (cargo test -p xcl --lib shader_cache_tests: 13 passed, 1 failed / 14 passed; this diff on 689f2db)IMAGE_LOADprogram, throughtranslated::cachedwithXCL_DIRECT_DXIL=1, builds run one after the other over one cache directory:main: written at 689f2db; at 20cf130 the 689f2db container is served (getDimensionsbeforetextureLoad), while a fresh translation there hastextureLoadfirst1831ec4ait is translated again (textureLoadfirst), and a rerun is a hitdxil/module/opt.rsor adding a file changes onlyXCL_DIRECT_DXIL_SOURCE_ID; editingdxil/ops_tests.rschanges noneRegression run
main:
PR:
(the second of two pairs, run main, PR, main, PR; the first: main 1477 frames, peak 21803 MB; PR 1478 frames, 22433 MB; no removal or crash in either. Release builds.)
Not tested
identity()passes the hash on is covered only by the scratch test, not by the unit testdirect_compute/direct_graphicsinpso.rsstay outside the hash, as before: bumpTRANSLATOR_VERSIONfor those (Shaders: guard wave64 graphics direct DXIL #1913 changesdirect_graphicswithout one; it also edits hashed sources, which changes the identity anyway)Overlaps (open PRs, merged in a scratch tree with this PR and with
main62265d3, 2026-11-24 23:45Z):TRANSLATOR_VERSION: Recompiler: direct DXIL asks for flushed f32 denormals #1707 and Recompiler: simplify direct DXIL typed-buffer component decoding #1739 bump 6 to 7, whichmainalready has; Recompiler: v_pack_b32_f16 applies the abs and neg half modifiers #1720, Recompiler: round direct-DXIL f16 converts and products to nearest-even #1742, Direct DXIL: make multi-wave Compute and Mesh s_barrier early-exit-safe #1793, Recompiler: direct DXIL rolls and shares BVH box32/box16 loop #1800, Recompiler: direct DXIL folds all-ones EXEC and skips dead VGPR reads #1801, dxil: fold constant CFG terminators after CSE #1818, dxil: collapse forward s_cbranch_execz regions and make read-only loads branchless #1834, Recompiler: fold 64-bit ints, bitcast selects and commutative CSE in direct DXIL #1906, Direct DXIL: MSAA loads clamp out-of-range sample indices before loading #1908, Recompiler: LDS ds_sub_u32 hides its negation from the driver (RTX 50 refuses it) #1919, Recompiler: direct DXIL folds 64-bit and float constants #1923, Recompiler: direct DXIL drops phi groups that pass one value around #1938, dxil: keep the LOD clamp of image_sample_*_cl on cubes #1939 and dxil: image_sample_o under implicit LOD offsets each mip by its texels #1940 all bump 7 to 8 (Recompiler: v_pack_b32_f16 applies the abs and neg half modifiers #1720 and Recompiler: LDS ds_sub_u32 hides its negation from the driver (RTX 50 refuses it) #1919 also changeemit.rs, which is hashed). All sixteen merge cleanly with this PR; for theirgpu/dxilchanges the bump becomes optional. Shaders: infer double extensions from emitted instructions #1544, Shaders: reuse the predicate when reading a zero-extended SCC #1546, Recompiler: direct DXIL vectorizes multi-dword loads and window switch #1699, Direct DXIL: enforce byte-buffer bounds across memory windows #1737 and Recompiler: emit globallycoherent on compute memory windows only when needed #1850 bump it too and conflict withmainalready.gpu/dxil.pso.rs: Recompiler: route huge compute programs through the direct DXIL translator #1809 conflicts (its direct entries needdirect_version(..)too). Shaders: cache refused shaders and DXC failures by capability (#1412) #1472 callsidentity_within its tests and merges cleanly.build.rs: Shaders: console containers are walked without decoding instructions #1082, Recompiler: route compute programs through a compact backend (XCL_COMPACT_CS) #1316, Shaders: XCL_SAFE_BARRIER turns the translation caches off (#1409) #1413, Recompiler: compact cases share code whose branch targets differ #1448, Recompiler: share scalar operands in compact compute cases #1548 and Recompiler: compact dispatch can switch in two levels (XCL_COMPACT_NEST) #1692 merge cleanly; Recompiler: pre-emission RDNA2 optimizer, dominator SMEM hoisting, and lane-local mask scalarization #1630 conflicts withmainalready.XCL_DXIL_NO_OPT).AI use
🤖 Generated with Claude Code