Direct DXIL: write every dword of an unaligned multi-dword format store #1912
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1922"
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 emirduran707 on 2026-11-24T23:15:17Z.
In the Direct DXIL translator,
st_bytesstores the lownbytes (up to 16) of four dwords forbuffer_store_format_*/tbuffer_store_format_*. When the address was not dword aligned (ornwas not a multiple of 4) it took the partial path, which only ever wroter[0], so an 8-, 12- or 16-byte format store at such an address dropped bytes 4..n. The partial path now stores each dwordkwith4k < natb + 4k, with the same shift and mask as before, and spills into the next dword when it crosses one. (#312 fixes the same gap in the HLSL recompiler'sst_bytes,recomp/emit.rs; this is the Direct DXIL path.)What is in it
crates/xcl/src/gpu/dxil/lower_mem.rs: the partial path ofst_bytesloops over the four dwords instead of writing only the first.crates/xcl/src/gpu/dxil/core_tests.rs: GPU testgpu_direct_unaligned_multi_dword_format_store: lane 0 does abuffer_store_format_xyzw(32_32_32_32_FLOAT, 16 bytes) at byte offset 2 and the test checks the bytes around and inside the store.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on4a6b414(rebased ontomainde36462): 1003 passed, 2 failed, 45 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpu;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record)gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3) fail identically on unmodifiedmainde36462on this GPU (seeds 722 and 1599).XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp::testson6e61d29(before the rebase): 123 passed, 0 failed, 17 ignoredgpu_direct_unaligned_multi_dword_format_storebefore the change failed: only the first dword landed (bytes00 00 80 3fat 0x102), bytes 0x106..0x112 kept the0xDEADBEEFfill; passes afterRegression run
main:
this PR:
Not tested
AI use
mainde36462(a conflict incrates/xcl/src/gpu/dxil/core_tests.rs; both tests kept) and reran the suite and smoke runs above.Imported from ivall/xcl. Originally posted by towiice on 2026-11-24T23:52:23Z.
Review: COMMENTED
Verified on Windows 11 (NVIDIA GeForce GTX 1650 SUPER, 4 GB Turing TU116, wave32, driver 610.88, DXC 1.9.2609.5):
Iterating over each dword \k\ (\4 * k < n) at \ + 4 * k\ in the partial path of \st_bytes\ properly preserves bytes \4..n\ for unaligned 8-, 12-, and 16-byte \uffer_store_format_\ / \ buffer_store_format_\ stores.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T23:20:48Z.
NVIDIA counterpart to the Radeon run: RTX 3070 8 GB, driver 616.56, Windows 11, debug,
6e61d29onmain689f2db.gpu_direct_unaligned_multi_dword_format_storeand the tests matchingformat_store: 2 passed, 0 failed, with and withoutXCL_DIRECT_DXIL=1.AI-assisted (Claude Code). Synthetic tests only.
Imported from ivall/xcl. Originally posted by WebIdentity1 on 2026-11-24T23:35:57Z.
Tested the two paths listed as untested here: 8- and 12-byte stores, including MTBUF. The test-only patch below adds 16 synthetic GPU readback cases: MUBUF/MTBUF × 8/12 bytes × offsets 0/1/2/3. It compares the entire 512-byte buffer with a bytewise expected result. MTBUF uses a deliberately different descriptor format to check that the instruction format wins.
On RTX 3090, driver 591.74, Ryzen 7 7800X3D, Windows 10 19045, Rust 1.98.1 MSVC, debug:
689f2dbplus both test functions: 0 passed / 1 failed / 0 ignored, no skips. All 12 unaligned cases mismatched; all four aligned controls matched.6e61d294c825a4d34156dea7c5f8eb0f35afa3c4plus the new test: 1 passed / 0 failed / 0 ignored, no skips. All 16 cases matched.Command:
cargo test --locked -p xcl --lib gpu_direct_short_multi_dword_format_stores -- --test-threads=1 --show-output, withXCL_ADAPTER=3090. Each tree was rebuilt; 310-file source manifests matched before/after, with onlylower_mem.rsdiffering between the pair.This supports the existing fix; no additional production change is proposed. Not tested: full suite for this overlay, retail smoke/gameplay, AMD, or performance. The patch is available to fold into this PR.
Test-only patch
AI use: Codex with GPT-6 Astra wrote the additional test, ran the Windows checks, and drafted this report.
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:08:02Z.
Both AMD and NVIDIA verification look good on
6e61d29. This is currentlyDIRTYwith merge conflicts againstmain— please rebase ontomainand letBuild and test (Windows, no GPU)run cleanly so we can merge.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:33:55Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
upstream-sync referenced this pull request2026-11-25 10:09:30 +00:00
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:42:46Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
upstream-sync referenced this pull request2026-11-26 02:07:37 +00:00