Repository navigation
Conversation
|
Results wanted: cold preparation with literal lifting on and off Some compute programs in a pack differ only in numeric constants. This PR lifts those constants so a family compiles once (DXC and driver). On a retail game, RTX 2070 SUPER: 13 repeat driver compiles = 253 s of 1,327 s driver time in one cold run (19 %); pack-wide 156 extra compiles of 2,682 compute programs (5.8 %). Gain still unmeasured with the switch on: we need cold numbers from other hardware.
Written by Claude Code, Claude Opus 5.5. |
|
Cold full preparation, Two cold runs of full shader preparation (
Lifting was active in B:
Limits
Setup
Measured and written with Claude Code (Claude Opus 5.5). |
|
Current-main audit (2026-11-29): discard as an experiment, not a merge candidate. The PR's own cold full-preparation comparison is decisive: it produced 113 fewer blobs around the same point but saved no wall time (54.4 vs 56.1 min for translation/DXC, and the driver tail remained effectively unchanged). The change is 679 additions across nine files, adds per-PSO runtime metadata/ABI uploads and a custom HLSL scanner, and current That complexity is not justified by the measured result. Keep the analysis/data, but close the implementation unless a narrowly targeted gameplay-critical family demonstrates a reproducible critical-path win. Cache impact: not safe for affected cached PSOs; it intentionally rewrites HLSL/DXIL and shares a different driver blob. Review assisted by Codex; exact model name was not exposed in this session. No additional cold run was performed. |
…ALS) A title's pack has compute programs that are one program with different numeric constants. Their HLSL differs only in those literals, so DXC and the driver compile each again. In a cold run of a retail game on an RTX 2070 SUPER, 13 such repeat driver compiles took 253 s of the 1,327 s spent in the driver (19 %). Pack-wide: 127 families, 312 programs, 156 extra compiles out of 2,682 compute programs (5.8 %), e.g. records b162ea7db32e1657 / 0ed9e58ef6dc9cdb (462 KB of DXIL each). With XCL_LIFT_LITERALS=1, preparation (`xcl shaders --precompile` and launch preparation) finds the families. Programs with the same instruction sequence are translated, and those whose HLSL is the same once literals are masked form a family. Only the literal positions that differ inside a family are lifted: plain `u` integer literals in main's body, never attributes, declarations, control flow, `[]` or texture offsets. A lifted literal reads the same uint from io after the SGPRs (lift::IO_LIFTED), so the program computes the same thing. Each member's lifted text is one text without comments, so the DXC cache (by text) and the driver blob cache (by DXIL) share it. A pipeline keeps its values, and both compute dispatch paths (bind.rs, console_list.rs) write them after the SGPRs. The table is kept next to the caches under the translation cache identity. A family member skips the translated disk cache, which keeps no lifted values. If DXC refuses a lifted text, the program compiles as it is. Off by default until cold-run numbers show the gain and no frame-time cost (a lifted literal is a uniform io load instead of a folded constant). Related: xcl-dev#2711 (identical split pieces share a container), xcl-dev#2088. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1d3b1cb to
c0a0ec0
Compare
|
Review (head c0a0ec0, diff read, not a merge-check; draft, conflicts with main,
Fine: the design holds. Only differing AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
No open or merged PR lifts differing literals of a compute family. #2711 (named in the description) shares identical split pieces only. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Compute programs in a title's pack that are one program with different numeric constants get their literals that differ lifted into
io, so the whole family compiles to one HLSL text, one DXC result and one driver blob. BehindXCL_LIFT_LITERALS=1(off by default) until cold-run numbers are in. Related: #2711 (identical split pieces share a container, does not fold literal variants), #2088.Why: in a cold run of a retail game (RTX 2070 SUPER), 13 repeat driver compiles of literal-only variants took 253 s of the 1,327 s spent in the driver (19 %). Pack-wide, 127 families (312 programs) make 156 extra compiles of 2,682 compute programs (5.8 %). Example: records
b162ea7db32e1657/0ed9e58ef6dc9cdb, 462 KB of DXIL each, compiled twice. All 21 same-size repeats in that run took the HLSL path, which is where this works.How:
xcl shaders --precompile, launch preparation) finds the families. Programs with the same instruction sequence are translated, and those whose HLSL is equal once every literal is masked form a family.uinteger literals inmain's body only. Never attributes, declarations, control-flow or preprocessor lines,[], texture offsets or quad operations. A family with a differing literal anywhere else is left alone.uint xcl_liftN = io.Load(512 + 4N), the same 32-bit value as auint, so the program computes the same thing. Lifting is correct for any program; the family only decides what is worth lifting.What is in it
crates/xcl/src/gpu/recomp/lift.rs: scanner, masked hash, family positions, rewrite, family key, table (built at preparation, kept next to the caches under the translation-cache identity), unit tests, and anXCL_SAMPLE_LIFT_HLSLtest over exported HLSL.crates/xcl/src/gpu/recomp/pso.rs:Compiled::lifted. The HLSL path compiles a family member lifted. A member skips the translated disk cache, which keeps no lifted values.crates/xcl/src/hle/d3d12x/real.rs,bind.rs,console_list.rs: per-pipeline values, written after the SGPRs by both compute dispatch paths.crates/xcl/src/shaders.rs: precompile builds the family table first when enabled, with a log line.crates/xcl/src/gpu/recomp/tests.rs+runner.rs: GPU test. Two programs differing only in literals give one lifted text and one DXIL container, and each gives the same output as its plain translation.runner::dispatchkeeps io words past the SGPRs.Size: ~450 changed lines outside tests (679 with them). One PR because the parts only do something together: the table without the dispatch writes would produce programs that read zeros, and the dispatch writes without the table never run.
Tested
cargo test -p xcl --lib recomp::lift::tests: 7 passed, 0 failed, 0 ignored.XCL_SAMPLE_LIFT_HLSL=<export of the retail game's compute HLSL> cargo test -p xcl --lib sample_families_compile_lifted: 34 liftable families among the programs under 256 KB. The 12 smallest were compiled with DXC 1.9.2609, and each family's members gave one identical DXIL container.cargo build --workspace --tests && cargo test --workspace --no-fail-fast -- --test-threads=4on c0a0ec0 (debug; rebased onto main 81bfbf0, run at the same time as the suites of Recompiler: lift literals that differ inside a family (XCL_LIFT_LITERALS) #3262, D3D12.X: port @Saksukella's write-watch changes #2754 and #2891 to main #3242 and Recompiler: the DXIL cache key leaves out comments and indentation #3241): 2741 passed, 4 failed, 49 ignored, includinggpu_lifted_literal_family_shares_dxil_and_keeps_results(ok)e2etarget, whose test title had not been built (missing …xcl_testtitle.exe – build first: cargo build --workspace)cargo build --workspace:cargo test -p xcl --test e2e: 5 passed, 0 failedSKIPPEDon this adapter (28): 22 no wave64, 3 f16 instructions refused (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's), 2 no heap windows (opt-inXCL_HEAP_WINDOWS=1), 1 no GPU_UPLOAD heapsRegression run
main (fa20459):
this PR's head (1d3b1cb):
Both:
scripts/smoke.ps1 -Seconds 60,XCL_PREPARE=0,XCL_PRESS_AT=25:A, run through the local exclusive queue.XCL_LIFT_LITERALSis unset (off), so the lifting path is not exercised here.These runs are on the head before the rebase (1d3b1cb); they have not been repeated on c0a0ec0.
Not tested
XCL_LIFT_LITERALS=1(preparation time, driver compiles): numbers requested from contributors in a comment below.AI use
🤖 Generated with Claude Code