Skip to content

Direct DXIL: bound relative moves by max_vgpr and refuse in per-lane bridge - #2037

Open
IAmTheSween wants to merge 1 commit into
xcl-dev:mainfrom
IAmTheSween:direct-dxil-movrel-vgpr-bound
Open

IAmTheSween wants to merge 1 commit into
xcl-dev:mainfrom
IAmTheSween:direct-dxil-movrel-vgpr-bound

Conversation

@IAmTheSween

@IAmTheSween IAmTheSween commented Nov 25, 2026 •

Copy link
Copy Markdown

Fixes #1890. In direct DXIL, Lw::top_vgpr() computed the upper bound for v_movrel* and v_swaprel_b32 select loops from self.init.touched, which starts empty outside Entry::Kernel and is cleared before each instruction in XCL_PER_LANE=1. Any relative move with m0 > 0 targeting a VGPR not statically touched earlier in RPO order was silently truncated.

Lw::max_vgpr now scans insts in Lw::new matching the HLSL emitter, and top_vgpr() returns self.max_vgpr. In the per-lane recompiler, bridge() refuses dynamically indexed relative moves upfront to route them through the fallback.

What is in it

  • crates/xcl/src/gpu/dxil/lower.rs: max_vgpr field on Lw
  • crates/xcl/src/gpu/dxil/kernel.rs: scan max_vgpr across program instructions in Lw::new
  • crates/xcl/src/gpu/dxil/lower_wide.rs: top_vgpr() returns self.max_vgpr
  • crates/xcl/src/gpu/recomp/lower.rs: refuse V_MOVREL* and V_SWAPREL_B32 in bridge()
  • crates/xcl/src/gpu/dxil/core_tests.rs: tests for v_movrel* and v_swaprel_b32 with non-static target VGPRs
  • crates/xcl/src/gpu/recomp/lower.rs: test verifying refusal of dynamic moves in per-lane lowering

Tested

  • NVIDIA GeForce RTX 5070 (driver 32.0.16.2114, 572.16), AMD Ryzen 5 5600X, Windows 11 Build 26300, rustc 1.100.0 msvc, debug
  • cargo test -p xcl --lib gpu::dxil::core_tests: 17 passed, 0 failed, 1 ignored
  • cargo test -p xcl --lib gpu_packed_math_dots_movrel: passed
  • cargo test -p xcl --lib dynamically_indexed_vgpr_moves_are_refused_in_per_lane: passed
  • python scripts/test_pr_check.py: 13 passed, 0 failed

Regression run
scripts/smoke.ps1 on main (8e87fc7b62a87ea589ccb9ea6182f514016cf7db) and on this PR's head commit (4fc971951041a6adf2f423633306049eadc9be53):

xcl-smoke v1
commit: 8e87fc7b62a87ea589ccb9ea6182f514016cf7db
gpu: NVIDIA GeForce RTX 5070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1137 (PresentX 1137)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15342 MB
xcl-smoke v1
commit: 4fc971951041a6adf2f423633306049eadc9be53
gpu: NVIDIA GeForce RTX 5070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 953 (PresentX 954)
presents per 2 s (last 3): 60 60 58
device removals: 0
crashes: 0
peak commit: 15148 MB

Not tested

  • AMD RDNA GPU, native wave64 execution
  • Retail gameplay progression (regression smoke verified boot, shaders, and rendering up to 60s)

AI use

@WebIdentity1

Copy link
Copy Markdown

Coordination: this overlaps the existing #1961 (4b4c111098a3b22e21dce00d41bc95ab3c11da8e), also addressing #1890. I inspected this head 1c0407a40e38a10cb5b585243efd8d5d3145e692; I have not run it and am not reporting test results for it.

Both changes replace the lowering-order-dependent init.touched bound with a program-wide max_vgpr. #1961 additionally initializes register gaps and transfers the possible relative range through the per-lane bridge, retaining inactive lanes, rather than refusing relative instructions. It only scans operands for programs using relative indexing, and is based on main after the automatic Direct DXIL source-cache hash change.

The existing #1961 compute-entry regression and native results are available for consolidation: four move forms plus inactive lanes, Direct DXIL and per-lane, 20 RTX 3090 dispatches and 30 AMD iGPU dispatches including native wave64, all 64 words per dispatch. Its identical test-only baseline fails on both GPUs. The current full-suite comparison and remaining CLAMP failure are documented there; retail smoke is still absent, so #1961 remains draft.

The two new tests here call translate, which uses the test-kernel entry; #1961's regression calls translate_compute/compute_with and writes output to memory, covering the compute-entry initialization issue directly. These are different coverage claims. I suggest consolidating around the existing compute regression and making the per-lane support-versus-fallback choice explicitly, rather than maintaining parallel fixes. Separate swaprel destination semantics remain tracked in #803.

No new implementation or duplicate test run from this coordination check. AI-assisted source comparison/report: Codex (GPT-6); the linked historical measurements retain their original attribution.

@raylitebull

Copy link
Copy Markdown
Member

Diff audit passed (kernel.rs max_vgpr scan, lower_wide.rs top_vgpr(), recomp/lower.rs per-lane V_MOVREL*/V_SWAPREL_B32 refusal, and tests) and CI has been approved.

Note that #1961 also targets #1890 (with full per-lane dynamic VGPR range transfer verified across RTX 3090 + AMD iGPU, currently draft pending retail smoke). For #2037, remaining items before merge are paired xcl-smoke v1 blocks (PR description failed), an independent AMD GPU verification pass on 1c0407a, and confirming whether #2037 (per-lane refusal) or #1961 (per-lane transfer) should land.

@nnonno91

Copy link
Copy Markdown

Independent AMD check of 1c0407a40e38a10cb5b585243efd8d5d3145e692. The two new direct-DXIL GPU fixtures also pass against the parent, so those fixtures give AMD execution coverage but don't reproduce the earlier register-bound behavior.

Tested

  • AMD Radeon(TM) Graphics iGPU (driver 32.0.21042.62), Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.8.2502.11, unoptimized test profile. Selected XCL_ADAPTER=AMD Radeon and XCL_REQUIRE_GPU=wave64.
  • On the PR, cargo test --locked -p xcl --lib gpu::dxil::core_tests -- --nocapture --test-threads=1 gave 15 passed, 0 failed and 1 ignored (dump_dxc_lowering). Both new relative move/swap fixtures executed in wave32. I also ran the same command with the exact filters gpu::recomp::tests::gpu_packed_math_dots_movrel and gpu::recomp::lower::tests::dynamically_indexed_vgpr_moves_are_refused_in_per_lane, adding --exact after --. Each gave 1 passed, 0 failed and 0 ignored. The packed math/relative move test ran with XCL_DIRECT_DXIL=1 and checked all 64 lanes. No SKIPPED lines.
  • On parent 8e87fc7b62a87ea589ccb9ea6182f514016cf7db, I copied only the new test code and used the same command with the filters with_non_static_target_vgpr and dynamically_indexed_vgpr_moves_are_refused_in_per_lane without --exact. The GPU tests gave 2 passed and 0 failed. The per-lane test gave 0 passed and 1 failed because the parent already returned unsupported V_MOVRELD_B32, while the PR returned the reason specific to dynamic indexing. Both runs had 0 ignored and no skips.

Not tested

Full workspace suite, retail smoke, or a before/after shader that reproduces the original register-bound issue.

AI use

OpenAI Codex (GPT-6.2 Sol) ran the tests, checked the logs and drafted this report.

@JoaoPauluu

Copy link
Copy Markdown

A run with vkd3d-proton as the host D3D12 (DXIL → SPIR-V through dxil-spirv, then the NVIDIA Vulkan driver), so the DXIL goes through a different compiler than the native-Windows runs here: this PR's 3 tests pass.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. 1c0407a as it is (merge base with main 8e87fc7), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • v_movrel_with_non_static_target_vgpr: ok, not skipped
    • v_swaprel_with_non_static_target_vgpr: ok, not skipped
    • dynamically_indexed_vgpr_moves_are_refused_in_per_lane: ok, not skipped

Not tested

  • the whole suite on this head, a retail title, native Windows, AMD.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@IAmTheSween

Copy link
Copy Markdown
Author

Coordination: this overlaps the existing #1961 (4b4c111098a3b22e21dce00d41bc95ab3c11da8e), also addressing #1890. I inspected this head 1c0407a40e38a10cb5b585243efd8d5d3145e692; I have not run it and am not reporting test results for it.

Both changes replace the lowering-order-dependent init.touched bound with a program-wide max_vgpr. #1961 additionally initializes register gaps and transfers the possible relative range through the per-lane bridge, retaining inactive lanes, rather than refusing relative instructions. It only scans operands for programs using relative indexing, and is based on main after the automatic Direct DXIL source-cache hash change.

The existing #1961 compute-entry regression and native results are available for consolidation: four move forms plus inactive lanes, Direct DXIL and per-lane, 20 RTX 3090 dispatches and 30 AMD iGPU dispatches including native wave64, all 64 words per dispatch. Its identical test-only baseline fails on both GPUs. The current full-suite comparison and remaining CLAMP failure are documented there; retail smoke is still absent, so #1961 remains draft.

The two new tests here call translate, which uses the test-kernel entry; #1961's regression calls translate_compute/compute_with and writes output to memory, covering the compute-entry initialization issue directly. These are different coverage claims. I suggest consolidating around the existing compute regression and making the per-lane support-versus-fallback choice explicitly, rather than maintaining parallel fixes. Separate swaprel destination semantics remain tracked in #803.

No new implementation or duplicate test run from this coordination check. AI-assisted source comparison/report: Codex (GPT-6); the linked historical measurements retain their original attribution.

Thanks for reaching out!

The choice here to refuse V_MOVREL* and V_SWAPREL_B32 in bridge() was intentional: bridging (0..=max_vgpr) transfers the entire register file across every dynamically indexed move, which inflates SSA inputs and outputs for instructions that usually only touch a small runtime offset. Routing these moves to the fallback keeps the per-lane bridge minimal and bounded to statically known operands.

That said, your synthetic multi-dispatch compute regression in #1961 is very comprehensive. If the maintainers prefer retaining per-lane execution by bridging the whole range over falling back, I am glad to either pull in that bridging approach and compute test here, or help land #1961 with these retail smoke numbers.

…bridge

Fixes xcl-dev#1890. In direct DXIL, Lw::top_vgpr() computed the upper bound for
v_movrel* and v_swaprel_b32 select loops from self.init.touched, which
starts empty outside Entry::Kernel and is cleared before each instruction
in XCL_PER_LANE=1. Any relative move with m0 > 0 targeting a VGPR not
statically touched earlier in RPO order was silently truncated.

Lw::max_vgpr now scans insts in Lw::new matching the HLSL emitter, and
top_vgpr() returns self.max_vgpr. In the per-lane recompiler, bridge()
refuses dynamically indexed relative moves upfront to route them through
the fallback.

Assisted-by: Antigravity (Gemini 3.8 Flash)
@IAmTheSween
IAmTheSween force-pushed the direct-dxil-movrel-vgpr-bound branch from 1c0407a to 4fc9719 Compare November 25, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Direct DXIL: Lw::top_vgpr() reads init.touched (empty outside Entry::Kernel and cleared in XCL_PER_LANE), truncating v_movrel* and v_swaprel_b32

5 participants