Recompiler: pick root-UAV memory windows with bit tests, not a switch #2191
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!2191
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2191"
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?
@ezamelczyk on GitHub · 2026-11-25 08:25 UTC · original
ezamelczyk:recomp-window-bit-tests→main· +32 −20 · 2 files · 1 commits · draftThe memory-window accessors (
xcl_mLoad,xcl_mStore, the atomics,xcl_loadx4) now choose a root UAV with one[branch] ifper window, testing a bit of a one-hot mask, instead of[branch] switch (xcl_w). Part of #1269.Why: Mesa's SPIR-V front end lowers an
OpSwitchinto a chain of ifs with a path on which no case runs. Inside a loop, every accessor result then becomes a loop-carried value that is undefined on entry, and RADV keeps all of them live. This is the cause of theCS_RaytracingResolvebuilds that @Fran-co-F and @lucsoft saw ACO's spiller run out of memory on in #1269. In those builds the windows are root UAVs, which is the default because heap windows are opt-in. With per-window ifs the values are defined before the first test, so nothing is carried round the loop. The bits are tested as(wm & (1u << k)) != 0u, withwm = select(xcl_w < windows, 1u << xcl_w, 0u), notxcl_w == k: with equality tests, DXC's jump threading took 31 of 47 s of the compile. Anxcl_woutside the windows sets no bit and keeps the default, as the switch'sdefaultdid. The heap form (XCL_HEAP_WINDOWS=1) is unchanged.What is in it
crates/xcl/src/gpu/recomp/emit.rs(mem_accessors): the switch form is replaced by per-window bit tests.crates/xcl/src/gpu/recomp/tests.rs: the two checks that looked forswitch (xcl_w)look for the new form.Tested
RX 9070 XT (RDNA4), Mesa 26.3.1 RADV (ACO), Ryzen 5 8400F, 30 GB RAM, CachyOS kernel 7.3.6. Wine 11.0 Staging (GE-Proton), vkd3d-proton 3.1 with #257's patch and dxil-spirv
53aac418. DXC 1.9.2609. rustc 1.99.1, release, cross-built forx86_64-pc-windows-msvc. Not Windows.One retail program,
CS_RaytracingResolve(console84eee477d68b6fdf, 1.28 MB of DXIL in the switch form), one cold pipeline build (VKD3D_SHADER_CACHE_PATH=0, empty caches):main(switch)xcl_w == k(The register and phi counts come from a locally instrumented Mesa build. The times and memory are with the system Mesa.)
The retail pack's 2 689 compute programs,
xcl shaders shaders.rpf --precompile --only cs --pipelines: 2 689 compiled, 0 errors, 2 689 pipelines made, 0 refused. This was on a local tree with this change on top of #1316, #1448 and #1288, not on this branch alone. In the switch form, the same pass ran out of memory on RADV in theCS_RaytracingResolvestretch for @lucsoft (#1269).cargo test --workspace -- --test-threads=4(release, Wine): 1 083 passed, 15 failed, 26 ignored. SKIPPED:f16_programs_on_the_gpu/f32_programs_on_the_gpu(per-lane form refusesV_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32) andpso_measurement_compiles_an_exact_synthetic_record(no Developer Mode under Wine).main568e7dband on this branch, with identical results on both. 6 fail on both:fuzz_validate_and_gpu_2,f64_programs_on_the_gpu,f32_programs_on_the_gpu,gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu_depth_buffer_created_for_unordered_access_is_placed,xma2_source_voice_decodes_and_manages_lifetime. The other 9 pass alone on both; in the full run they failed because a device removal from another test took them out.gpu_memory_windows_reject_out_of_uma_aliasing,gpu_mesh_mode_reads_memory_windows,gpu_memory_windows_above_4_gibandgpu_bvh64_intersect_ray_across_memory_windows_and_grazing.Regression run
scripts/linux/smoke.shfrom #257 (it prints the blocksmoke.ps1prints), retail title, 300 s, the same button script. Each run had an empty DXIL cache, Mesa's shader cache off andVKD3D_SHADER_CACHE_PATH=0.In both runs presents had stopped before the end (
presents per 2 s (last 3): 0 0 0). I have not checked where each run stopped.main:
this PR:
Not tested
XCL_DIRECT_DXIL), which picks its windows separately.AI use
🤖 Generated with Claude Code
@luckyteagirl on GitHub · 2026-11-25 08:58 UTC · original
Independent native Windows compiler measurement on exact PR head
fb84fde754d03463fcc56e424b2e6e79866e6b20against the runtime-identical pre-PR source6020a33b16ba2de25b3aef5947552f2dc1831f09. The diff from that source to PR base568e7db7729c8fa6c8f0f4b32d798faaf11462bbchanges only README/SVG, not compiler code. The PR release workspace build passed and its checkout is clean.Environment: Windows 11 build 26200, Ryzen 9 5980HX, RX 6800M driver
30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. From a locally owned title pack, each XCL release executable exported the same compute record hash84eee477d68b6fdf(CS_RaytracingResolve), with four root-UAV windows and--split 0. Both exports reported one program and zero errors. No title or shader bytes are attached here.I compiled each exported HLSL file using
dxc.exe -E main -T cs_6_6 -HV 2021 -O1 -Fo ...; these are the flagsdxc::compileselects for a source of this size. I alternated three sequential runs per revision, with a memory guard that did not fire:All six DXC processes exited 0. On this Windows DXC path, the PR's median was 6.109 s / 17.9% longer and its DXIL was 221,060 bytes / 17.2% larger for this record. The sampled RSS is an approximate process measure, not total system commit. This differs from the Linux/RADV end-to-end improvement in the PR description; it does not measure or contradict the RADV driver result.
Scope: Exact-record HLSL generation and standalone native DXC compilation only. I did not run
CreateComputePipelineState, measure a Windows driver pipeline, execute the shader, run the full test suite, or perform a retail-title smoke on this PR. The synthetic/root-UAV semantics and gameplay performance remain unverified here.AI use: OpenAI Codex identified the record in the locally owned pack, built the PR, exported both HLSL variants, wrote and ran the bounded DXC measurement script, checked the exact revisions and numbers, and prepared this report.
@bielfreedom on GitHub · 2026-11-25 09:51 UTC · original
AMD Windows driver data for #2191: on the RX 9070 XT, the bit-test form makes the DXIL 15 % larger and AMD's
CreateComputePipelineState1.56× slower on 24 large retail programs.CS_RaytracingResolvestill doesn't finish on the HLSL path. This adds the driver side to @luckyteagirl's DXC-only numbers above. The PR's gain is on RADV/ACO; on the native AMD Windows compiler it goes the other way.Setup
568e7db;fb84fde.fnv64), DXC time and per-CreateComputePipelineStatetime.Method
XCL_HEAP_WINDOWS=0),XCL_PIPELINE_THREADS=1,XCL_DXC_THREADS=1.XCL_PSO_DISK_CACHE=0and a fresh exe name per run, because the AMD driver cache is keyed on the exe file name.24 programs (means of 2 rounds; all 96 builds succeeded, 0 refused)
ed2f8fa2e996c6a6c6f8ee0f53ed570984eee477d68b6fdf(CS_RaytracingResolve), 1 run each:The DXIL sizes match luckyteagirl's (+17 %). Both builds were still working, at 9–11 GB private, when they were killed. So on AMD Windows the bit tests don't remove whatever stalls this program in the driver. The direct route (53 s whole, 7.8 s with #2107's split; data) remains the way through here.
Read / inference
Not tested
XCL_HEAP_WINDOWS=1(unchanged by the PR).AI use: Claude Code (Claude Opus 5.5) ran the measurements and drafted this. The account owner is away; counts and timings only, no game data.
@zohaiblazuli on GitHub · 2026-11-25 14:32 UTC · original
Data for the cost this PR targets, measured on
main1a0bbe3(not on this PR's head): #2088 comment. RTX 3060 (NVIDIA 617.42), 8 compute programs, cold driver builds. Replacingswitch (xcl_w)withswitch (0u)(wrong results; an upper bound) makes the build 1.6–6.2× shorter.The largest gap left after the heap form is on the 5 MB outlier
219287eb2f6021fe: 819 s with the switch, 434 s heap, 133 s for the bound. A timing of this PR on that program would show how much of it this form recovers.AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this.
@siam4201 on GitHub · 2026-11-25 15:56 UTC · original
Tested on NVIDIA GeForce RTX 5070 Ti (driver
32.0.16.2101, Ryzen 9 7900X, Rust1.97.1), including a cold PSO benchmark on a large compute outlier from a retail pack (83a0f0eec0ddb740):Cold PSO benchmark (
--measure-pso 83a0f0eec0ddb740 --repeat 2)main(568e7db):263716 bytes DXIL,3053 ms DXC, median10.442 s(min 9.418 s, max 11.465 s)pr-2191(fb84fde):312640 bytes DXIL,2428 ms DXC, median6.383 s(min 5.855 s, max 6.911 s) — ~38.9% faster cold driver compile (~20.5% faster DXC)Tested (
.\scripts\test.ps1)pr-2191(fb84fde): 1094 passed, 4 failed (pre-existingfuzz_validate_and_gpu_0..3E_OUTOFMEMORY#1905, same asmain568e7db), 26 ignoredno wave64, 3per-lane form: refused(V_CVT_F16_F32,V_MUL_F16,V_PK_MUL_F16)Regression run (
.\scripts\smoke.ps1, 30s)main:pr-2191:Not tested
AI use
@afpruivo on GitHub · 2026-11-25 21:32 UTC · original
Native Windows NVIDIA result: #2191 slowed seven of eight cold driver builds on an RTX 3090.
RTX 3090 24 GB, NVIDIA 621.40, Windows 11 build 26300, i5-13600K, DXC 1.8.2502.11. All four arms use main
68a284a, with PR #2191 headfb84fdeand PR #1380 head7d43a46merged locally. The #1380 merge kept main’scoherent_memand the PR’s flat gate. One coldCreateComputePipelineStatemeasurement per record and arm, four windows, caches disabled. Runtime and workspace tests were outside this measurement.1b0362e416b36cba26fad5fd65eaf255062468c09af883b973fb752d7f62c3a51623a8c07824a06c2d2bbb32f64e4801f9d73adcc1ad69ef219287eb2f6021feThe bit-test arm took 1.05–1.21× as long on seven records. The largest record improved by 11.5%, enough to lower the total by 3.0%. Aggregate DXIL grew from 14.95 to 16.86 MB (+12.7%), DXC time rose 9.6%, and peak private memory on the largest record rose from 9.37 to 11.32 GB. The comparison is consistent with per-window branches contributing to driver compile cost. The flat-load arm also changes the memory access pattern, so this run does not isolate that effect.
AI disclosure: OpenCode ran the benchmark and drafted the report. ChatGPT checked the figures against the saved matrix and posted at my request.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.