Test scalar-buffer alignment across a dword carry #3919

Open
akimfomin wants to merge 1 commit from upstream-pr/3919 into main
akimfomin commented 2026-11-30 11:36:27 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by akimfomin on 2026-11-30T11:36:27Z.


What it tests

Adds a generated Windows WARP regression for s_buffer_load_dword after #3894 by @eleboucher. It exercises five SGPR offsets plus immediate 1, including 3 + 1 and 7 + 1 crossing a dword boundary, with both the constant-buffer and raw descriptor-twin translations.

This is stacked on the exact #3894 head 844200e9. Only the test commit is new to that branch. Please keep this draft until #3894 lands and the series is checked against main.

Validation

  • New test passed all ten generated WARP dispatches on the exact upstream base.
  • Existing raw-twin test passed on the same build.
  • No game, shader dumps, or local assets are needed.

@eleboucher thanks for offering to review and verify the fixture on your 4070 Ti SUPER. Windows WARP command:

cargo test --locked -p victory-shader scalar_buffer_load_aligns_after_adding_dynamic_and_immediate_offsets
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5564481594 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3919). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-30T11:36:27Z. --- ## What it tests Adds a generated Windows WARP regression for `s_buffer_load_dword` after #3894 by @eleboucher. It exercises five SGPR offsets plus immediate 1, including `3 + 1` and `7 + 1` crossing a dword boundary, with both the constant-buffer and raw descriptor-twin translations. This is stacked on the exact #3894 head `844200e9`. Only the test commit is new to that branch. Please keep this draft until #3894 lands and the series is checked against main. ## Validation - New test passed all ten generated WARP dispatches on the exact upstream base. - Existing raw-twin test passed on the same build. - No game, shader dumps, or local assets are needed. @eleboucher thanks for offering to review and verify the fixture on your 4070 Ti SUPER. Windows WARP command: ``` cargo test --locked -p victory-shader scalar_buffer_load_aligns_after_adding_dynamic_and_immediate_offsets ```
eleboucher commented 2026-11-30 11:52:40 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by eleboucher on 2026-11-30T11:52:40Z.

Review: COMMENTED


Ran it on the RTX 4070 Ti SUPER box (Windows WARP), with the test binary cross-built from the PR head 039b3e0d:

  • On 039b3e0d (#3894 + this test): scalar_buffer_load_aligns_after_adding_dynamic_and_immediate_offsets, table_constant_buffers_read_as_raw_bytes_through_their_twins and scalar_load_clears_the_two_low_address_bits all pass.
  • Negative control: the same test commit cherry-picked onto plain main 41adb551 (without #3894) also passes.

So as written, the fixture does not distinguish the fixed lowering from the old one. Two likely reasons:

  • WARP, like NVIDIA hardware, tolerates the misaligned raw load and returns the dword at the address rounded down. The faulting case only showed up under Aftermath shader error reporting on real hardware.
  • On the constant-buffer route the old lowering already selected the right component, since a CBV is indexed by dword.

The review of the test itself is fine: the offset reaches the program as a root constant per dispatch, and want = data[(s0 + imm) / 4] matches the ISA rule (offset and SOFFSET added, then the two LSBs ignored). To make it a regression test, it needs to observe the address rather than the data: assert on the emitted IR that the offset into rawBufferLoad is masked, as scalar_load_clears_the_two_low_address_bits does, or arrange that an unmasked address reads a different dword on WARP (if WARP's raw-buffer path does not round, a misaligned Load would show it; I did not verify that).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6111659544 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3919#pullrequestreview-6111659544). Originally posted by [eleboucher](https://github.com/eleboucher) on 2026-11-30T11:52:40Z. **Review:** COMMENTED --- Ran it on the RTX 4070 Ti SUPER box (Windows WARP), with the test binary cross-built from the PR head `039b3e0d`: - On `039b3e0d` (#3894 + this test): `scalar_buffer_load_aligns_after_adding_dynamic_and_immediate_offsets`, `table_constant_buffers_read_as_raw_bytes_through_their_twins` and `scalar_load_clears_the_two_low_address_bits` all pass. - Negative control: the same test commit cherry-picked onto plain `main` 41adb551 (without #3894) **also passes**. So as written, the fixture does not distinguish the fixed lowering from the old one. Two likely reasons: - WARP, like NVIDIA hardware, tolerates the misaligned raw load and returns the dword at the address rounded down. The faulting case only showed up under Aftermath shader error reporting on real hardware. - On the constant-buffer route the old lowering already selected the right component, since a CBV is indexed by dword. The review of the test itself is fine: the offset reaches the program as a root constant per dispatch, and `want = data[(s0 + imm) / 4]` matches the ISA rule (offset and SOFFSET added, then the two LSBs ignored). To make it a regression test, it needs to observe the address rather than the data: assert on the emitted IR that the offset into `rawBufferLoad` is masked, as `scalar_load_clears_the_two_low_address_bits` does, or arrange that an unmasked address reads a different dword on WARP (if WARP's raw-buffer path does not round, a misaligned `Load` would show it; I did not verify that).
akimfomin commented 2026-11-30 12:04:46 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by akimfomin on 2026-11-30T12:04:46Z.


@eleboucher Thanks for checking the negative control. I agree that the WARP result verifies the returned values but cannot show whether the compiler passed an unaligned byte address to the raw load. I have added a generated lowering check that evaluates that exact operand over the five offsets, using the existing address-value test helper. I’m verifying that it passes on #3894 and fails at the intended address assertion on plain main before updating the draft.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7277914099 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3919#issuecomment-7277914099). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-30T12:04:46Z. --- @eleboucher Thanks for checking the negative control. I agree that the WARP result verifies the returned values but cannot show whether the compiler passed an unaligned byte address to the raw load. I have added a generated lowering check that evaluates that exact operand over the five offsets, using the existing address-value test helper. I’m verifying that it passes on #3894 and fails at the intended address assertion on plain main before updating the draft.
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/3919:upstream-pr/3919'
git switch 'upstream-pr/3919'

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/3919'
git switch 'upstream-pr/3919'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3919'
git switch 'upstream-pr/3919'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3919'
git switch 'main'
git merge --squash 'upstream-pr/3919'
git switch 'main'
git merge --ff-only 'upstream-pr/3919'
git switch 'main'
git merge 'upstream-pr/3919'
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
trustno1-coder/VIctory-NVIDIA!3919
No description provided.