Recompiler: share scalar operands in compact compute cases #1538
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1548"
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 t4l03 on 2026-11-24T17:30:17Z.
Stacked on #1448 (through #1315 and #1316). Only the three commits after
57d7574belong to this PR.Part of #1269. Compact compute shaders can have repeated bodies with different scalar literals or embedded program-counter values. With
XCL_COMPACT_IMMEDIATES=1, eligible bodies can share a case while preserving their original operands and branch targets.What is in it
Tested
Windows 11 build 26300, Ryzen 7 7800X3D, RTX 4070 Ti driver 617.14, integrated Radeon driver 32.0.21042.62, Rust 1.100.0, DXC 1.9.2609.5.
cargo test --workspace --locked --offline -j 4 --no-fail-fast -- --test-threads=4 --show-outputon the RTX 4070 Ti, debug: Cargo reported 988 passed, 0 failed, 42 ignored. The harness logged 24 skipped tests or subcases: 19 without native wave64, three per-lane opcode refusals, one with heap windows unavailable, and one PSO measurement requiring Windows Developer Mode.cargo test --locked --offline -p xcl --lib -j 4 gpu_compact -- --nocaptureon the integrated Radeon: 21 passed, 0 failed, 0 ignored, zero skips. This includes GPU readback comparisons for operand sharing and the upstream many-target case.Before the metadata-only rewrite, the release CLI exported and precompiled ActivateRays in both modes with compact compute, Direct DXIL and four descriptor-heap windows enabled (
--split 0). Both selected compact HLSL and produced separate_ci.binand_c.binentries in the same cache. The case count fell from 2,516 to 2,281; the 7,482-word block table plus the 708-word literal table stayed under the 8,192-word limit. The longest target-select leaf was 32 in both forms, preserving #1448's bound.Earlier standalone
ActivateRaysPSO from the first immediate-sharing revision on this 4070 Ti with #680's heap accessors: 64.76 / 63.26 s and 3.509 / 3.492 GiB. The matching #1448 heap control took 81.49 / 78.11 s and 4.340 / 4.338 GiB. The switch-window experiment hit the 6 GiB process cap. Separate XCL caches, NVIDIA global DXCache enabled.Independent RTX 4090 (617.42) testing completed both forms on the first immediate-sharing revision with #680 applied locally. Switch windows used 6.81 GB versus about 8.2 GB in the earlier control. The 194.6 s result was inside the earlier range. The heap arm used 3.55 GB and took 113.5 s, one run with historical controls. Report.
Regression run
scripts/smoke.ps1 -Game <title folder> -Seconds 60, release, default routing.main:
this PR:
Not tested
AI use
Codex (gpt-6.2-sol) wrote the Rust implementation and tests, rebased onto
57d7574, ran validation, and drafted this report. GLM-5.3 wrote a separate local HLSL research prototype that motivated this implementation. That prototype and its generated shader artifacts are outside this PR.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:19:15Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by t4l03 on 2026-11-24T19:20:00Z.
Thanks, @DavidM1911. I verified that the head at the time contains
mainatc160d86and merges cleanly. GitHub also reports the PR as mergeable. You can fetch the current PR head withgit fetch https://github.com/xcl-dev/xcl.git refs/pull/1548/headand testFETCH_HEADin a clean checkout. If the conflict still reproduces, could you share the two SHAs you used?AI use
Codex (gpt-6.2-sol) checked the Git refs and merge tree and drafted this reply.
Imported from ivall/xcl. Originally posted by t4l03 on 2026-11-24T19:58:35Z.
Update for the RTX 3060 Ti retest:
mainadvanced fromc160d86to85e3826, and the head at the time conflicts. @CowboyBingus @Pipodi, I reproduced the samegpu/recomp/pso.rsconflict starting at #1316 (5749171). The export added by #1524 calls the five-argumentconsole_translationfromshaders.rs, and #1316 changes that function's signature and return type for compact routing. I'll restack #1548 and rerun its tests and smoke pair once #1448 has the updated base.AI use
Codex (gpt-6.2-sol) checked the merge trees and drafted this update.
Imported from ivall/xcl. Originally posted by t4l03 on 2026-11-24T20:28:25Z.
@DavidM1911 the retest head was stacked on #1448
42b2f11. I verified a clean merge againstmain4178e88, and GitHub reports the PR as mergeable.git fetch https://github.com/xcl-dev/xcl.git refs/pull/1548/headwill fetch the new head for your RTX 3060 Ti retest. The description has the fresh suite and smoke results.AI use
Codex (gpt-6.2-sol) rebased, validated, and drafted this update.
Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-24T22:49:00Z.
@t4l03 heads-up: #1448 has a new head,
57d7574. It is #1448's old commit plus a bound on the per-case select list (MAX_SELECTS= 32, split by[branch] if (xcl_b < pivot), inpick_targetsincompact.rs), rebased onto #1316964f5ed. #1448 is now ready for review. This PR's three commits no longer merge onto it without conflicts (checked withgit merge-tree), so it needs a rebase onto57d7574when you get to it. The bound only changes cases with more than 32 differing targets.AI use: Claude Code with Claude Opus 5.5.
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T23:52:18Z.
Full-suite run, since this PR has no test report yet. Tested exact head
2f9d88f(on its base266b845).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::dxil::fuzz_tests: 983 passed, 0 failed, 42 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_compact_native_wave64_form,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.literal_family_sharing_stays_within_the_table_budget,equal_blocks_share_one_case,compact_is_wanted_for_large_repetitive_programs,gpu_compact_matches_translate,the_switch_reads_auto_0_and_1,only_compute_goes_to_the_compact_backend,translated_compact_and_normal_forms_are_kept_apart,a_refused_compact_form_is_compiled_in_the_normal_form,the_compact_routing_goes_before_direct_dxil,compact_and_normal_forms_compile,gpu_compact_execz_nest,gpu_compact_backward_loops,compact_many_targets_take_a_bounded_path,gpu_compact_many_targets,gpu_compact_immediates_match_translate,gpu_compact_shared_targets,gpu_compact_dense_table,gpu_compact_repeated_blocks,gpu_compact_far_jumps,gpu_compact_v_mul_lo_u32,gpu_compact_buffer_load_format_x,gpu_compact_native_wave64_form,gpu_compact_compute_dispatch,gpu_compact_memory_windows,gpu_compact_memory_windows_loop,gpu_compact_programs_with_four_windows,gpu_compact_exchange_repeated,gpu_compact_buffer_load_format_x_repeated,gpu_compact_endpgm_before_last_block,gpu_compact_against_the_pc_block_fallback,gpu_compact_sample_big_cs.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 988 passed, 0 failed, 42 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main62265d3too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651) and the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests (follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:29:04Z.
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-01T06:04:13Z.
Triage (#1607) – head
b391e9cStacked on #1448, which in turn carries #1315 and #1316; the line overlap with #1315/#1316/#1448/#1692/#2018/#2025 is that shared base. This PR's own part is the three commits after
57d7574:compact.rs:share_literals, thecompact_literaloperand hook inemit.rs, and the opt-inXCL_COMPACT_IMMEDIATESroute inmod.rs:translate_as. No other open PR does that, and none of it is on main.It can only be reviewed once #1448 settles. It also conflicts with main.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.