shader: return the old qword from LDS comparisons and XOR #937

Merged
stan495 merged 4 commits from upstream-pr/944 into main 2026-11-24 01:16:59 +00:00
stan495 commented 2026-11-23 18:10:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-23T18:10:55Z.


Scope

Add the five returning forms of signed and unsigned qword min/max and bitwise XOR. Return the original qword even when the destination aliases the data pair.

Depends on #942. Review this batch with git diff 9926b9f6 f02da958. The non-returning forms are already in main via #1002. This batch adds the five returning forms.

Verification

Tested f02da958 on Windows 11 25H2 (10.0.26200.9974) with the D3D12 debug layer enabled. Hardware used AMD Radeon RX 7900 XTX (32.0.32029.2010). WARP used Microsoft Basic Render Driver (10.0.26100.9818).

cmake --build --preset dev --target offscreen_check
$env:XBOX2WINDOWS_ADAPTER = '7900 XTX'
ctest --preset dev --no-tests=error -R '^compute_store_aot_(lds_qword|lds_private|ds_route|guard_read)_(warp|hardware)$|^compute_store_aot_warp$' -V

9 passed, 0 failed, 0 skipped. Both backends compared all 320 UAV words. Each fixture compares the original and updated pairs after one and two groups. Negative controls copy the post-update pair where the original should be returned.

python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1

LLVM 15.0.7 round trips reproduced the same HLSL as text translation. Coverage records include all five new forms.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6565781677 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/944). Originally posted by [stan495](https://github.com/stan495) on 2026-11-23T18:10:55Z. --- ## Scope Add the five returning forms of signed and unsigned qword min/max and bitwise XOR. Return the original qword even when the destination aliases the data pair. Depends on #942. Review this batch with `git diff 9926b9f6 f02da958`. The non-returning forms are already in main via #1002. This batch adds the five returning forms. ## Verification Tested `f02da958` on Windows 11 25H2 (10.0.26200.9974) with the D3D12 debug layer enabled. Hardware used AMD Radeon RX 7900 XTX (32.0.32029.2010). WARP used Microsoft Basic Render Driver (10.0.26100.9818). ```powershell cmake --build --preset dev --target offscreen_check $env:XBOX2WINDOWS_ADAPTER = '7900 XTX' ctest --preset dev --no-tests=error -R '^compute_store_aot_(lds_qword|lds_private|ds_route|guard_read)_(warp|hardware)$|^compute_store_aot_warp$' -V ``` 9 passed, 0 failed, 0 skipped. Both backends compared all 320 UAV words. Each fixture compares the original and updated pairs after one and two groups. Negative controls copy the post-update pair where the original should be returned. ```sh python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` LLVM 15.0.7 round trips reproduced the same HLSL as text translation. Coverage records include all five new forms.
upstream-sync closed this pull request 2026-11-24 06:45:31 +00:00
lambirou commented 2026-11-24 06:49:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-24T00:34:17Z.


Coordination from the XCL-15 candidate (#1061), per the maintainer's note. Our branch independently implements the same five returning forms (ds_xor_rtn_b64, ds_min/max_rtn_i64, ds_min/max_rtn_u64) on the current private LDS gfx1030 profile. It passes the binary control, WARP (Microsoft Basic Render Driver 10.0.26100.10068) and hardware (AMD RX 9060 XT, driver 32.0.32029.2010, Windows 10.0.26300): 320 words per case, one and two groups, no mismatches. Distinct controls in our branch: signed-high/unsigned-low ties, destination/source overlap, and a mutant that returns the post-update pair instead of the old pair; the unsigned signed-comparison mutant is expected at word 0. I will close #1061 to keep one implementation candidate. If useful, I can add those tests as a small follow-up with attribution after #944 lands, or share the exact fixture lines here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118205980 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/944#issuecomment-7118205980). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-24T00:34:17Z. --- Coordination from the XCL-15 candidate (#1061), per the maintainer's note. Our branch independently implements the same five returning forms (ds_xor_rtn_b64, ds_min/max_rtn_i64, ds_min/max_rtn_u64) on the current private LDS gfx1030 profile. It passes the binary control, WARP (Microsoft Basic Render Driver 10.0.26100.10068) and hardware (AMD RX 9060 XT, driver 32.0.32029.2010, Windows 10.0.26300): 320 words per case, one and two groups, no mismatches. Distinct controls in our branch: signed-high/unsigned-low ties, destination/source overlap, and a mutant that returns the post-update pair instead of the old pair; the unsigned signed-comparison mutant is expected at word 0. I will close #1061 to keep one implementation candidate. If useful, I can add those tests as a small follow-up with attribution after #944 lands, or share the exact fixture lines here.
stan495 commented 2026-11-24 06:49:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T00:51:57Z.


Thanks @lambirou for coordinating #1061 and sharing your independent WARP and RX 9060 XT results. I resolved the merge conflict in 0b45e7f2, and the LDS qword tests passed on WARP and Arc B390.

Could you paste the fixture lines for the case where the high dwords are equal and the low dwords need an unsigned comparison? I'd like to compare that case with what #944 exercises.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118515929 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/944#issuecomment-7118515929). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T00:51:57Z. --- Thanks @lambirou for coordinating #1061 and sharing your independent WARP and RX 9060 XT results. I resolved the merge conflict in `0b45e7f2`, and the LDS qword tests passed on WARP and Arc B390. Could you paste the fixture lines for the case where the high dwords are equal and the low dwords need an unsigned comparison? I'd like to compare that case with what #944 exercises.
thepatrickworld commented 2026-11-24 06:49:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-24T01:05:06Z.


Measured your head 0b45e7f2 on an RX 9070 XT, and tried the independent comparison @R0Y00 asked for in #1061: not only running the fixtures, but injecting the two mutations the tie cases are supposed to catch.

Merge and run. 0b45e7f2 onto 72270be3, no conflict: merge 051db16b, tree 0f76fc71. dev preset, your exact selection, three consecutive runs — the table is one of the three, the other two exited 0 with the same 9/9:

compute_store_aot_guard_read_hardware    Passed 11.34 s
compute_store_aot_ds_route_hardware      Passed  1.69 s
compute_store_aot_lds_private_hardware   Passed 10.33 s
compute_store_aot_lds_qword_hardware     Passed 10.86 s
compute_store_aot_warp                   Passed  4.80 s
compute_store_aot_guard_read_warp        Passed  4.44 s
compute_store_aot_ds_route_warp          Passed  1.00 s
compute_store_aot_lds_private_warp       Passed  4.32 s
compute_store_aot_lds_qword_warp         Passed  4.90 s

on AMD Radeon RX 9070 XT vendor=1002 device=7550, driver 32.0.32029.2010, DXC 1.9.2602.17, Windows 10.0.26200.9711. Your hardware column was a 7900 XTX, so this adds the RDNA 4 side of the same head.

The three checks R0Y00 named. I ran compute_store_check.py draw-lds-qword on the card with the tree clean, then with two mutations in tools/compute_store_aot.py, then clean again:

tree result reading
clean draws pass, 24 mutant rejections (14 on the ten non-returning forms, 10 on the ten returning ones), 0 mismatches your fixtures and mutants hold on this adapter
if op.endswith("_i64") → if True: draw stops at ds_min_u64, mismatches=32, word=0 expected=fffffff0 actual=00000018 the low clause is untouched by that flag, so only the high-word sign can explain it; 32 = the 16 even lanes x the two stored dwords
low-word tie-break clause removed (the same edit as the project's without_low_tiebreak) draw stops at ds_min_u64, mismatches=8, word=34 expected=00000001 actual=00000018 word=34 is lane 17, the low dword of the stored pair (34 = 17x2); 8 = the eight odd lanes 17..31, one stored dword each

The two failure sets are disjoint by lane parity, which pins each to its own clause: the even lanes are the ones where the two high words differ across the sign bit (0x7fffffff against 0x80000000), the odd lanes are the ones where the high words are equal (0x80000000 + 1 on both sides) and only the low dword (0xfffffff0 + lane against 0x18) decides. So the fixture's data does carry both distinctions.

That is coverage, not proof of the ISA: the expected words come from the project's own lds_qword_reference, and no RGA comparison was made. And one limit matters for how far this reads: both mutations abort the draw at ds_min_u64, a non-returning form, so the four returning min/max forms were exercised by the clean run only — the mutation result says the shared comparison path is discriminating, not that each _rtn form was individually mutated.

The third item, the old-value return, is covered by your own mutant in ds_mutants (the LDS_QWORD_RETURNS branch substitutes the post-update pair) and is one of the 24 rejections in the clean row.

Overlap is the shape of the shared program rather than a separate case: v[18:19] is both the destination and the data operand, seeded by ds_write_b64 v5, v[16:17] offset:8. The two hazards show in different words — a destination written from the post-update pair shows in the returned dwords (v18/v19, which the fixture exports and which LDS_QWORD_RETURNS substitutes), while a source clobbered before the compare would show in the LDS pair read back by ds_read_b64. No separate lds_overlap-style case is added for the qword forms; that geometry comes with widening LDS_QWORD_RETURNS.

Scope: only those nine entries; three runs of a deterministic draw, so they repeat the same cases rather than covering more; one physical GPU (9070 XT, RDNA 4), one driver, Windows only; dev preset; no binary mode with LLVM; no RGA disassembly. This is a measurement, not a merge green light — the PR is still a draft and I am not reviewing the rest of it.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118738130 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/944#issuecomment-7118738130). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-24T01:05:06Z. --- Measured your head `0b45e7f2` on an RX 9070 XT, and tried the independent comparison @R0Y00 asked for in #1061: not only running the fixtures, but injecting the two mutations the tie cases are supposed to catch. **Merge and run.** `0b45e7f2` onto `72270be3`, no conflict: merge `051db16b`, tree `0f76fc71`. `dev` preset, your exact selection, three consecutive runs — the table is one of the three, the other two exited 0 with the same 9/9: ``` compute_store_aot_guard_read_hardware Passed 11.34 s compute_store_aot_ds_route_hardware Passed 1.69 s compute_store_aot_lds_private_hardware Passed 10.33 s compute_store_aot_lds_qword_hardware Passed 10.86 s compute_store_aot_warp Passed 4.80 s compute_store_aot_guard_read_warp Passed 4.44 s compute_store_aot_ds_route_warp Passed 1.00 s compute_store_aot_lds_private_warp Passed 4.32 s compute_store_aot_lds_qword_warp Passed 4.90 s ``` on `AMD Radeon RX 9070 XT vendor=1002 device=7550`, driver `32.0.32029.2010`, DXC `1.9.2602.17`, Windows `10.0.26200.9711`. Your hardware column was a 7900 XTX, so this adds the RDNA 4 side of the same head. **The three checks R0Y00 named.** I ran `compute_store_check.py draw-lds-qword` on the card with the tree clean, then with two mutations in `tools/compute_store_aot.py`, then clean again: | tree | result | reading | |---|---|---| | clean | draws pass, 24 mutant rejections (14 on the ten non-returning forms, 10 on the ten returning ones), 0 mismatches | your fixtures and mutants hold on this adapter | | `if op.endswith("_i64")` → `if True:` | draw stops at `ds_min_u64`, `mismatches=32`, `word=0 expected=fffffff0 actual=00000018` | the low clause is untouched by that flag, so only the high-word sign can explain it; 32 = the 16 even lanes x the two stored dwords | | low-word tie-break clause removed (the same edit as the project's `without_low_tiebreak`) | draw stops at `ds_min_u64`, `mismatches=8`, `word=34 expected=00000001 actual=00000018` | `word=34` is lane 17, the low dword of the stored pair (34 = 17x2); 8 = the eight odd lanes 17..31, one stored dword each | The two failure sets are disjoint by lane parity, which pins each to its own clause: the even lanes are the ones where the two high words differ across the sign bit (`0x7fffffff` against `0x80000000`), the odd lanes are the ones where the high words are equal (`0x80000000 + 1` on both sides) and only the low dword (`0xfffffff0 + lane` against `0x18`) decides. So the fixture's data does carry both distinctions. That is coverage, not proof of the ISA: the expected words come from the project's own `lds_qword_reference`, and no RGA comparison was made. And one limit matters for how far this reads: both mutations abort the draw at `ds_min_u64`, a non-returning form, so the four returning min/max forms were exercised by the clean run only — the mutation result says the shared comparison path is discriminating, not that each `_rtn` form was individually mutated. The third item, the old-value return, is covered by your own mutant in `ds_mutants` (the `LDS_QWORD_RETURNS` branch substitutes the post-update pair) and is one of the 24 rejections in the clean row. **Overlap** is the shape of the shared program rather than a separate case: `v[18:19]` is both the destination and the data operand, seeded by `ds_write_b64 v5, v[16:17] offset:8`. The two hazards show in different words — a destination written from the post-update pair shows in the returned dwords (`v18`/`v19`, which the fixture exports and which `LDS_QWORD_RETURNS` substitutes), while a source clobbered before the compare would show in the LDS pair read back by `ds_read_b64`. No separate `lds_overlap`-style case is added for the qword forms; that geometry comes with widening `LDS_QWORD_RETURNS`. Scope: only those nine entries; three runs of a deterministic draw, so they repeat the same cases rather than covering more; one physical GPU (9070 XT, RDNA 4), one driver, Windows only; `dev` preset; no `binary` mode with LLVM; no RGA disassembly. This is a measurement, not a merge green light — the PR is still a draft and I am not reviewing the rest of it. _AI-assisted._
thepatrickworld commented 2026-11-24 06:50:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-24T01:35:13Z.


Follow-up, since this landed: the run above was on a merge I built myself (051db16b, tree 0f76fc71) onto a base that has moved since, so it is not the tree that shipped.

Re-ran the same nine-entry selection on the merged commit 58da41c34c8c4c9b22f6fe526938228dc0c3f191, tree 8256e22ae8e21eb1a2072dcf0293fb56d0be731a (parents 2db96ba + 0b45e7f2), clean tree, twice: 9/9 both times, same entries, timings within a second of the ones above (compute_store_aot_lds_qword_hardware 10.98 s, ..._warp 4.88 s). So the pass result holds on what landed.

The mutation experiment was not re-run on the merged tree — it stands for the code I measured, not for the merge.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119247990 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/944#issuecomment-7119247990). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-24T01:35:13Z. --- Follow-up, since this landed: the run above was on a merge I built myself (`051db16b`, tree `0f76fc71`) onto a base that has moved since, so it is not the tree that shipped. Re-ran the same nine-entry selection on the merged commit `58da41c34c8c4c9b22f6fe526938228dc0c3f191`, tree `8256e22ae8e21eb1a2072dcf0293fb56d0be731a` (parents `2db96ba` + `0b45e7f2`), clean tree, twice: 9/9 both times, same entries, timings within a second of the ones above (`compute_store_aot_lds_qword_hardware` 10.98 s, `..._warp` 4.88 s). So the pass result holds on what landed. The mutation experiment was not re-run on the merged tree — it stands for the code I measured, not for the merge. _AI-assisted._
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!937
No description provided.