shader: lower image stores of fewer than four channels #94

Manually merged
github merged 4 commits from github-bot/gh-94 into main 2026-11-26 17:09:33 +00:00 AGit
Owner

@⁠Olima34 on GitHub · 2026-11-26 14:29 UTC · original
Olima34:fix/shader-image-store-dmask → main · +163 −8 · 4 files · 4 commits · merged 2026-11-26 17:05 UTC

What this changes

image_store with a dmask other than 0xF was refused ("an image store of some channels"). As for typed buffer stores (#56), GFX11 and older store 0 in the channels the mask leaves out (LLVM 88421ea "[AMDGPU] Trim zero components from buffer and image stores", Mesa 4a6ee2c4833), so the store now writes the whole texel: the data holds the enabled channels in turn (two per VGPR with d16), and the others are 0. A dmask of 0, whose behaviour is undocumented, is still refused. docs/native-host.md gets the image counterpart of the "Typed buffer stores" note.

Tests: hand-assembled stores with dmask 0x1, 0x3 and 0x5 now translate (image_stores_of_some_channels_lower), and a Windows value test reads the UAV back (image_stores_of_some_channels_zero_the_others).

How it was tested

  • cargo test -p victory-shader and arm64 cargo test --workspace (value probes run only in the Windows CI)
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, also with --all-features
  • cargo xtask policy
  • Ran the game: not done, no copy of it here

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md
  • New diagnostics are behind a VICTORY_* variable and documented (none added)
**@⁠Olima34** on GitHub · 2026-11-26 14:29 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/94) `Olima34:fix/shader-image-store-dmask` → `main` · +163 −8 · 4 files · 4 commits · merged 2026-11-26 17:05 UTC ## What this changes `image_store` with a `dmask` other than `0xF` was refused ("an image store of some channels"). As for typed buffer stores (#56), GFX11 and older store 0 in the channels the mask leaves out (LLVM 88421ea "[AMDGPU] Trim zero components from buffer and image stores", Mesa 4a6ee2c4833), so the store now writes the whole texel: the data holds the enabled channels in turn (two per VGPR with `d16`), and the others are 0. A `dmask` of 0, whose behaviour is undocumented, is still refused. docs/native-host.md gets the image counterpart of the "Typed buffer stores" note. Tests: hand-assembled stores with `dmask` 0x1, 0x3 and 0x5 now translate (`image_stores_of_some_channels_lower`), and a Windows value test reads the UAV back (`image_stores_of_some_channels_zero_the_others`). ## How it was tested - [x] `cargo test -p victory-shader` and arm64 `cargo test --workspace` (value probes run only in the Windows CI) - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`, also with `--all-features` - [x] `cargo xtask policy` - [ ] Ran the game: not done, no copy of it here ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none added)
image_store with a dmask other than 0xF was refused ("an image store of
some channels"). On GFX11 and older the hardware stores 0 in the
channels dmask leaves out (LLVM 88421ea "[AMDGPU] Trim zero components
from buffer and image stores"; Mesa 4a6ee2c4833 "aco: shrink buffer
stores with undef/zero components"), as it does for typed buffer
stores (#56). The data VGPRs hold the enabled channels in turn (two per
VGPR with d16), the others are stored as 0 and the DXIL write mask stays
0xF. A dmask of 0, whose effect is not documented, stays refused.

Tests: a translation test (dmask 0x1, 0x3, 0x5, 0xE, 0xF and d16 0x5;
dmask 0 refused) that fails without the change, through the typed store
helper generalised to an 8-dword descriptor, and a Windows UAV readback
(each row stored whole, then with dmask 0x1, 0x3, 0x5, 0xE or 0x8).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:45:51 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 14:54 UTC · original · requested changes

Thanks, this is the image-store version we'll keep. One thing: docs/native-host.md says "This is not a guess", but the LLVM/Mesa evidence only shows zero-fill of missing trailing components. Please narrow that to prefix dmasks and mark gapped masks (e.g. 0x5) as a guess.

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 14:54 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/94#pullrequestreview-6076251699) · **requested changes** Thanks, this is the image-store version we'll keep. One thing: docs/native-host.md says "This is not a guess", but the LLVM/Mesa evidence only shows zero-fill of missing trailing components. Please narrow that to prefix dmasks and mark gapped masks (e.g. 0x5) as a guess.
Review: LLVM 88421ea and Mesa 4a6ee2c4833 show zero-fill of missing trailing components only, so the docs and the comment now call prefix dmasks (0x1, 0x3, 0x7) established and gapped ones (0x5, or without red) a guess. No code change.
Author
Owner

@⁠Olima34 on GitHub · 2026-11-26 15:01 UTC · original

Done: the docs and the code comment now call prefix dmasks (0x1, 0x3, 0x7) established, by the zero-fill of missing trailing components in LLVM 88421ea and Mesa 4a6ee2c4833, and mark gapped masks (0x5, or one without red) as a guess. No code change.

**@⁠Olima34** on GitHub · 2026-11-26 15:01 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/94#issuecomment-7195668387) Done: the docs and the code comment now call prefix dmasks (0x1, 0x3, 0x7) established, by the zero-fill of missing trailing components in LLVM 88421ea and Mesa 4a6ee2c4833, and mark gapped masks (0x5, or one without red) as a guess. No code change.
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 16:03 UTC · original · review (dismissed)

The prefix dmasks are now documented as established and gapped masks as a guess, in the docs and the code comment. CI is green. Approving.

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 16:03 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/94#pullrequestreview-6077224088) · **review (dismissed)** The prefix dmasks are now documented as established and gapped masks as a guess, in the docs and the code comment. CI is green. Approving.
# Conflicts:
#	crates/victory-shader/src/emit/gfx_refusal_tests.rs
github manually merged commit 89df389567 into main 2026-11-26 17:09:33 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.