Skip to content

recomp/dxil: straddling 16-bit LDS, r0 f16 attrs, loop limit, and safe MS barriers - #1976

Open
raylitebull wants to merge 4 commits into
xcl-dev:mainfrom
raylitebull:feat/recomp-ms32kb-lds-and-safe-barrier
Open

raylitebull wants to merge 4 commits into
xcl-dev:mainfrom
raylitebull:feat/recomp-ms32kb-lds-and-safe-barrier

Conversation

@raylitebull

@raylitebull raylitebull commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Stacked on #1975 (extends #1975's 0b0e182 + 8da3917 + a85fa25 on ae0518c with commit ec13a10).

Adds three robustness and correctness improvements across the HLSL recompiler and Direct DXIL translator (32 KB passthrough_split adjustments have been trimmed from this PR and deferred cleanly to #304):

  1. Dword-straddling 16-bit LDS reads/writes (lower_mem.rs, emit.rs): splits 16-bit LDS loads/stores (ds_read_{u,i}16, ds_write_b16, ds_*_d16_*) at byte offset at % 4 == 3 across (at >> 2) byte 3 and (at + 4) >> 2 byte 0 in both Direct DXIL (lds_read_bits, lds_bits_store) and HLSL (InterlockedAnd / InterlockedOr), while preserving #134 PRELUDE_PIXEL.
  2. Early-exit-safe multi-wave mesh barriers (kernel.rs, lower.rs): replaces Direct DXIL's non-uniform multi-wave mesh barrier fallback error with a bounded groupshared arrival barrier (xcl_bar via safe_barrier_init / safe_barrier_wait / safe_barrier_exit, reusing top 2 dwords of xcl_lds when present so TGSM stays <= 32768 bytes, gated by XCL_SAFE_BARRIER != 0).
  3. Same-register f16 PS attribute fix & XCL_SHADER_LOOP_LIMIT (recomp/mod.rs, lower.rs, pso.rs): preserves hi_register = Some(0) when r[7] & 0x10 != 0 and resolves .zw subcomponents on same-register packed f16 attributes (ps_attribute_slot_and_comp), plus configurable XCL_SHADER_LOOP_LIMIT (default 65536, capped 1 << 24, folded into pso.rs translation identity).

Part of #1269.

What is in it

  • Incremental commit ec13a10 on top of #1975 (a85fa25): crates/xcl/src/gpu/dxil/kernel.rs, lower.rs, lower_mem.rs, lower_valu.rs, crates/xcl/src/gpu/recomp/emit.rs, mod.rs, pso.rs.
  • Targeted tests in fidelity_tests / attribute_tests: lds_16bit_straddling_dword_boundary_hlsl, direct_dxil_lds_dword_straddling_16bit_validate, direct_dxil_infinite_loop_guarded_by_shader_loop_limit, direct_dxil_mixed_fp16_interp_preserves_half_across_ssa_phi, direct_dxil_mesh_non_uniform_barrier_guard (including full-32KB-LDS TGSM check), and fssm_16bit_packed_tables_and_slot_mapping (r0 same-register f16 .xy/.zw).

Tested

  • Toolchain: Windows 11 x64, rustc 1.99.1 (58cf8f9c3 2026-10-13), stacked on #1975 (a85fa25) over ae0518c (ec13a10).
  • ec13a10 was rebased cleanly onto ae0518c + a85fa25 (with 32 KB passthrough_split trimmed to defer to Recompiler: the mesh pass-through budget accounts DXC’s vertex chunks #304 and #134 PRELUDE_PIXEL preserved, via pure git during a local test hold); queued for GitHub Actions Build and test and fresh AMD / NVIDIA verification (fidelity_tests, attribute_tests, v_swaprel_b32_uses_the_m0_relative_switch).
  • Earlier head 561a6a9 (prior to #304 trim / ae0518c rebase) passed cargo check --workspace --tests, fidelity_tests (20/20), attribute_tests (4/4), and v_swaprel_b32_uses_the_m0_relative_switch (1/1).

Regression run

  • Standalone scripts/smoke.ps1 pair and tests on ec13a10 vs ae0518c have not been run yet. AMD and NVIDIA reviewers are invited to test on ec13a10 vs ae0518c (including scripts/smoke.ps1, XCL_DIRECT_DXIL=1, and multi-wave mesh / f16 PS workloads) and post results in the comments.

Not tested

  • cargo check / fidelity_tests / attribute_tests and 60 s scripts/smoke.ps1 pair on ec13a10, full cargo test --workspace suite, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.

AI use

  • Antigravity assisted with implementation, rebase, trimming, and DXIL/recompiler validation tests; the author reviewed the diff.

@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head fed1358 (on its base 80f4819).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_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::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1003 passed, 0 failed, 43 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_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: from_d3d_supports_16bit_component_types, place_separates_16bit_and_32bit_rows_and_packs_16bit_together, mixed_mode_fixed_row_adopts_row_interp_mode, direct_dxil_vs_compr_and_ps_16bit_inputs_validate, direct_dxil_movrel_const_and_umin_bound_validate, direct_dxil_movrel_masks_m0_low_byte, direct_dxil_packed_f16_vs_ps_and_ms_validate, direct_dxil_mesh_non_uniform_barrier_guard, direct_dxil_lds_dword_straddling_16bit_validate, direct_dxil_infinite_loop_guarded_by_shader_loop_limit, direct_dxil_mixed_fp16_interp_preserves_half_across_ssa_phi, ps_attr_modes_follows_copied_reused_and_joined_interp_regs, m0_bounds_tracks_constants_masks_clamps_and_counted_loops, v_movrel_emits_bounded_switch_cases, vs_compr_param_and_16bit_sig_types_unpack_cleanly, ps_packed_f16_interp_high_bit_and_paired_attrs, vs_and_ms_packed_f16_param_unpack, v_movrel_and_swaprel_mask_m0_low_byte, mesh_passthrough_respects_32kb_align32_and_256_vert_limits, lds_16bit_straddling_dword_boundary_hlsl, fssm_16bit_packed_tables_and_slot_mapping.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1013 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 80f4819 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests and const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@raylitebull
raylitebull force-pushed the feat/recomp-ms32kb-lds-and-safe-barrier branch from fed1358 to 561a6a9 Compare November 25, 2026 00:44
@raylitebull

Copy link
Copy Markdown
Member Author

Stacking note: #1976 is currently stacked on top of #1975 (which carries the f16 signature packing, CFG v_interp modes, and bounded movrel/M0[7:0] changes), while #1976 adds the mesh 32 KB split alignment, straddling 16-bit LDS reads/writes, safe multi-wave MS barriers (distinct from stale/conflicting #1793), and r0 f16 attribute unpacking.

We will rebase #1976 cleanly onto #1975's latest head (and trim down to only the 4 mesh/LDS/safe-barrier additions once #1975 lands) so reviewers see zero duplicated diff.

@raylitebull
raylitebull force-pushed the feat/recomp-ms32kb-lds-and-safe-barrier branch from 561a6a9 to ec13a10 Compare November 25, 2026 01:54
@raylitebull raylitebull changed the title recomp/dxil: align mesh 32KB split, straddling 16-bit LDS, safe MS barriers, and r0 f16 attrs recomp/dxil: straddling 16-bit LDS, r0 f16 attrs, loop limit, and safe MS barriers Nov 25, 2026
@raylitebull

Copy link
Copy Markdown
Member Author

Rebased #1976 cleanly onto ae0518c + #1975 (a85fa25) in commit ec13a10:

  • Trimmed the 32 KB passthrough_split adjustments in emit.rs (deferring cleanly to #304 d3bd51d) and preserved #134's PRELUDE_PIXEL line.
  • Updated the PR title/summary accordingly and kept ec13a10 cleanly stacked atop #1975's a85fa25 (#2008 EXP VM rebase resolved).
  • Pushed ec13a10 for GitHub Actions Build and test and fresh AMD / NVIDIA verification (fidelity_tests, attribute_tests, v_swaprel_b32_uses_the_m0_relative_switch).

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (crates/xcl/src/gpu/recomp/emit.rs) — needs a rebase before it can be tested.

@JJAutoCompare

Copy link
Copy Markdown

Tested

Independent STOR-WINLAB CPU verification of open PR #1976 at ec13a10753ed792308a90d060093cc3254b6ab08. The checkout was clean and detached at that SHA before and after testing. The prior full-suite report covered an older head.

Windows 11 Enterprise Evaluation 25H2 x64 (26200.9974), Ryzen 7 3800X, Rust and Cargo 1.100.0 (x86_64-pc-windows-msvc), unoptimized test profile with debug info and incremental compilation disabled. Intel Arc A770 driver 32.0.101.9175 was installed. The shader fixture loaded DXC/DXIL 1.9.2609.5. Both selected fixtures ran on the CPU.

cargo test --locked -p xcl --lib gpu::dxil::lower_valu::fidelity_tests::direct_dxil_mixed_fp16_interp_preserves_half_across_ssa_phi -- --exact --nocapture --test-threads=1
cargo test --locked -p xcl --lib gpu::recomp::attribute_tests::fssm_16bit_packed_tables_and_slot_mapping -- --exact --nocapture --test-threads=1

Each exited 0 with 1 passed, 0 failed, 0 ignored, 0 skipped, and 1,082 filtered out (0.04 s and 0.01 s respectively).

  • The mixed-FP16 pixel shader passed DXIL validation and disassembly. The fixture found phi i32, and i32, and the upper-half preservation mask 0xFFFF0000.
  • The FSSM fixture checked packed PS and VS/MS metadata, including hi_register = Some(0) for the same-register r0 case, TEXCOORD0 in slot 0 .xy and TEXCOORD8 in slot 1 .zw. This fixture did not compile a shader.

Not tested

GPU execution or pipeline creation, retail smoke, LDS, loop limits, relative moves, mesh barriers, and the workspace suite.

AI use

T3 Code / Codex (gpt-6.2-sol) inspected and ran the two checked-in fixtures and prepared this report from the logs.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of ec13a107 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on cbc296ab, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1623 (PresentX 1623)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14648 MB
xcl-smoke v1
commit: ec13a10753ed792308a90d060093cc3254b6ab08
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1627 (PresentX 1627)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14815 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 101 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

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.

5 participants