Shaders: cube face and multisampled image loads #1954

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

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


The translator refused image accesses on cube and MSAA dimensions except for sampling ("an image dimension (cube loads or MSAA)"). Two commits.

Cube (dim 3)

  • UAV stores, atomics and loads, and image_get_resinfo: the handle is now a 2D array (kind 7). D3D12 has no cube UAVs, so a UAV over a cube is a 2D-array view with the faces as slices, which matches GFX10's (x, y, face) addressing. Before, resinfo used an invalid cube-UAV kind.
  • SRV loads: annotating a TextureCube SRV handle as a 2D array does not work in practice. The hardware adapter read zeros and WARP read only face 0. victory-gpu also can't make a per-shader 2D-array view, because host views come from the title's view descriptions.
    • So the load becomes a point-filtered sampleLevel at the texel's centre on that face, through a new clamped point immediate sampler.
    • Known limits, documented in cube_load: out-of-range reads clamp instead of returning zero, cube arrays are not handled, and integer formats can't be sampled.

MSAA (dims 6 and 7)

  • image_load becomes textureLoad on Texture2DMS (kind 3) or Texture2DMSArray (kind 8), with the sample index as the sample operand. The console's last address is the fragment index, which equals the sample unless FMASK remaps it; this is noted in the code.
  • image_get_resinfo returns width, height and layers.
  • Still refused, with reasons in the code: image_msaa_load, MSAA stores, atomics, sampling and image_load_mip, and the 4th resinfo channel.

Tests: the new emit/image_dim_tests.rs (7 tests) covers:

  • all 96 texels of a cube
  • a cube mip level with partial channels
  • store and load through a 6-slice UAV
  • image_atomic_add on a 2D-array UAV
  • every sample of a 4x MSAA texture and of a 2-slice MSAA array, filled by depth-only draws with per-sample masks
  • resinfo on both MSAA kinds

Each program is validated with dxil.dll and run on the default hardware adapter and WARP. Swapping the face coordinates, leaving the UAV handle as a cube, or zeroing the sample operand each makes tests fail. The cube mip test uses main's View::MippedCube; the test host gains only 2D-array UAVs and the multisampled depth view.

Not covered: main's newer descriptor-as-data path (descriptor_data in lower.rs) still refuses cube and MSAA ("an image dimension (cube or MSAA)"). This PR does not touch it.

This PR and #1955 (image stores) 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:5483513583 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1956). Originally posted by [RaghavVijayanand](https://github.com/RaghavVijayanand) on 2026-11-25T01:45:16Z. --- The translator refused image accesses on cube and MSAA dimensions except for sampling ("an image dimension (cube loads or MSAA)"). Two commits. **Cube (dim 3)** - **UAV stores, atomics and loads, and `image_get_resinfo`:** the handle is now a 2D array (kind 7). D3D12 has no cube UAVs, so a UAV over a cube is a 2D-array view with the faces as slices, which matches GFX10's (x, y, face) addressing. Before, resinfo used an invalid cube-UAV kind. - **SRV loads:** annotating a TextureCube SRV handle as a 2D array does not work in practice. The hardware adapter read zeros and WARP read only face 0. victory-gpu also can't make a per-shader 2D-array view, because host views come from the title's view descriptions. - So the load becomes a point-filtered `sampleLevel` at the texel's centre on that face, through a new clamped point immediate sampler. - Known limits, documented in `cube_load`: out-of-range reads clamp instead of returning zero, cube arrays are not handled, and integer formats can't be sampled. **MSAA (dims 6 and 7)** - `image_load` becomes textureLoad on Texture2DMS (kind 3) or Texture2DMSArray (kind 8), with the sample index as the sample operand. The console's last address is the fragment index, which equals the sample unless FMASK remaps it; this is noted in the code. - `image_get_resinfo` returns width, height and layers. - Still refused, with reasons in the code: `image_msaa_load`, MSAA stores, atomics, sampling and `image_load_mip`, and the 4th resinfo channel. **Tests:** the new `emit/image_dim_tests.rs` (7 tests) covers: - all 96 texels of a cube - a cube mip level with partial channels - store and load through a 6-slice UAV - `image_atomic_add` on a 2D-array UAV - every sample of a 4x MSAA texture and of a 2-slice MSAA array, filled by depth-only draws with per-sample masks - resinfo on both MSAA kinds Each program is validated with dxil.dll and run on the default hardware adapter and WARP. Swapping the face coordinates, leaving the UAV handle as a cube, or zeroing the sample operand each makes tests fail. The cube mip test uses main's `View::MippedCube`; the test host gains only 2D-array UAVs and the multisampled depth view. Not covered: main's newer descriptor-as-data path (`descriptor_data` in `lower.rs`) still refuses cube and MSAA ("an image dimension (cube or MSAA)"). This PR does not touch it. This PR and #1955 (image stores) 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 01:45:31 +00:00 (Migrated from github.com)

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

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:6050344339 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1956#pullrequestreview-6050344339). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T01:45:31Z. **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:11Z.


Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-shader/src/emit/host.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:7150573515 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1956#issuecomment-7150573515). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:19:11Z. --- <!-- victory-triage v1 head=2e7466cf710d3455048959b2ad0144a8ec38bf1d verdict=needs-rebase at=2026-11-25T16:15:00Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-shader/src/emit/host.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 03:14:10 +00:00 (Migrated from github.com)

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

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. Cube face and multisampled image loads — texture-dimension coverage for cube/MSAA paths.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051314402 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1956#pullrequestreview-6051314402). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T03:14:10Z. **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. Cube face and multisampled image loads — texture-dimension coverage for cube/MSAA paths.
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:38Z.


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

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

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T08:59:26Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 2e7466c. cargo test --workspace --locked --no-fail-fast -> 703 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:7157728593 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1956#issuecomment-7157728593). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T08:59:26Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `2e7466c`. `cargo test --workspace --locked --no-fail-fast` -> 703 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:47 +00:00 (Migrated from github.com)

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


Offline measurement on a retail dump

Result: no count change against main.

I merged head 2e7466cf 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:7160496192 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1956#issuecomment-7160496192). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T11:01:59Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 2e7466cf 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 12:05:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RaghavVijayanand on 2026-11-26T11:32:37Z.


Rebased onto main 63bcca4. Two adjustments for what main gained since:

  • Zero-fill: the test harness's new zero-fill of texture UAVs now covers every array slice of the cube and array UAVs this branch adds (one copy per slice, then a single transition).
  • WARP lock: the multisampled-depth view makes its draw root signature before dispatch takes main's WARP lock. root_signature_for takes the lock as well, and it is not re-entrant, so multisampled_array_loads_read_the_slice_and_sample_asked_for hung on WARP.

Each commit builds. On an RTX 5060 Laptop: the cube, multisampled, image store/atomic and parallel_warp_pipelines_and_draws tests pass (11), on hardware and WARP. Clippy is clean.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7190861852 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1956#issuecomment-7190861852). Originally posted by [RaghavVijayanand](https://github.com/RaghavVijayanand) on 2026-11-26T11:32:37Z. --- Rebased onto `main` 63bcca4. Two adjustments for what `main` gained since: - **Zero-fill:** the test harness's new zero-fill of texture UAVs now covers every array slice of the cube and array UAVs this branch adds (one copy per slice, then a single transition). - **WARP lock:** the multisampled-depth view makes its draw root signature before `dispatch` takes `main`'s WARP lock. `root_signature_for` takes the lock as well, and it is not re-entrant, so `multisampled_array_loads_read_the_slice_and_sample_asked_for` hung on WARP. Each commit builds. On an RTX 5060 Laptop: the cube, multisampled, image store/atomic and `parallel_warp_pipelines_and_draws` tests pass (11), on hardware and WARP. Clippy is clean.
oddmaniv commented 2026-11-27 03:30:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oddmaniv on 2026-11-27T03:30:10Z.


Independent verification of the PR author's image-dimension tests at 8d1bdac43da2eac3c3efd0eb58bd76f1063635c9.

cargo test --locked -p victory-shader --lib image_dim_tests -- --nocapture

Tree Result
Unmodified PR head 7 passed, 0 failed, 0 ignored; native exit 0
PR patch applied to pinned main 7 passed, 0 failed, 0 ignored; native exit 0

Main baseline pin: 63bcca43c6a00a758510398fa43096ce7e4f7df0.
Baseline limitation: The selected PR-added test is absent on unmodified main; a zero-match baseline would not be a pass.

Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits.
This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed.

AI-assisted verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7209039153 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1956#issuecomment-7209039153). Originally posted by [oddmaniv](https://github.com/oddmaniv) on 2026-11-27T03:30:10Z. --- Independent verification of the PR author's image-dimension tests at `8d1bdac43da2eac3c3efd0eb58bd76f1063635c9`. `cargo test --locked -p victory-shader --lib image_dim_tests -- --nocapture` | Tree | Result | | --- | --- | | Unmodified PR head | 7 passed, 0 failed, 0 ignored; native exit 0 | | PR patch applied to pinned main | 7 passed, 0 failed, 0 ignored; native exit 0 | Main baseline pin: `63bcca43c6a00a758510398fa43096ce7e4f7df0`. Baseline limitation: The selected PR-added test is absent on unmodified main; a zero-match baseline would not be a pass. Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits. This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed. AI-assisted verification.
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/1956:upstream-pr/1956'
git switch 'upstream-pr/1956'

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