Recompiler: compact form that emits every distinct block text once #1305
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1315"
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?
Imported from ivall/xcl. Originally posted by CowboyBingus on 2026-11-24T14:39:34Z.
A compact translation for very large compute programs whose basic blocks repeat: each distinct block text is emitted once, as a case of one dispatch loop, and a static table gives every block's case and branch offset. Part of #1269 and #505 (the 29.75 MB
ActivateProbesprogram, see this comment).This PR adds the form and its tests; nothing calls it yet. #1316, stacked on this one, routes compute programs to it.
Measured on an RTX 5070 Ti (driver 621.24),
indirect_diffuse_lighting:CS_ScreenProbes_ActivateProbes(56c0cd3b82a00c6e, 88,863 instructions), 4 memory windows, split wave64, through XCL's own DXC path and level rule;CreateComputePipelineStatewith XCL's ABI root signature, no cached blob, from a new exe:translatetranslate_compact-O0)CreateComputePipelineStateThe
translatecolumn was measured on47efa2eplus one local commit outsidegpu/(bc394e3). The 600 s run was the same DXIL (sha256e45bc693…) on another local tree. Thetranslate_compactcolumn was measured on a local merge (31be310) whosecompact.rsdiffers from this PR's in two comments.The program has 14,378 basic blocks, and 594 distinct block bodies when branch targets are set aside.
compact_wantedtakes programs of 20,000 instructions or more whose distinct blocks hold under 30 % of the instructions. By a survey of the retail pack's 2,689 compute-program records (2,682 distinct programs) that applies the same rule, these are56c0cd3b82a00c6e,958400d2caf07244(ActivateProbesTarget) and95cc13288a27a96e(ActivateRays).ActivateRaysneeds a 9,975-word table. The table is capped at 8,192 words: a static array is constant data for the driver, and on this GPUCreateComputePipelineStateof this program's compact form with an added 12,288-word static array succeeded, and with 15,360 words failed withE_OUTOFMEMORY. Sotranslate_compactreturns an error forActivateRays, and the caller keepstranslate.Related: #1278 and #1279 change how programs of 4 MB of DXIL or more are scheduled. This PR adds a form for two of them, and the stacked PR routes them to it.
What is in it
Recompiler: decode and set up the emitter in prepare(), shared by translate–gpu/recomp/mod.rs, no behaviour change.preparealso takes theHEAP_WINDOWSflag out ofmem_windows, astranslatedid since #680, so the compact form gets the same options.Recompiler: compact form that emits every distinct block text once:gpu/recomp/compact.rs(new).gpu/recomp/emit.rs:reset_temps, so temporaries are numbered from t1 for each instruction.emit::Emproduces for each instruction, as intranslate; the A/B tests below compare the results.Tests: A/B tests of translate_compact against translate on the GPU–gpu/recomp/tests_compact.rs.buffer_load_format_xas its own block at several addresses, and in 12 formats;s_setpc_b64forward and backward;s_endpgmbefore the last block;v_mul_lo_u32;pcblocks intranslate;XCL_SAMPLE_BIG_CS=<code file>adds a retail program; a programtranslate_compactreturns an error for (e.g. its table limit) is SKIPPED, and whenCreateComputePipelineStatefails fortranslate's form the A/B comparison is SKIPPED and the compact form must still compile and run.translatedoes; the runtime code is about 380 lines.Tested
0d7907b(onmain6e1e2be):cargo build --workspaceandcargo build --releasesucceeded;cargo test -p xcl --lib compact -- --test-threads=4: 25 passed, 0 failed, 0 ignored, withgpu_compact_native_wave64_formSKIPPED (no wave64);cargo test -p xcl --lib pso:: -- --test-threads=4: 16 passed, 0 failed, 1 ignored (compile_time_bench::repeated_pso_shader_compile). The full suite was not run on this head.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4(debug) on an earlier head of this PR,c195f07(onmain266b845): 976 passed, 1 failed, 42 ignored (lib tests 927 / 1 / 22). The failure ishle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory(kernelx.rs:2070), which fails the same way onmain930e8b4. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,gpu_compact_native_wave64_form, and 16 lines ofmain'slower/lower_dxiltests. SKIPPED (per-lane form refused): 3 lines oflower_dxil's f16 / f32-conversion tests. SKIPPED (no heap windows):heap_window_out_of_memory_falls_back_to_the_switch_form.Regression run
scripts/smoke.ps1 -Game <game folder> -Seconds 60 -Title retail(release builds, menus, no input):main:
this PR:
Not tested
translateform did not finish in the driver within 600 s on this GPU.XCL_HEAP_WINDOWS=1): the A/B tests use the switch form.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-24T14:57:41Z.
AMD run with 64-lane waves, where
gpu_compact_native_wave64_formruns instead of skipping. Updated for head0d7907b(earlier runs onc195f07,7118972,d58677a,732f2ff,a45ac0canda940184, same result).Tested: pass, head
0d7907bapplied onmain6ea813a, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu:: --test-threads=4(now the widergpu::filter, which also runs the direct DXIL tests):mainwithout this PR. All 17gpu_compact_*tests ok,gpu_compact_native_wave64_formandgpu_compact_against_the_pc_block_fallbackincluded.gpu_compact_native_wave64_formSKIPPED (no wave64); the othergpu_compact_*tests ok.mainwithout this PR.gpu_dxil_wide_paritywas not rerun for this head (3 passed, 0 SKIPPED on both GPUs atc195f07).Not tested: the whole workspace suite; #1316 on top of this; a title; compile time of the big program.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by ASThome00 on 2026-11-24T14:58:36Z.
Test report for this PR on an adapter with native 64-lane waves, which covers the test listed as skipped above.
Commit:
711897240007a7c906bd31b1bb571a15907f1269(this PR's head, onmain930e8b4), debug build.Hardware: AMD Radeon(TM) Graphics (integrated, Ryzen 9 7900X3D; driver 31.0.24002.92) and NVIDIA RTX 5070 Ti (driver 32.0.16.2124), 64 GB RAM, Windows 11 26300, Rust 1.100.0, DXC 1.9.2602.17.
Tested
XCL_ADAPTER=radeon cargo test -p xcl --lib compact -- --test-threads=4: 19 passed, 0 failed, 0 ignored, none SKIPPED.gpu_compact_native_wave64_formran and passed; the "wave64 native" variants (also unstructured and with 4 windows) report result bytes identical totranslate.XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 769 passed, 1 failed, 41 ignored. SKIPPED (no mesh shaders):gpu_geometry_mode_es_gs_strip,gpu_mesh_mode_two_passes.gpu::recomp::tests::gpu_s_round_mode_controls_f16_rounding_across_modes(tests.rs:6838, lane 1 (0xbf800800) RNE: left 15360, right 48128). It fails the same way onmain930e8b4on this adapter (2 of 2 runs), so it is not from this PR.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,gpu_compact_native_wave64_form.Not tested
gpu_compact_sample_big_csdid nothing here (XCL_SAMPLE_BIG_CSnot set).scripts/smoke.ps1run, no DXC or driver compile times, no title run.AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this report.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T15:34:12Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 21 ignored.Thanks!
Imported from ivall/xcl. Originally posted by thaqiart139-alt on 2026-11-24T15:39:43Z.
Edited: rerun on the current head
a45ac0c(rebased ontomainc160d86). The first run was on7118972, againstmain930e8b4, with the same result: all pass on both GPUs.Test report for this PR's head
a45ac0con AMD RDNA2 with native 64-lane waves (the description's "native wave64 case skips here"), and on a 32-lane NVIDIA card.Tested
XCL_ADAPTER=radeon/nvidia; the SKIPPED lists below show which GPU each run used.cargo test --workspace -- --test-threads=4, this PR against its base:mainc160d86a45ac0ctests_compact.rspass on the iGPU,gpu_compact_native_wave64_formincluded (it runs there; on the RTX 5070 it is SKIPPED: no wave64).gpu_compact_sample_big_csreturns at once withoutXCL_SAMPLE_BIG_CS, so 15 of them ran.hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory, the one failure in the description, passes on both GPUs here, onc160d86and ona45ac0c.c160d86:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwareandgpu_compact_native_wave64_form(no wave64);heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).gpu::dxil::graphics::tests::emitted_ms_primitive_attribute_reaches_the_pixel_shader,gpu::dxil::graphics::tests::emitted_ms_ps_draw_a_triangle,gpu_geometry_mode_es_gs_stripandgpu_mesh_mode_two_passes(no mesh shaders);heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).Not tested
AI use
Imported from ivall/xcl. Originally posted by CowboyBingus on 2026-11-24T17:35:12Z.
Rebased onto
main9e3831e(after #680); the head is now732f2ff. Two conflicts, both ingpu/recomp/mod.rs: #680'sHEAP_WINDOWShandling at the start oftranslatenow sits inprepare(), whichtranslateandtranslate_compactshare; and the module list keeps bothmod heap_window_testsandmod tests_compact. Suite, smoke and description are updated for the new head.AI use: Claude Code (Claude Opus 5.5) wrote this comment.
Imported from ivall/xcl. Originally posted by CowboyBingus on 2026-11-24T18:52:04Z.
Rebased onto
mainc160d86(after #1426); the head is nowa45ac0c. No conflicts in this PR's commits. Suite, smoke and description are updated for the new head.AI use: Claude Code (Claude Opus 5.5) wrote this comment.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:47:40Z.
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:25:15Z.
Triage (#1607) – head
0d7907b#1448 (and #1692 / #2018 / #2025 above it) carries this PR's three commits, rebased onto main with conflicts resolved:
b662d124,efc54bda(which adds the testthe_compact_form_keeps_the_dispatch_remap) and6a3c753a. Your authorship is kept. This copy conflicts with main.Main has also since added a compact form to the direct DXIL translator (#2034 and follow-ups in
gpu/dxil/compact.rs). Compute programs go there by default, and very large ones do even withXCL_DIRECT_DXIL=0. So the HLSL compact form would now apply only to programs the direct translator refuses.Recommendation: close (superseded by #1448).
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T15:57:33Z.
Closing as superseded: the same change is in #1448 (open, mergeable, required checks green). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will.
AI use: Claude Code (Claude Opus 5.5).
Pull request closed