shader: avoid negated TGSM atomic add in the HLSL LDS subtract lowering #3931

Open
timbot103 wants to merge 1 commit from upstream-pr/3931 into main
timbot103 commented 2026-12-03 12:43:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T12:43:05Z.


Refs #1541, #2954 and #3919.

Change

Use one successful compare-exchange for each HLSL LDS subtract. The returning form writes the observed old word after the retry, including when the destination aliases the operand. The shader cache revision changes so existing native HLSL pragmas recompile with the new lowering.

expand_gfx1013_compute serves the register-based compute-request path and the shader compiler's #pragma x2w_lds path. The portable gfx1013_compute_ir_check covers both form expansions. The GPU fixture compares the aliasing return, the resulting private LDS word, and 32 contending non-returning subtracts on a shared word.

With the strengthened fixture and the old expansion, RTX 5080 PSO creation failed with 0x8007000e on a44d1967. WARP passed. The old hardware cache still produced the failure with the fixed expander under the old key. With the new key, the same hardware cache directory produced a second entry and the readback passed.

Verification

Windows 11 26200.9974, RTX 5080 driver 32.0.16.2140 (621.40), Microsoft Basic Render Driver with app-local WARP 1.0.22.0 and DXC 1.9.2602.17 (21d28f727). The LDS replay ran with its debug layer disabled.

cmake --build out/build/dev -- -j 6
$targets = 'compile_dxil', 'offscreen_check', 'native_lds_gpu', 'gfx1013_compute_ir_check',
    'gfx1013_compute_ir_gds_mask_mut', 'gfx1013_compute_ir_unsupported_opcode_mut',
    'gfx1013_compute_ir_register_tuple_mut', 'gfx1013_compute_ir_vop2_opcode_mut',
    'gfx1013_compute_ir_inline_negative_mut'
cmake --build out/build/release --target @targets -- -j 6
ctest --preset dev --no-tests=error -j 1 -R '^(gfx1013_compute_ir_|native_lds_)' -V
ctest --preset release --no-tests=error -j 1 -R '^(gfx1013_compute_ir_|native_lds_)' -V
ctest --preset pr --no-tests=error -j 1 -R '^native_lds_subword_(read|store)_controls$' -V
python -B tests/bidi_controls_check.py
python -B tests/docs_links_check.py
git diff --check origin/main...HEAD

Debug and Release each passed 100 tests with 0 failures and 0 skips. Both adapters passed readback. The two PR-preset controls, full Debug build, and repository checks passed.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5626717656 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3931). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T12:43:05Z. --- Refs #1541, #2954 and #3919. ## Change Use one successful compare-exchange for each HLSL LDS subtract. The returning form writes the observed old word after the retry, including when the destination aliases the operand. The shader cache revision changes so existing native HLSL pragmas recompile with the new lowering. `expand_gfx1013_compute` serves the register-based compute-request path and the shader compiler's `#pragma x2w_lds` path. The portable `gfx1013_compute_ir_check` covers both form expansions. The GPU fixture compares the aliasing return, the resulting private LDS word, and 32 contending non-returning subtracts on a shared word. With the strengthened fixture and the old expansion, RTX 5080 PSO creation failed with `0x8007000e` on `a44d1967`. WARP passed. The old hardware cache still produced the failure with the fixed expander under the old key. With the new key, the same hardware cache directory produced a second entry and the readback passed. ## Verification Windows 11 26200.9974, RTX 5080 driver 32.0.16.2140 (621.40), Microsoft Basic Render Driver with app-local WARP 1.0.22.0 and DXC 1.9.2602.17 (21d28f727). The LDS replay ran with its debug layer disabled. ```powershell cmake --build out/build/dev -- -j 6 $targets = 'compile_dxil', 'offscreen_check', 'native_lds_gpu', 'gfx1013_compute_ir_check', 'gfx1013_compute_ir_gds_mask_mut', 'gfx1013_compute_ir_unsupported_opcode_mut', 'gfx1013_compute_ir_register_tuple_mut', 'gfx1013_compute_ir_vop2_opcode_mut', 'gfx1013_compute_ir_inline_negative_mut' cmake --build out/build/release --target @targets -- -j 6 ctest --preset dev --no-tests=error -j 1 -R '^(gfx1013_compute_ir_|native_lds_)' -V ctest --preset release --no-tests=error -j 1 -R '^(gfx1013_compute_ir_|native_lds_)' -V ctest --preset pr --no-tests=error -j 1 -R '^native_lds_subword_(read|store)_controls$' -V python -B tests/bidi_controls_check.py python -B tests/docs_links_check.py git diff --check origin/main...HEAD ``` Debug and Release each passed 100 tests with 0 failures and 0 skips. Both adapters passed readback. The two PR-preset controls, full Debug build, and repository checks passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
R0Y00 commented 2026-12-03 12:58:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T12:58:33Z.

Review: CHANGES_REQUESTED


The Linux check on 95c9e063 reaches all 84 C++ cases successfully, including expand_atomic_subtract, then fails the Python meta-check because it still expects the literal 83/83 summary. Please update tests/gfx1013_compute_ir_meta_check.py to include the new case in CASES and update its count and summary expectations while retaining the mutation checks. The relevant job is https://github.com/R0Y00/Xbox2Windows/actions/runs/47108374219/job/144260156747.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6170264604 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3931#pullrequestreview-6170264604). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T12:58:33Z. **Review:** CHANGES_REQUESTED --- The Linux check on 95c9e063 reaches all 84 C++ cases successfully, including expand_atomic_subtract, then fails the Python meta-check because it still expects the literal 83/83 summary. Please update tests/gfx1013_compute_ir_meta_check.py to include the new case in CASES and update its count and summary expectations while retaining the mutation checks. The relevant job is https://github.com/R0Y00/Xbox2Windows/actions/runs/47108374219/job/144260156747.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3931:upstream-pr/3931'
git switch 'upstream-pr/3931'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3931'
git switch 'upstream-pr/3931'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3931'
git switch 'upstream-pr/3931'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3931'
git switch 'main'
git merge --squash 'upstream-pr/3931'
git switch 'main'
git merge --ff-only 'upstream-pr/3931'
git switch 'main'
git merge 'upstream-pr/3931'
git push origin 'main'
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
R0Y00/Xbox2Windows!3931
No description provided.