Repository navigation
Conversation
With several memory windows every access is a switch between them. DXC inlines the accessors before it optimises, so a program gets one switch per access and its time grows much faster than their number. Compute programs with 100 accesses or more are now compiled with the accessors only declared and linked with them afterwards (IDxcLinker inlines them): 1600 accesses 36 s -> 4.4 s, the same DXIL size and GPU time. The generated HLSL is unchanged. XCL_LINK_MEM=0 turns it off; a program that cannot be linked is compiled whole.
8bca7cb to
328cf29
Compare
|
AMD run, as asked under "Not tested": RDNA3 Radeon RX 7800 XT (16 GB, native 64-lane waves,
|
|
Retail-pack measurement, as asked under "Not tested": about −15 % DXC time on a 1-in-100 sample, 0 errors. Machine: Ryzen 7 7800X3D (16 threads), 32 GB RAM, ~17 GB commit free, RTX 5070 Ti (driver 32.0.16.2114, 32-lane waves), Windows 11 26300, DXC 1.9.2602.17, release build. Measured at Method:
Not measured: the split wave64 form (the survey translates the native 64-lane form), the driver's pipeline time, DXC's peak memory, and the GPU tests on this card. No game material: timings and counts only. Measured with an AI assistant (Claude Code). |
|
Tested 328cf29 (main 956a476 + this PR) on an RTX 3090 (driver 616.92), Windows 11 26300, Ryzen 9 5950X. AI-assisted test report (Claude); tests run locally as stated; the diff was read in full before running. |
|
Independent Windows + RTX 5080 GPU verification of Build & Tests
Code check
(AI-assisted) |
|
AI-assisted review (Claude Code). Windows 11 (10.0.26200), Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74, 32-lane waves), Rust 1.99.0 MSVC, debug build. Synthetic programs only, no game files. Tested With the Windows SDK's DXC, the linked path never works. The README names the Windows SDK as the DXC source. The newest SDK, 10.0.26100, ships
DXC 1.8.2505 and 1.9.2602 (GitHub releases) accept it. Everyone who measured above used 1.9.2602.17, so nobody has run the SDK case yet. Suggestions:
Measured with DXC 1.9.2602.17. I used xcl-pso's synthetic E/F bench from #156 (a copy in my tree; translated compute programs, one creator, fresh seeds so the driver hasn't seen them). DXC time is with 2 compiles at a time. The driver column is the first
The DXC columns are from a CPU-only run with 4 programs. The driver run's own DXC times agree (C 2.9–3.0 → 1.6 s, D 4.7–4.9 → 2.0–2.1 s).
Related, and bigger than this PR on NVIDIA. The same
DXC 1.9 emits DXIL half the size or less, and the 5070 Ti's driver then compiles it 1.4–2.2× faster. DXC's own time goes up for a whole compile. Linking (this PR) takes that back for windowed programs. The driver times in #156's synthetic table were taken with the SDK DXC. Not tested:
|
|
A data point for the SDK-DXC boundary, measured on this machine (Ryzen 7 9800X3D, RTX 3060 Ti, Windows 11):
Suggests the version check / README note would be more precise as "DXC >= 1.8" rather than "SDK DXC fails": a 26100 SDK with 1.8.2502 passes the attribute probe here. |
|
A follow-up to the review above, on how this fits with #187 and on the driver's part for access-dense programs. With #187. The two merge with one conflict, in Driver time when accesses are dense. The review's shapes had a memory access every 8 rounds. With a load and a store every round (split wave64, 1000 rounds, an exec-masked block every 4 rounds, 2 never-seen programs per row):
So the PR does what it says for DXC, and on such programs the driver's part, which it leaves as it is, is the larger one by far. In your own bench with a heap form added (1600 accesses, 2 rounds): DXC 1.0 s (1 window) / 11.0 s (whole) / 1.6 s (linked) / 1.2 s (heap), and GPU time for 2048 groups 0.237 / 0.273 / 0.271 / 0.243 ms. Tested
Not tested
AI use: Claude Code, Claude Fable 5.2. |
…ong SDKs first Nobody running XCL could tell which dxcompiler.dll it had loaded, and it matters: with DXC 1.7.2308 (what Windows SDK 10.0.26100.4654 installs; other revisions of that SDK have 1.8.2502) the DXIL of translated compute programs was 2-2.7 times the size of DXC 1.9.2602's and an NVIDIA driver took 1.4-2.2 times as long to build pipelines from it (ivall#156); 1.7 also rejects [WaveSize] on library entries (ivall#174). - dxc.rs: after loading, dxcompiler.dll and dxil.dll are asked for IDxcVersionInfo and IDxcVersionInfo2 (commit), and their version resources are read. One info line with versions and folder; below 1.8 one warning with the measured cost and XCL_DXC_DIR. The release number is taken from the file: IDxcVersionInfo gives the DXIL version the library knows, and release 1.8.2505 answers 1.9. - report.json: `dxc` (folder, both libraries). Filled by the game process when it compiled something, else by the launcher from its checks. - xcl run's checks print the version, and a note with the fix when it is below 1.8. - Windows SDK folders are tried in the order of their DXC's version, then of the SDK's, compared as numbers (old SDKs' compilers carry their Windows build number and go last). XCL_DXC_DIR and the folder of xcl.exe come first as before. - README: DXC 1.8 or newer is recommended, and where to get it. Co-Authored-By: Claude <noreply@anthropic.com>
shdann
left a comment
There was a problem hiding this comment.
In dxc.rs:249–254, two different compute shaders can request the same accessor library at startup. Each thread can see an empty cache before either stores its result. Both then compile the same library. The result is correct, but the extra DXC work happens during the cold start this change aims to shorten. Consider storing a per-key initialization cell under the map lock, then compiling outside the map lock. Preserve retry after a compile failure. A test with two distinct programs sharing one library can count library compilations and check that both programs link. Static review of 328cf29 with OpenAI Codex (GPT-6); I did not measure the timing impact.
Lane L6 of the compile-time handoff (DXC cost). Draft. About −14 % DXC time on retail compute programs (measured below); the tests pass on AMD (RX 7800 XT, comment below). #187 removes the window switch itself (windows from the descriptor heap, VS / PS too, and much faster on its own synthetic CS). If it lands, this PR only matters where that one falls back to the switch (
XCL_HEAP_WINDOWS=0, a failed view); I would prefer it over this one.What is slow
With several memory windows every
memaccess is a call to an accessor that switches between the windows. DXC inlines it when it compiles, before it optimises, so a program gets one switch per access, and DXC's time grows much faster than their number. HANDOFF (956a476) measured it at about double DXC + driver time on one large CS; #172 measured about 26 % of DXC time on its 1-in-100 pack sample. The first table below is the worst case, programs made of memory accesses only; the second is real ones.Change
emit::linked_formturns such a program into two DXIL libraries: the program, with its accessors only declared, and the accessors. DXC cannot inline a declaration.dxc::compile_linkedcompiles both and links them withIDxcLinker, which inlines the accessors after the program was optimised. The compiled accessor library is kept.cs_*(which is also what MS and GS programs run as), only with 2–4 windows, only from 100 places that use an accessor. VS and PS are unchanged.XCL_LINK_MEM=0turns it off. It shares the DXIL cache, so compare with anotherXCL_DXIL_CACHE.The HLSL the translator emits is unchanged (the accessor text is byte-identical to
mainfor 2, 3 and 4 windows), so cache keys do not change: programs already in a DXIL cache stay as they were compiled.Measured, synthetic worst case
GTX 1650 (driver 32.0.16.2124, 32-lane waves), Ryzen 5 1600, 16 GB RAM, ~13.5 GB commit free, Windows 11 26300, DXC 1.9.2602.17, debug build.
bench_memory_window_accessors(ignored test, in this PR): synthetic split-wave64 CS, 3 rounds, the forms one after the other in every round, a different program each time so that the driver cannot answer from its cache. Medians:main)main)dispatch_timedgives).Measured on a retail pack
GTX 1650 machine above (16 GB RAM), release build, one binary,
XCL_LINK_MEM=0/1. Cold--precompile --only cs --limit 22300(143 compute programs, 4 windows, split wave64), 4 DXC threads, a new empty cache for every run, order off-on, on-off, off-on:XCL_LINK_MEM=0--pipelines, one at a time, in two runs). Driver time off / on was not compared.Tried and dropped
[noinline]accessors in the program itself: the same DXC gain and a smaller DXIL, but NVIDIA keeps them as calls and the dispatch is 4.5–6× slower. (DXC's validator also takes only scalars in such functions.)noinline.Checked
gpu_linked_memory_accessors: one program with 1–4 dword loads and stores, scalar loads, 32- and 64-bit atomics, in two windows, odd and even lanes in different ones. Registers and memory are the same whole and linked, and loads match what is in memory.linked_programs_keep_their_declarations: wave size (32 and 64), thread count, the windows' registers,globallycoherent(resource properties) and the number of functions are those of the whole program.cargo test --workspace: 538 lib tests pass, 0 fail, 2 SKIPPED (no wave64); other suites pass.cs_*program with windows is linked: 538 pass, 0 fail.Not tested
main. No AMD timings, and no retail program on AMD.Textually it conflicts with #172 only at the end of
tests.rs; the two are independent.Gate A passed at 2026-11-23 18:21 UTC on main 956a476; Gate B passed at 18:54 UTC on main 956a476. PRs read: #113, #123, #138, #139, #162, #166, #172: none changes how accessors are compiled. The tests use synthetic programs only; no game material is in this PR.