tombox-xshader: count ds_read/ds_write b96 and b128 at their full size in ds_reach (follow-up to #257) #380

Open
SchmashinPrunes wants to merge 1 commit from upstream-pr/380 into main
SchmashinPrunes commented 2026-11-25 14:42:48 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by SchmashinPrunes on 2026-11-25T14:42:48Z.


@omonkeyz, this is a follow-up to #257. It fixes the ds_reach sizing I flagged in my #257 review. It does not close the gap from your follow-up comment, sub-version 5 containers whose ISA starts before 0x130. More on that below.

The fix

ds_reach in hlsl/lds64.rs gave ds_read_b96, ds_read_b128, ds_write_b96 and ds_write_b128 a 4-byte element, because none of those names contains 64, _b8 or _b16. Their real sizes are 12 and 16 bytes. Two places use ds_reach:

  • lds64_dwords refuses a shader with a 64-bit LDS atomic when a static LDS offset reaches past the declared LDS size. A 128-bit access was undercounted by 12 bytes, so for example ds_read_b128 at offset 0x1ff4 passed in a shader that declares 8 KiB.
  • The fixture test's static_reach, which decides which header dwords "fit" a shader, was short by the same amount for shaders whose highest access is a 96- or 128-bit one.

Now 96- and 128-bit accesses count at their full size. The other forms are unchanged.

The short-header sub-version 5 containers

I can't help with this part from here. Proving a location needs real console containers, and I don't have any. Your fixture test already prints the offsets that fit each fixture, per sub-version. For the 7 that fail, that list should show whether one location fits all of them, or whether the dword sits at a fixed distance before the ISA (the case scan_recovers_a_planted_dword_and_tells_a_fixed_offset_from_one_counted_back_from_the_isa checks for). The fixture test uses the corrected ds_reach, so rerun it on this branch.

Tests

  • New ds_reach_counts_the_whole_access: ds_read/ds_write b32, b64, b96 and b128 at offset 0x1ff0 must reach 0x1ff0 + 4, 8, 12 and 16 bytes. Each case first checks that the encoding decodes to the expected mnemonic.
  • Without the ds_reach change, the b96/b128 cases fail.

Results (Windows 11, WARP):

run result
tombox-xshader --lib 150 passed, 5 ignored, including the new test
without the ds_reach change the new test fails at the first wide form: ds_write_b96 at 0x1ff0 reaches 8180, want 8188
full tombox-xshader suite 34 suites ok, tests/exec.rs 189/189

The PR gate is clean.

🤖 Generated with Claude Code

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:5493528632 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/380). Originally posted by [SchmashinPrunes](https://github.com/SchmashinPrunes) on 2026-11-25T14:42:48Z. --- @omonkeyz, this is a follow-up to #257. It fixes the `ds_reach` sizing I flagged in my #257 review. It does **not** close the gap from your follow-up comment, sub-version 5 containers whose ISA starts before 0x130. More on that below. ### The fix `ds_reach` in `hlsl/lds64.rs` gave `ds_read_b96`, `ds_read_b128`, `ds_write_b96` and `ds_write_b128` a 4-byte element, because none of those names contains `64`, `_b8` or `_b16`. Their real sizes are 12 and 16 bytes. Two places use `ds_reach`: - `lds64_dwords` refuses a shader with a 64-bit LDS atomic when a static LDS offset reaches past the declared LDS size. A 128-bit access was undercounted by 12 bytes, so for example `ds_read_b128` at offset 0x1ff4 passed in a shader that declares 8 KiB. - The fixture test's `static_reach`, which decides which header dwords "fit" a shader, was short by the same amount for shaders whose highest access is a 96- or 128-bit one. Now 96- and 128-bit accesses count at their full size. The other forms are unchanged. ### The short-header sub-version 5 containers I can't help with this part from here. Proving a location needs real console containers, and I don't have any. Your fixture test already prints the offsets that fit each fixture, per sub-version. For the 7 that fail, that list should show whether one location fits all of them, or whether the dword sits at a fixed distance before the ISA (the case `scan_recovers_a_planted_dword_and_tells_a_fixed_offset_from_one_counted_back_from_the_isa` checks for). The fixture test uses the corrected `ds_reach`, so rerun it on this branch. ### Tests - New `ds_reach_counts_the_whole_access`: `ds_read`/`ds_write` b32, b64, b96 and b128 at offset 0x1ff0 must reach 0x1ff0 + 4, 8, 12 and 16 bytes. Each case first checks that the encoding decodes to the expected mnemonic. - Without the `ds_reach` change, the b96/b128 cases fail. **Results** (Windows 11, WARP): | run | result | |---|---| | `tombox-xshader --lib` | 150 passed, 5 ignored, including the new test | | without the `ds_reach` change | the new test fails at the first wide form: `ds_write_b96` at 0x1ff0 reaches 8180, want 8188 | | full `tombox-xshader` suite | 34 suites ok, `tests/exec.rs` 189/189 | The PR gate is clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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/380:upstream-pr/380'
git switch 'upstream-pr/380'

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/380'
git switch 'upstream-pr/380'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/380'
git switch 'upstream-pr/380'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/380'
git switch 'main'
git merge --squash 'upstream-pr/380'
git switch 'main'
git merge --ff-only 'upstream-pr/380'
git switch 'main'
git merge 'upstream-pr/380'
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
omonkeyz/xbox-emulator!380
No description provided.