Shaders: cube face and multisampled image loads #1956

Open
github-bot wants to merge 2 commits from github-bot/gh-1956 into main AGit
Owner

@⁠RaghavVijayanand on GitHub · 2026-11-25 01:45 UTC · original
RaghavVijayanand:shader/image-cube-msaa → main · +919 −62 · 4 files · 2 commits · open

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.

**@⁠RaghavVijayanand** on GitHub · 2026-11-25 01:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1956) `RaghavVijayanand:shader/image-cube-msaa` → `main` · +919 −62 · 4 files · 2 commits · open 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`.
GFX10 image loads, stores and atomics with dim CUBE address the cube as
the 2D array it is (x, y, face); the translator refused them, accepting
cubes only for samples, gathers and size queries.

Unordered access (stores, atomics, loads of a UAV) now goes through a 2D
array handle: D3D12 has no cube UAVs, so the title's view of a cube for
unordered access is a 2D array, faces as slices.

A shader view is the title's TextureCube, and DXIL loads no texel of a
cube. Annotating the handle as a 2D array does not make the view one:
tried, the load read zeros on the default hardware adapter and only face
0 on WARP (the D3D12 debug layer is not installed here to name the
mismatch). The view is made before any shader reads it, so victory-gpu
cannot choose another for these loads; instead a cube load becomes a
point-filtered sampleLevel at the texel's centre on that face, at the
load's level, through a clamped point immediate sampler. Shortcuts,
noted at `cube_load`: out-of-range texels or levels clamp where the
console reads zeros, a face past 5 reads face 0 (cube arrays, as for
samples), and integer formats cannot be sampled.

New end-to-end tests (emit/image_dim_tests.rs) assemble GFX10 programs,
validate the DXIL with dxil.dll and run on the default hardware adapter
and WARP: image_load of all 96 texels of a 4x4 cube SRV, image_load_mip
of level 1 of a two-level cube (some channels), image_store then
image_load through a 6-slice 2D-array UAV, and image_atomic_add with the
old value returned on an R32_UINT 2D-array UAV. The host harness gains
2D-array UAVs read back slice by slice (the mip test's cube is main's
View::MippedCube).

Swapping the face coordinates in `cube_load` fails both SRV tests;
leaving the UAV handle a cube fails the store test in validation and the
atomic test at pipeline creation. The workspace tests pass (700, 10
ignored) apart from five that fail on main itself here (victory-gpu's
dynamic_slots_are_held_until_released and
lists_share_a_table_and_copies_keep_their_views, victory-shader's two
heap-buffer stride tests and gathers_at_a_level_match_the_hardware), as
do clippy with and without all features.
GFX10 image_load with dim 2D_MSAA or 2D_MSAA_ARRAY takes x, y (and the
slice), then the sample; the translator refused both dimensions.

Such loads now go to DXIL's textureLoad on a Texture2DMS or
Texture2DMSArray handle, the sample in the operand where a level would
be. image_get_resinfo on them gives width, height and layers (the level
operand left undefined, as DXIL takes none for multisampled views).
Shortcut, noted at the load: the console's last address is a fragment,
the sample itself unless the view's FMASK remaps it.

Still refused, each with its reason in the code: image_msaa_load (one
channel of four samples, four data dwords where the decoder gives one,
and which four is not established), stores, atomics and other accesses
to multisampled images, unordered multisampled views (writable MSAA UAVs
are SM 6.7), and the fourth resinfo channel, where DXIL gives the sample
count and the console's value for a multisampled view is not known.

The host test harness gains multisampled R32_FLOAT views: as texels
cannot be copied into a multisampled texture, each sample of each pixel
is drawn as a depth, by a depth-only draw (a hand-built pass-through
vertex shader) scissored to the pixel with only that sample in the
pipeline's sample mask. New tests in emit/image_dim_tests.rs, validated
with dxil.dll and run on the default hardware adapter and WARP: every
sample of every pixel of a 4x4 four-sample texture, every slice and
sample of a two-slice array, and the sizes of both.

With the sample operand replaced by 0 both load tests fail. The
workspace tests pass (703, 10 ignored) apart from the five that fail on
main itself here (see the cube commit), as do clippy with and without
all features.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:50:00 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:19 UTC · original · edited 2026-11-25 16:03 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 02:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1956#issuecomment-7150573515) · edited 2026-11-25 16:03 UTC <!-- 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)_
Author
Owner

@⁠StExpeditus on GitHub · 2026-11-25 08:59 UTC · original

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.

**@⁠StExpeditus** on GitHub · 2026-11-25 08:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1956#issuecomment-7157728593) **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.
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 11:01 UTC · original

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).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 11:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1956#issuecomment-7160496192) ### 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).
github-bot force-pushed github-bot/gh-1956 from 2e7466cf71 to 8d1bdac43d 2026-11-26 11:33:56 +00:00 Compare
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 01:45 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 01:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1956#pullrequestreview-6050344339) · **reviewed** 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.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 03:14 UTC · original · approved these changes

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.

**@⁠catminou4** on GitHub · 2026-11-25 03:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1956#pullrequestreview-6051314402) · **approved these changes** 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.
Author
Owner

@⁠RaghavVijayanand on GitHub · 2026-11-26 11:32 UTC · original

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.

**@⁠RaghavVijayanand** on GitHub · 2026-11-26 11:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1956#issuecomment-7190861852) 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.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1956/head:github-bot/gh-1956'
git switch 'github-bot/gh-1956'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1956'
git switch 'github-bot/gh-1956'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1956'
git switch 'github-bot/gh-1956'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1956'
git switch 'main'
git merge --squash 'github-bot/gh-1956'
git switch 'main'
git merge --ff-only 'github-bot/gh-1956'
git switch 'main'
git merge 'github-bot/gh-1956'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1956
No description provided.