Shaders: image stores of some channels, to mip 0, and to integer views #1953

Open
RaghavVijayanand wants to merge 4 commits from upstream-pr/1955 into main
RaghavVijayanand commented 2026-11-25 01:45:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RaghavVijayanand on 2026-11-25T01:45:13Z.


Three image-store refusals in the translator. Each is its own commit, and each builds and passes tests.

  • Stores of some channels (dmask != 0xF): the data VGPRs hold only the enabled channels, in channel order (d16: two per VGPR). Each dword now goes to its channel, and the channels left out are written as 0. That behavior follows the AMD ISA guides' DMASK description and LLVM's handling; it has not been checked on console hardware. The host store keeps a full 0xF mask, because dxil.dll rejects partial masks on typed UAV stores.
  • image_store_mip: a level that is a constant 0 stores to the view's own level. A non-zero or computed level is still refused, because it would need a view per level.
  • Integer stores: the view's format is in the descriptor, which is only read at run time. When an image atomic in the same program uses the same descriptor, the view must be R32_UINT or R32_SINT, so stores to it now use textureStore.i32. Integer views with no atomic still get a float store; that is documented.
  • The same handle-cache key fix as #1953, which is that fix alone, with a test that fails without it. It is needed here so that atomics (U32) and stores (F32x4) on one descriptor get their own handles. Whichever of the two merges second has a trivial conflict on those lines.

Tests: the new emit/image_store_tests.rs (6 tests) covers:

  • all 15 dmasks on RGBA32_FLOAT, and 7 d16 dmasks
  • RGBA32_UINT and R32_UINT views with denormal, NaN and -0 bit patterns
  • mip level 0 accepted, while level 1 and computed levels are refused
  • an atomic plus a store on R32_UINT

Each program is validated with dxil.dll and run on the default hardware adapter and WARP. Each fix was broken on purpose to confirm a test fails. The test host gains View::Uint4TextureUav (RGBA32_UINT) beside main's Uint2TextureUav. The integer-store detection also treats main's 64-bit atomics (R32G32_UINT) as proof of an integer view.

This PR and #1956 (cube/MSAA) both touch image() in emit/lower.rs, so merging both needs a small manual merge.

Rebased onto current main (940d32f). On this machine, 5 tests fail on main itself, with or without this change: descriptor::host::tests::dynamic_slots_are_held_until_released, memory::tests::lists_share_a_table_and_copies_keep_their_views, the two stride_tests::a_heap_buffer_read_* tests, and synthetic_tests::gathers_at_a_level_match_the_hardware. Everything else passes, and clippy passes with -D warnings, with and without --all-features.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6595221214 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1955). Originally posted by [RaghavVijayanand](https://github.com/RaghavVijayanand) on 2026-11-25T01:45:13Z. --- Three image-store refusals in the translator. Each is its own commit, and each builds and passes tests. - **Stores of some channels** (dmask != 0xF): the data VGPRs hold only the enabled channels, in channel order (d16: two per VGPR). Each dword now goes to its channel, and the channels left out are written as 0. That behavior follows the AMD ISA guides' DMASK description and LLVM's handling; it has not been checked on console hardware. The host store keeps a full 0xF mask, because dxil.dll rejects partial masks on typed UAV stores. - **`image_store_mip`**: a level that is a constant 0 stores to the view's own level. A non-zero or computed level is still refused, because it would need a view per level. - **Integer stores**: the view's format is in the descriptor, which is only read at run time. When an image atomic in the same program uses the same descriptor, the view must be R32_UINT or R32_SINT, so stores to it now use `textureStore.i32`. Integer views with no atomic still get a float store; that is documented. - The same handle-cache key fix as #1953, which is that fix alone, with a test that fails without it. It is needed here so that atomics (U32) and stores (F32x4) on one descriptor get their own handles. Whichever of the two merges second has a trivial conflict on those lines. **Tests:** the new `emit/image_store_tests.rs` (6 tests) covers: - all 15 dmasks on RGBA32_FLOAT, and 7 d16 dmasks - RGBA32_UINT and R32_UINT views with denormal, NaN and -0 bit patterns - mip level 0 accepted, while level 1 and computed levels are refused - an atomic plus a store on R32_UINT Each program is validated with dxil.dll and run on the default hardware adapter and WARP. Each fix was broken on purpose to confirm a test fails. The test host gains `View::Uint4TextureUav` (RGBA32_UINT) beside main's `Uint2TextureUav`. The integer-store detection also treats main's 64-bit atomics (R32G32_UINT) as proof of an integer view. This PR and #1956 (cube/MSAA) both touch `image()` in `emit/lower.rs`, so merging both needs a small manual merge. **Rebased onto current main (940d32f).** On this machine, 5 tests fail on main itself, with or without this change: `descriptor::host::tests::dynamic_slots_are_held_until_released`, `memory::tests::lists_share_a_table_and_copies_keep_their_views`, the two `stride_tests::a_heap_buffer_read_*` tests, and `synthetic_tests::gathers_at_a_level_match_the_hardware`. Everything else passes, and clippy passes with `-D warnings`, with and without `--all-features`.
copilot-pull-request-reviewer[bot commented 2026-11-25 02:05:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T01:45:26Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:Marvisak/VIctory:review:6050343383 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1955#pullrequestreview-6050343383). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-25T01:45:26Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Marvisak commented 2026-11-25 03:03:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:19:03Z.


Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge candidate) was for an older state of main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150570556 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1955#issuecomment-7150570556). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:19:03Z. --- <!-- victory-triage v1 head=6abd8ff64c04b122d1ce0db789cf64602e9efaf2 verdict=needs-rebase at=2026-11-25T16:14:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-shader/src/emit/lower.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (merge candidate) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
catminou4 commented 2026-11-25 04:06:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:14:09Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. Image stores of some channels, to mip 0, and to integer views — partial-channel store lowering.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051314312 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1955#pullrequestreview-6051314312). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T03:14:09Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. Image stores of some channels, to mip 0, and to integer views — partial-channel store lowering.
StExpeditus commented 2026-11-25 05:06:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T04:23:40Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 6abd8ff. cargo test --workspace --locked --no-fail-fast -> all green: 0 passed, 0 ignored, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152802174 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1955#issuecomment-7152802174). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T04:23:40Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `6abd8ff`. `cargo test --workspace --locked --no-fail-fast` -> **all green**: 0 passed, 0 ignored, 0 failed.
StExpeditus commented 2026-11-25 09:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:00:47Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 6abd8ff. cargo test --workspace --locked --no-fail-fast -> 702 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157757206 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1955#issuecomment-7157757206). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T09:00:47Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `6abd8ff`. `cargo test --workspace --locked --no-fail-fast` -> 702 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.
sinan-cmyk commented 2026-11-25 11:05:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T11:05:21Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head 6abd8ff6 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160570354 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1955#issuecomment-7160570354). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T11:05:21Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 6abd8ff6 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
RaghavVijayanand commented 2026-11-26 11:04:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RaghavVijayanand on 2026-11-26T10:42:39Z.


Rebased onto main 63bcca4. Two adjustments for what main gained since: the test harness's new zeroing of texture UAVs passes the texture's format to footprint_as (which this branch made format-aware), and the handle caches main added (entry block, join block) are keyed on both property dwords, as in #1953. Each commit builds. On an RTX 5060 Laptop: the image store/atomic tests pass (7), clippy is clean, and the rest of victory-shader passes except the three NVIDIA 1M-view-heap-cap tests that fail on unmodified main there too (stride_tests x2, gathers_at_a_level_match_the_hardware).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7189729582 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1955#issuecomment-7189729582). Originally posted by [RaghavVijayanand](https://github.com/RaghavVijayanand) on 2026-11-26T10:42:39Z. --- Rebased onto `main` 63bcca4. Two adjustments for what `main` gained since: the test harness's new zeroing of texture UAVs passes the texture's format to `footprint_as` (which this branch made format-aware), and the handle caches `main` added (entry block, join block) are keyed on both property dwords, as in #1953. Each commit builds. On an RTX 5060 Laptop: the image store/atomic tests pass (7), clippy is clean, and the rest of `victory-shader` passes except the three NVIDIA 1M-view-heap-cap tests that fail on unmodified `main` there too (`stride_tests` x2, `gathers_at_a_level_match_the_hardware`).
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/1955:upstream-pr/1955'
git switch 'upstream-pr/1955'

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