Recompiler: direct DXIL LDS accesses stop below the safe barrier's words #3468

Closed
Foniass wants to merge 1 commit from upstream-pr/3468 into main
Foniass commented 2026-11-29 22:39:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T22:39:55Z.


Follow-up to #3264 (merged). With LDS and a safe multi-wave barrier, the barrier keeps its counts in xcl_lds[8189..8190] and lds_top is 8188, but only the split form clamped the program's own LDS indices to lds_top. A native wave64 or wave32 program with several hardware waves a group could write the top of LDS over the barrier's counts. The HLSL path clamps every LDS access to XCL_LDS_TOP (8188) in this case (emit.rs, safe_barrier_prelude). Direct DXIL now does the same whenever lds_top is below 8191. Found while comparing amd-dev's declared-LDS commit with #2937, whose clamp has the same condition.

What is in it

  • crates/xcl/src/gpu/dxil/lower_mem.rs: lds_index clamps when split || lds_top < 8191 (DS loads, stores and atomics)
  • crates/xcl/src/gpu/dxil/lower_geom.rs: the mesh epilogue's LDS reads, the same condition
  • crates/xcl/src/gpu/dxil/robustness_tests.rs: lds_accesses_stop_below_the_safe_barrier_words (native wave64 and wave32, 16 x 16 threads). It fails without the fix and passes with it.

Tested

  • RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 4a777f16: 2777 passed, 0 failed, 49 ignored. SKIPPED GPU tests: 45 distinct notices, almost all no wave64.
  • Retail title: 60 s smoke run below.

Regression run

main:

xcl-smoke v1
commit: 3b6a91ed096d6d6e0fee52cfb86dc0a7d7c8c1b0
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1193 (PresentX 1193)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15684 MB

this PR:

xcl-smoke v1
commit: 4a777f160e25fa5723e5dccdf6d6e44a70e576e4
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1590 (PresentX 1590)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15507 MB

Not tested

  • On the GPU: the native wave64 form needs an AMD GPU, and no GPU test writes the top LDS words. The test checks the translated DXIL.
  • Other titles.

AI use

  • Claude Code with Claude Opus 5.5: found the gap, wrote the fix and the test, ran the tests and the smoke run, wrote this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5555917669 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3468). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T22:39:55Z. --- Follow-up to #3264 (merged). With LDS and a safe multi-wave barrier, the barrier keeps its counts in `xcl_lds[8189..8190]` and `lds_top` is 8188, but only the split form clamped the program's own LDS indices to `lds_top`. A native wave64 or wave32 program with several hardware waves a group could write the top of LDS over the barrier's counts. The HLSL path clamps every LDS access to `XCL_LDS_TOP` (8188) in this case (`emit.rs`, `safe_barrier_prelude`). Direct DXIL now does the same whenever `lds_top` is below 8191. Found while comparing amd-dev's declared-LDS commit with #2937, whose clamp has the same condition. **What is in it** - `crates/xcl/src/gpu/dxil/lower_mem.rs`: `lds_index` clamps when `split || lds_top < 8191` (DS loads, stores and atomics) - `crates/xcl/src/gpu/dxil/lower_geom.rs`: the mesh epilogue's LDS reads, the same condition - `crates/xcl/src/gpu/dxil/robustness_tests.rs`: `lds_accesses_stop_below_the_safe_barrier_words` (native wave64 and wave32, 16 x 16 threads). It fails without the fix and passes with it. **Tested** - RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke - `cargo test --workspace --no-fail-fast -- --test-threads=4` on 4a777f16: 2777 passed, 0 failed, 49 ignored. SKIPPED GPU tests: 45 distinct notices, almost all `no wave64`. - Retail title: 60 s smoke run below. **Regression run** main: ``` xcl-smoke v1 commit: 3b6a91ed096d6d6e0fee52cfb86dc0a7d7c8c1b0 gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1193 (PresentX 1193) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15684 MB ``` this PR: ``` xcl-smoke v1 commit: 4a777f160e25fa5723e5dccdf6d6e44a70e576e4 gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1590 (PresentX 1590) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15507 MB ``` **Not tested** - On the GPU: the native wave64 form needs an AMD GPU, and no GPU test writes the top LDS words. The test checks the translated DXIL. - Other titles. **AI use** - Claude Code with Claude Opus 5.5: found the gap, wrote the fix and the test, ran the tests and the smoke run, wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
vasanex commented 2026-11-30 03:35:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-11-30T03:35:23Z.


Unattended test report – posted automatically by an AI agent on the account owner's instruction. The account owner has not read or checked it. It is not a code review and not a merge-check.

Outcome of the tests: with this PR merged onto current main, the whole suite has no failures on an RTX 3080, and the PR's new test fails on the same main without the PR's two code changes.

Tree tested

  • head: 4a777f160e25fa5723e5dccdf6d6e44a70e576e4
  • base: main cfb9753a8cbf5517ee36914b7041cb62b4a97582
  • merged without conflicts, merged tree 9d7d26d1845dc5c618dbf9562da795189927196d

Machine: NVIDIA GeForce RTX 3080 10 GB (no wave64), driver 621.40, AMD Ryzen 9 7950X, Windows 11 Pro build 26200, rustc 1.100.0, debug build, no XCL_* variables set.

Commands and results

  • cargo build --workspace: ok
  • cargo test --workspace --no-fail-fast -- --test-threads=4, once, on the merge: 2835 passed, 0 failed, 51 ignored. 25 SKIPPED lines, not counted as coverage: 22 no wave64, 2 no heap windows, 1 driver cache cannot be disabled without Developer Mode.
  • cargo test -p xcl --lib lds_accesses_stop_below_the_safe_barrier_words -- --nocapture
    • on the merge: 1 passed, 0 failed
    • on main cfb9753a with only this PR's robustness_tests.rs added: 0 passed, 1 failed, wave64 true: no LDS index clamped to 8188. The test stops there, so this does not show whether its wave32 half fails without the change.

Since the merge had no failures, the whole suite was not run on main alone.

Not tested

  • Any run of a title. This PR changes translated shaders; no smoke pair was made, so there is nothing here on speed or memory.
  • The change on the GPU with the top LDS words: the new test checks the disassembled DXIL and does not run it. Its wave64 form cannot run on this card.
  • The change in lower_geom.rs (mesh epilogue): the new test translates a compute program. Whether another test reaches this change was not checked.
  • AMD and Intel GPUs, release builds.

Tool and model: Claude Code, Claude Opus 5.5 (read the diff before building it, merged, built, ran the tests and wrote this report).

<!-- greyfinch-sync:ivall/xcl:comment:7268022079 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3468#issuecomment-7268022079). Originally posted by [vasanex](https://github.com/vasanex) on 2026-11-30T03:35:23Z. --- **Unattended test report** – posted automatically by an AI agent on the account owner's instruction. The account owner has not read or checked it. It is not a code review and not a merge-check. **Outcome of the tests:** with this PR merged onto current `main`, the whole suite has no failures on an RTX 3080, and the PR's new test fails on the same `main` without the PR's two code changes. **Tree tested** - head: `4a777f160e25fa5723e5dccdf6d6e44a70e576e4` - base: `main` `cfb9753a8cbf5517ee36914b7041cb62b4a97582` - merged without conflicts, merged tree `9d7d26d1845dc5c618dbf9562da795189927196d` **Machine:** NVIDIA GeForce RTX 3080 10 GB (no wave64), driver 621.40, AMD Ryzen 9 7950X, Windows 11 Pro build 26200, rustc 1.100.0, debug build, no `XCL_*` variables set. **Commands and results** - `cargo build --workspace`: ok - `cargo test --workspace --no-fail-fast -- --test-threads=4`, once, on the merge: 2835 passed, 0 failed, 51 ignored. 25 SKIPPED lines, not counted as coverage: 22 no wave64, 2 no heap windows, 1 driver cache cannot be disabled without Developer Mode. - `cargo test -p xcl --lib lds_accesses_stop_below_the_safe_barrier_words -- --nocapture` - on the merge: 1 passed, 0 failed - on `main` `cfb9753a` with only this PR's `robustness_tests.rs` added: 0 passed, 1 failed, `wave64 true: no LDS index clamped to 8188`. The test stops there, so this does not show whether its wave32 half fails without the change. Since the merge had no failures, the whole suite was not run on `main` alone. **Not tested** - Any run of a title. This PR changes translated shaders; no smoke pair was made, so there is nothing here on speed or memory. - The change on the GPU with the top LDS words: the new test checks the disassembled DXIL and does not run it. Its wave64 form cannot run on this card. - The change in `lower_geom.rs` (mesh epilogue): the new test translates a compute program. Whether another test reaches this change was not checked. - AMD and Intel GPUs, release builds. **Tool and model:** Claude Code, Claude Opus 5.5 (read the diff before building it, merged, built, ran the tests and wrote this report).
Foniass commented 2026-11-30 21:45:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-30T21:45:44Z.


Closing: superseded by ada50ec5 (Kalmarv, #3497). On main, lds_index now clamps whenever lds_top < 8191, with a test of its own, which is this PR's fix for program LDS accesses. The only part left here is the same condition for the mesh epilogue's LDS reads in lower_geom.rs. That is a read-only path, and on main lds_top is below 8191 there only in the split form, which already clamps. #3478 is rebased directly onto main without this PR.

(Written with Claude Code, Claude Opus 5.5.)

<!-- greyfinch-sync:ivall/xcl:comment:7292860041 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3468#issuecomment-7292860041). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-30T21:45:44Z. --- Closing: superseded by ada50ec5 (Kalmarv, #3497). On main, `lds_index` now clamps whenever `lds_top < 8191`, with a test of its own, which is this PR's fix for program LDS accesses. The only part left here is the same condition for the mesh epilogue's LDS reads in `lower_geom.rs`. That is a read-only path, and on main `lds_top` is below 8191 there only in the split form, which already clamps. #3478 is rebased directly onto main without this PR. (Written with Claude Code, Claude Opus 5.5.)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3468
No description provided.