Repository navigation
recomp/dxil: CFG v_interp modes, bounded movrel/M0[7:0], and MS barrier guard - #1975
raylitebull wants to merge 1 commit into
Conversation
|
Update: verified the author's integration repair at 6 passed / 0 failed / 0 ignored, zero skips. The existing 20-dispatch compute-output regression passes all 1,280 words across Direct DXIL/per-lane and wave32/split-wave64, including inactive lanes. Both Direct DXIL movrel checks, the M0-bounds and bounded-switch checks, and the swaprel switch test also pass. Native Windows 10 19045 / Ryzen 7800X3D / RTX 3090 driver 591.74 / Rust 1.98.1 MSVC / DXC 1.8.2502.11, debug; Original reproducer, proposed patch and earlier resultsVerified the #1961 / #1890 interaction on Tested — native Windows 10 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust 1.98.1 MSVC, DXC 1.8.2502.11, debug;
The patch uses #1961's Integration patch on top of #1975 + #1961diff --git a/crates/xcl/src/gpu/dxil/lower_valu.rs b/crates/xcl/src/gpu/dxil/lower_valu.rs
index fb749a7..99b7b08 100644
--- a/crates/xcl/src/gpu/dxil/lower_valu.rs
+++ b/crates/xcl/src/gpu/dxil/lower_valu.rs
@@ -1360,17 +1360,6 @@ impl Lw {
}
}
- /// Highest VGPR touched so far (for relative VGPR indexing upper cap).
- fn touched_top_vgpr(&self) -> u64 {
- self.init
- .touched
- .iter()
- .filter(|&&v| (VAR_VGPR..VAR_VGPR + 256).contains(&v))
- .map(|&v| (v - VAR_VGPR) as u64)
- .max()
- .unwrap_or(0)
- }
-
/// Range-bounded `v_movrel*`: avoids touching/selecting across unrelated VGPRs when `M0`
/// is a compile-time constant or carries a provable `UMin`/SSA upper bound.
fn movrel_bounded(&mut self, d: &Decoded, name: &str) -> LResult<()> {
@@ -1381,7 +1370,7 @@ impl Lw {
let vdst = Self::fv(d, "VDST");
let m0 = self.sreg(124);
let m0_lo = self.andc(m0, 0xFF);
- let top = self.touched_top_vgpr().max(vdst).max(src_code.saturating_sub(256));
+ let top = self.max_vgpr.max(vdst).max(src_code.saturating_sub(256));
let (rd_idx, wr_idx) = match name {
"v_movrels_b32" => (Some(m0_lo), None),
"v_movreld_b32" => (None, Some(m0_lo)),
@@ -1458,7 +1447,7 @@ impl Lw {
return err(d, "swaprel: the source is not a VGPR");
}
let base = src_code - 256;
- let top = self.touched_top_vgpr().max(vdst).max(base);
+ let top = self.max_vgpr.max(vdst).max(base);
let m0 = self.sreg(124);
let m0_lo = self.andc(m0, 0xFF);
let a = self.act();Not tested: this PR's unrelated changes, the full combined workspace suite, retail smoke, AMD/native wave64, or compilation-time/memory improvements. This checks relative moves; it does not settle the separate swaprel destination-semantics issue in #803. No performance inference is made from a control producing incorrect output. AI use: Codex with GPT-6 Astra inspected the integration, prepared the small adjustment, ran the paired Windows tests and drafted this report. |
367982c to
b62e6e3
Compare
|
Thanks for catching the Updated Verified locally with |
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Tested Clean PR head cargo test --locked -p xcl --lib --no-run
cargo test --locked -p xcl --lib -- gpu::dxil::lower_valu::fidelity_tests::direct_dxil_movrel_masks_m0_low_byte --exact --test-threads=1 --show-outputThe build succeeded. The CPU test translated and validated a Direct DXIL compute kernel with nonzero upper M0 bits, then checked the disassembly for a low-byte mask. 1 passed, 0 failed, 0 ignored, 0 skips. $env:XCL_ADAPTER = 'A770'
$env:XCL_SPLIT_WAVE64 = '1'
$env:XCL_REQUIRE_GPU = 'wave64'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
$env:XCL_DIRECT_DXIL = '0'
cargo test --locked -p xcl --lib -- gpu::recomp::tests::gpu_v_swaprel_b32 --exact --test-threads=1 --show-output
$env:XCL_DIRECT_DXIL = '1'
cargo test --locked -p xcl --lib -- gpu::recomp::tests::gpu_v_swaprel_b32 --exact --test-threads=1 --show-output
}Both locked A770 runs dispatched a split-wave64 compute test kernel. HLSL used DXC Not tested GPU output with nonzero upper M0 bits, the title compute pipeline, VS/PS/MS attribute and barrier changes, native wave64 hardware, integration with #1961, the full workspace suite, and retail smoke. AI use Codex ( |
b62e6e3 to
a85fa25
Compare
|
Rebased
|
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
|
Regression run of Against the limits in CONTRIBUTING.md: 100 % of AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, AI use: Claude Code (Claude Opus 5.5) built both trees and ran |
a85fa25 to
f6289cb
Compare
|
Rebased Pushed |
f6289cb to
1447d7e
Compare
|
Rebased Verified locally ( |
1447d7e to
865350c
Compare
|
Rebased Verified locally ( |
|
Review of the float16 interpolant part of this PR (with #1976 on top), from working on the same feature for the newer retail title (#505). I checked the layout against that title's own shaders: 442 mesh shaders and 362 pixel shaders dumped from a run, of which 383 MS params and 378 PS attributes are packed float16. Three points where this PR's pairing differs from what those programs do, and one about other titles:
A focused branch that does only the float16 interpolants, with the layout above, is here: https://github.com/MacieGx/xcl/tree/recomp/f16-packed-interpolants (2 commits on Two ways forward, whichever you and the maintainer prefer:
AI use: Claude Code (Claude Opus 5.5 coordinating; Claude Fable 5.2 and Opus 5.5 subagents analysed the dumped shaders, wrote the branch and compared it with this PR). I checked each point above against the code of both. |
…and MS barrier guard
865350c to
7296038
Compare
|
Thanks so much for the 442-MS / 362-PS interpolant spec audit, Rescoped and rebased
Verified locally ( |
A retail title's world pixel shaders (xcl-dev#505; 173 of its 362) pack their float16 interpolants: two components per dword (component c of a register in dword c / 2, the even one in the low half) and up to two signature registers per attribute, the second after the dwords the first one's components take (1 for .xy, 2 for .xyz / .xyzw). The PS reads each half with v_interp_p2_f16, SRC0 bit 8 choosing the high one. XCL refused the PS input table of such programs (records [6, reg, mask, attr, 0, reg2, packed reg, flags]: flag 8 = float16, flag 16 = byte 5 names the second register, byte 6 below byte 1 from the first pair on), so every attribute, plain ones included, fell back to "the N-th register" and the ones after a pair read their neighbour. The PS also converted the raw packed dword as a float, ignored the high bit and declared the float16 inputs nointerpolation. Now the table parses, each (dword, half) of a packed attribute maps to its element and component (f16_registers, ps_f16_slot; a record that repeats its own register pairs it with the next float16 register no other attribute names), and the PS reads that component as a float, interpolated with the attribute's own mode. Both translators (HLSL and direct DXIL). The layout was checked on the title's dumped programs: every v_interp_p2_f16 (dword, half) of 376 of 378 packed attributes in 362 PS is a declared component (2 read one past a .xy register). Not covered here: the VS / mesh side still exports the packed dwords raw (the next commit), so the GPU test feeds the PS from a PC VS that hands over each component as a float. xcl-dev#1975 / xcl-dev#1976 parsed the same records with a fixed layout - the second register always in dwords 2-3, a repeated register paired with itself - which does not match the title's programs after a .xy register; both have since dropped their float16 part in favour of this change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The other half of the previous commit: the VS and mesh (NGG) programs that feed those pixel shaders export their float16 interpolants packed the same way - two components per dword, up to two signature registers per exp param. XCL refused the output table of such programs (records [6, reg, param, reg, 0, 1 | 3]: 1 = float16, 3 = more than one dword) and fell back to "the N-th register", so every param after a pair went to its neighbour's register; a packed param went raw into its first register alone. A mesh program never used its table at all. Now the table parses for VS and mesh programs (MsInterface::params) and a packed param is unpacked where it is exported: each half goes as a float to its own component of its own element, in the VS outputs and in the mesh record, in both translators. The table does not name the second register of a pair: the float16 registers pair up in order, so it is the next one no other param starts with (f16_registers). Checked on the title's dumped programs: the enable mask of every exp param of 383 packed params in 442 MS is exactly the predicted dwords. A mesh program with a table now takes its params' registers from it, float16 or not, as a VS already did; without one nothing changes. xcl-dev#1975 unpacked the same params with the second register always in dwords 2-3 and paired a mesh program's registers without its table; it has since dropped that part in favour of this change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@raylitebull thanks for deferring it. The float16 interpolant part is now its own PR: #2513 (2 commits on |
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
|
AMD RX 9070 (RDNA4, RADV / Linux) test report on Setup
Tested
Not tested
AI use
|
|
Overlap with #803 (open): for AI-assisted (Claude Code, Claude Opus 5.5): read both diffs and wrote this. |
Fixes shader fidelity issues across both the HLSL recompiler and the Direct DXIL translator (all 16-bit signature /
f16interpolant packing has been cleanly deferred to@MacieGx'srecomp/f16-packed-interpolantsPR with zero file overlap onrecomp/mod.rs,dxil/graphics.rs,dxil/lower_gfx.rs, ordxil/lower_mem.rs):v_interpmode tracking (emit.rs): tracks interpolation modes (ps_attr_modes,BasicCfg) across copied, reused, and joinedv_interpregisters.v_movrel/v_swaprel/s_movrelranges &M0[7:0]/M0[23:16]masking (emit.rs,lower.rs,lower_valu.rs,lower_wide.rs,tests.rs): propagatesM0bounds across constants, masks, clamps, and counted loops (m0_bounds/Lw::value_upper_bound), emits bounded switch cases, and masksM0to the low byte (M0[7:0]/M0[23:16]) in both HLSL and Direct DXIL (Lw::movrel/Lw::swaprelinlower_wide.rsviaself.top_vgpr()).kernel.rs,lower.rs): detects and guards non-uniforms_barrierusage in mesh shaders in both backends.Part of #1269.
What is in it
crates/xcl/src/gpu/recomp/emit.rs&tests.rs: CFGv_interpmode tracking (ps_attr_modes,BasicCfg),m0_boundsanalysis andM0[7:0]masking forv_movrel/v_swaprel/s_movrel, bounded switch generation, non-uniform mesh barrier handling,scalar_relative_move_cluster, andv_swaprel_b32_uses_the_m0_relative_switch.crates/xcl/src/gpu/dxil/kernel.rs,lower.rs,lower_valu.rs,lower_wide.rs:M0[7:0]/M0[23:16]masking andconst_u64/value_upper_boundrange-narrowing insideLw::movrel/Lw::swaprel, plus non-uniform MS barrier guarding (6files total,+1198 / -81).Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), DXCdxcompiler 1.8.2502.11/dxil 1.8.2502.11, rebased cleanly ontoc9ee916a(72960386).cargo check --workspace --tests: passed (0warnings in touched files).fidelity_tests7/7,saveexec_tests::direct_*1/1,recomp::testsscalar_relative_move_cluster+v_swaprel_b32_uses_the_m0_relative_switch2/2): 10 passed, 0 failed (0.18s,dxil 1.8.2502.11validated).Regression run
scripts/smoke.ps1pair on72960386vsc9ee916ahas not been run yet. AMD and NVIDIA reviewers are invited to test on72960386vsc9ee916a(includingscripts/smoke.ps1,XCL_DIRECT_DXIL=1, and HLSL recompilation paths) and post results in the comments.Not tested
scripts/smoke.ps1pair on72960386, fullcargo test --workspacesuite on72960386, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.AI use
c9ee916a, and DXIL/recompiler validation tests; the author reviewed the diff and test output.