Skip to content

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

Closed
Foniass wants to merge 1 commit into
xcl-dev:mainfrom
Foniass:dxil-lds-top-clamp
Closed

Foniass wants to merge 1 commit into
xcl-dev:mainfrom
Foniass:dxil-lds-top-clamp

Conversation

@Foniass

@Foniass Foniass commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

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 4a777f1: 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

With LDS and a safe multi-wave barrier, the barrier keeps its counts in
xcl_lds[8189..8190] and lds_top is 8188 (xcl-dev#3264), but only the split form
clamped the program's LDS indices to lds_top. A native wave64 or wave32
program 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; direct
DXIL now does the same whenever lds_top is below 8191 (DS loads and
stores, and the mesh epilogue's reads).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@vasanex

vasanex commented Nov 30, 2026

Copy link
Copy Markdown

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).

Prime1997 added a commit to Prime1997/xcl that referenced this pull request Nov 30, 2026
…he safe barrier's words) into own9

Upstream PR by Foniass. Main-based builds hang the GPU (TDR) on an RTX 3060 Ti
once multi-wave compute/mesh programs with s_barrier run in Direct DXIL; a
program writing the top of LDS over the barrier's counts would do exactly that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaZV7vMq866ni7pGnJC2Ew

# Conflicts:
#	crates/xcl/src/gpu/dxil/lower_mem.rs
@Foniass

Foniass commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

Closing: superseded by ada50ec (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.)

@Foniass Foniass closed this Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants