Shaders: lower partial-channel typed buffer stores #342

Open
tarcisioads wants to merge 1 commit from upstream-pr/342 into main
tarcisioads commented 2026-11-24 02:24:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-24T02:24:45Z.


Support partial-channel typed buffer_store_format_* (count < 4) in crates/victory-shader/src/emit/lower.rs:

  • Allow count 1..=4 in typed bufferStore.f32 (still rejecting *offen || *offset != 0), padding unused channels up to 4 with undef (f32) and passing (1u8 << count) - 1 as the writeMask.
  • Add unit test partial_channel_typed_buffer_store_lowers covering buffer_store_format_x, buffer_store_format_xy, buffer_store_format_xyz, and buffer_store_format_d16_xyz.

Verification

  • cargo test -p victory-shader (57/57 passed on macOS; Windows dxil.dll validation not run)
  • rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower.rs (ok)
  • cargo xtask policy (ok)
<!-- greyfinch-sync:Marvisak/VIctory:issue:5464899279 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/342). Originally posted by [tarcisioads](https://github.com/tarcisioads) on 2026-11-24T02:24:45Z. --- Support partial-channel typed `buffer_store_format_*` (`count < 4`) in `crates/victory-shader/src/emit/lower.rs`: - Allow `count` 1..=4 in typed `bufferStore.f32` (still rejecting `*offen || *offset != 0`), padding unused channels up to 4 with `undef` (`f32`) and passing `(1u8 << count) - 1` as the `writeMask`. - Add unit test `partial_channel_typed_buffer_store_lowers` covering `buffer_store_format_x`, `buffer_store_format_xy`, `buffer_store_format_xyz`, and `buffer_store_format_d16_xyz`. ### Verification - `cargo test -p victory-shader` (57/57 passed on macOS; Windows `dxil.dll` validation not run) - `rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower.rs` (ok) - `cargo xtask policy` (ok)
r4tedx commented 2026-11-24 06:55:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T03:14:33Z.


Review note: typed stores now pass a partial mask (i8((1u8 << count) - 1)), and the DXIL validator rejects that for a typed UAV. Adding validation to this PR's own fixture (dxil.dll from the Windows SDK) fails with

store on typed uav must write to all four components of the UAV

DXIL's bufferStore on a typed buffer has to write all four components (mask 0xF); the components the instruction does not supply need explicit values. D3D12 only checks the container hash, so a driver may still accept the module, which is why the test passes without the validator. What the hardware writes to the components a typed buffer store leaves out I could not find stated for MTBUF; for image stores the RDNA 2 ISA says the missing components get 0.

From the documents and synthetic tests only; I have no copy of the title and have not run this on console hardware.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120904935 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/342#issuecomment-7120904935). Originally posted by [r4tedx](https://github.com/r4tedx) on 2026-11-24T03:14:33Z. --- Review note: typed stores now pass a partial mask (`i8((1u8 << count) - 1)`), and the DXIL validator rejects that for a typed UAV. Adding validation to this PR's own fixture (dxil.dll from the Windows SDK) fails with ``` store on typed uav must write to all four components of the UAV ``` DXIL's `bufferStore` on a typed buffer has to write all four components (mask `0xF`); the components the instruction does not supply need explicit values. D3D12 only checks the container hash, so a driver may still accept the module, which is why the test passes without the validator. What the hardware writes to the components a typed buffer store leaves out I could not find stated for MTBUF; for image stores the RDNA 2 ISA says the missing components get 0. From the documents and synthetic tests only; I have no copy of the title and have not run this on console hardware.
tarcisioads commented 2026-11-24 12:04:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-24T11:18:55Z.


Rebased onto main (ffe310e) and addressed @r4tedx's DXIL validator feedback in 4950d61:

  • Pad missing channels in typed bufferStore.f32 with 0.0f (self.s.m.f32(0)) and pass 0xF as the writeMask.
  • cargo test -p victory-shader (97 passed, 0 failed on macOS; dxil.dll validation still needs Windows).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7129937998 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/342#issuecomment-7129937998). Originally posted by [tarcisioads](https://github.com/tarcisioads) on 2026-11-24T11:18:55Z. --- Rebased onto `main` (`ffe310e`) and addressed @r4tedx's DXIL validator feedback in `4950d61`: - Pad missing channels in typed `bufferStore.f32` with `0.0f` (`self.s.m.f32(0)`) and pass `0xF` as the `writeMask`. - `cargo test -p victory-shader` (97 passed, 0 failed on macOS; `dxil.dll` validation still needs Windows).
Marvisak commented 2026-11-25 01:07:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:28:44Z.


Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main (conflict in crates/victory-shader/src/emit/lower.rs). It will be reviewed again once it is rebased.

From the earlier needs-work note, still open: evidence for zero-filling the channels a partial typed buffer store does not supply (or refuse those cases), and dxil.dll validation in partial_channel_typed_buffer_store_lowers.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148550902 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/342#issuecomment-7148550902). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:28:44Z. --- <!-- victory-triage v1 head=2915587002e831727952668292dd5c948e49896a verdict=needs-rebase at=2026-11-25T22:17:30Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main` (conflict in `crates/victory-shader/src/emit/lower.rs`). It will be reviewed again once it is rebased. From the earlier needs-work note, still open: evidence for zero-filling the channels a partial typed buffer store does not supply (or refuse those cases), and `dxil.dll` validation in `partial_channel_typed_buffer_store_lowers`. --- _Generated by [Claude Code](https://claude.ai/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/342:upstream-pr/342'
git switch 'upstream-pr/342'

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