Faster shader compiles: one window switch per four dwords, every core, --precompile builds the cache titles use #113
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!113
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/113/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Foniass on GitHub · 2026-11-23 12:34 UTC · original
Foniass:t3/faster-shader-compile→main· +226 −54 · 5 files · 3 commits · merged 2026-11-23 12:51 UTCShader compile time. A title's ~24 000 shaders took 30–40 min, so I looked at where DXC spends its time. Measured with the retail
shaders.rpf, translated the way a title translates them.What was slow
memaccess is a[branch] switchbetween the 4 windows (xcl_m*), and the translator emitted one per dword. Ans_load_dwordx8of a descriptor was 8 switches, and ans_buffer_load_dwordx16was 16 switches plus 16?:branches (HLSL 2021's?:is a branch). In a 1 % random sample (253 programs), 88 % of the switches came from scalar loads. Translated the way a title translates them (4 windows), the same programs took DXC 2.3× as long as with one window, and the slowest went from 24 s to 130 s.MAX_COMPILE_THREADS = 6capped DXC and the PSO workers. A 16-thread CPU sat mostly idle.--precompilebuilt the wrong cache. The DXIL cache is keyed by the HLSL.--precompiletranslated with 1 window and no split wave64 form, but a title translates VS / PS / CS with its 4 windows (and on a 32-lane GPU, compute in the split form). So a title asked for other HLSL and compiled everything again.Changes
emit.rs):s_load:Load4/Load2for the contiguous dwords.s_buffer_loadandbuffer_load: bounds checks asselects. A dword that is out of range, or belongs to an inactive lane, reads offset 0 (always inside the window) and is discarded. Four dwords share one switch (xcl_loadx4).ld_raw: oneLoad4plus oneLoad, with no branch.v_interp,s_cselect/s_cmov/s_ff1/s_flbit,v_bfmand DPP lane sources:selectinstead ofif/?:.dxc.rs,pso_async.rs): every core but one (XCL_DXC_THREADSoverrides).wait_for_memorynow wants 6 GB of commit plus 1 GB per compile already running before it lets another start right away. Peak DXC commit on the pack's biggest translations is about 0.7 GB (typically 0.1–0.3 GB), so "gigabytes each" no longer holds. Priority stays normal: a title thread can wait for a pipeline (resolve_wait, a compute pipeline's first bind) and must not end up waiting behind its own threads. The driver compiles on thexcl-psoworkers are still not memory-gated.--precompile(shaders.rs): translates exactly aspsodoes: 4 windows for VS / PS / CS, 1 for MS, and the split form when the GPU runs only 32-lane waves.--windows Nand--split 0|1override. There are also measurement helpers:XCL_DUMP_HLSL=<dir>(with--recomp) writes everyXCL_DUMP_EVERY-th translation,XCL_RECOMP_WINDOWStranslates with that many windows, andXCL_RECOMP_ONLY=<hash>translates one program.Numbers (Ryzen 7 7800X3D, 8 cores / 16 threads, DXC 1.9.2602)
maindxc.exeCPU time (4 windows)--precompile, first 10 % of the pack (2 650 records), 4 windows, wall timemainmeasured 327 s and 378 s on two runs of the same slice, so wall-time differences of a few percent between runs are noise.Checked
cargo test --workspace --releaseon an RTX 5070 Ti: 527 passed, 0 failed (2no wave64skips, as onmain). The GPU tests also pass withXCL_SPLIT_WAVE64=1.gpu_grouped_loads_bounds_and_inactive_lanescovers an unaligneds_load_dwordx8,s_buffer_load_dwordx8/x16/x2straddlingnum_records, andbuffer_load_dwordx3(idxen) /x2(offen) with lanes past the end and inactive lanes that keep their registers.gpu_memory_windows_above_4_gibgains ans_buffer_load_dwordx4from window 1, which goes through the multi-windowxcl_loadx4.58309b9.v_interpkeeps its(float)conversion as aselect, andps_interp_converts_integer_inputs_and_compilespasses.Found along the way, not in this PR
pcdispatcher, which costs DXC about 1.5× per instruction. Most of them are cold blocks that the console compiler placed after the program, which jump back into it. In address order those look like crossing loops. I have a layout pass that moves them next to their branch; it is not measured enough yet to propose.--precompilestill differs from the runtime in two places that predate this PR. A PS's static samplers start after its VS's at run time, but at 0 in--precompile. And the runtime builds the mesh pass-through for its pixel shader, while--precompilebuilds it without one.translate_mesh/translate_geometrytranslate with 1 memory window, while VS / PS / CS get the title's 4. Is it intended that NGG and GS programs only reach window 0?🤖 Generated with Claude Code
@ivall on GitHub · 2026-11-23 12:51 UTC · original
Merged (
f311ca5) – great work, thanks.Checked on an RX 9070 (16 threads), DXC from SDK 10.0.26100, same random sample (seed 12345, 1 in 100 records, 258 variants) translated with 4 windows (
XCL_SURVEY_WINDOWS=4):main(58309b9)pcblocks (43)CS_RaytracingResolve_c5cb017e)cargo test --workspacegreen with the retail samples (shader pack, console DLLs, texture archive), lib tests also withXCL_SPLIT_WAVE64=1.58309b9(int / uint PS inputs converted again – XDefiant's UI text, #107 regression); your rebase kept the conversion in theselectform, which is what I had resolved to as well.resolve_wait).@Foniass on GitHub · 2026-11-23 13:25 UTC · original
One more measurement: the NVIDIA driver's own compile (pipeline creation) next to DXC's, on the 1 % random sample's 137 compute programs. These are CS plus the compute halves of MS, translated as on a 32-lane GPU (4 windows, split wave64). Times are single-threaded on an RTX 5070 Ti, driver 621.14.
mainemitterCreateComputePipelineState, coldrunner::compute_pso_secondsplus an ignored test that readsXCL_PSO_BENCH_DIR. It is not in this PR; I can add it if useful.