Trim unused trailing dwords from grouped scalar buffer reads #1188

Open
BradRoland wants to merge 2 commits from upstream-pr/1191 into main
BradRoland commented 2026-11-25 23:20:05 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by BradRoland on 2026-11-25T23:20:05Z.


With grouped scalar loads enabled, an s_buffer_load_dwordx4 at byte 328 can request 16 bytes even when the shader consumes only the first 12. This patch records the grouped reads produced by the scalar lowering and, after dead-code elimination, narrows each read through its last live component. A consumer of the fourth word, mapped status, or the whole result retains the original width. A gap between used components stays inside the mask.

For the synthetic shader in #1179, Windows SDK disassembly shows one rawBufferLoad with mask 7 for the three-word case (previously 15) and mask 15 for the four-word control. The scalar-mode outputs and the grouped four-word control have byte-identical DXIL before and after. All 24 dispatches over 336-, 340- and 344-byte views returned the expected words on an RTX 4080 and WARP. The shader library passed 217 tests with 3 ignored, and Clippy passed with all targets and features.

The grouped-load switch stays opt-in. Run 277 reported black water with that switch enabled. This change reduces the access at the suspected boundary and gives testers a smaller change to try. Its effect on the game's water is still unverified. Run notes · Synthetic fixture and original disassembly

<!-- greyfinch-sync:fxceless/victory-fork:issue:6615776939 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1191). Originally posted by [BradRoland](https://github.com/BradRoland) on 2026-11-25T23:20:05Z. --- With grouped scalar loads enabled, an `s_buffer_load_dwordx4` at byte 328 can request 16 bytes even when the shader consumes only the first 12. This patch records the grouped reads produced by the scalar lowering and, after dead-code elimination, narrows each read through its last live component. A consumer of the fourth word, mapped status, or the whole result retains the original width. A gap between used components stays inside the mask. For the synthetic shader in #1179, Windows SDK disassembly shows one `rawBufferLoad` with mask `7` for the three-word case (previously `15`) and mask `15` for the four-word control. The scalar-mode outputs and the grouped four-word control have byte-identical DXIL before and after. All 24 dispatches over 336-, 340- and 344-byte views returned the expected words on an RTX 4080 and WARP. The shader library passed 217 tests with 3 ignored, and Clippy passed with all targets and features. The grouped-load switch stays opt-in. Run 277 reported black water with that switch enabled. This change reduces the access at the suspected boundary and gives testers a smaller change to try. Its effect on the game's water is still unverified. [Run notes](https://github.com/fxceless/victory-fork/blob/b8994e1/README.md#newest-2026-11-25-night-utc) · [Synthetic fixture and original disassembly](https://github.com/fxceless/victory-fork/pull/1179)
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/1191:upstream-pr/1191'
git switch 'upstream-pr/1191'

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/1191'
git switch 'upstream-pr/1191'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1191'
git switch 'upstream-pr/1191'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1191'
git switch 'main'
git merge --squash 'upstream-pr/1191'
git switch 'main'
git merge --ff-only 'upstream-pr/1191'
git switch 'main'
git merge 'upstream-pr/1191'
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
fxceless/victory-fork!1188
No description provided.