Shaders: return 0 for unused depth and height channels in image_get_resinfo #1936

Closed
ashrafsdrop wants to merge 1 commit from upstream-pr/1938 into main
ashrafsdrop commented 2026-11-25 01:19:45 +00:00 (Migrated from github.com)

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


Resolves VIC-BT-038 from #1249:

Summary

  1. Unused Dimension Return Values:
    In \crates/victory-shader/src/emit/lower.rs, \image_get_resinfo\ lowering previously returned \one\ (1) for channels missing from the resource dimension (!present[ch]):

    • Per RDNA2 ISA specifications, non-present spatial dimensions (e.g. depth on 1D/2D views, or height on 1D views) query as 0, not 1.
    • For UAV queries, \ch == 3\ (mip levels) correctly retains 1 (representing a single mip level in DXIL).
    • Missing channels (!present[ch]) now evaluate to \self.s.m.i32(0).
  2. Tests:
    Added unit test
    esinfo_returns_zero_for_unused_depth_channel_on_2d_texture\ in \lower.rs\ asserting successful lowering of \image_get_resinfo\ with all four channels (\dmask: 0xF) on a 2D texture.

Verification

  • \cargo test -p victory-shader: 247 passed, 0 failed.
  • \cargo clippy -p victory-shader --all-targets --all-features -- -D warnings: clean, 0 warnings.
  • \cargo run -p xtask -- policy: 182 files ok.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6594906010 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1938). Originally posted by [ashrafsdrop](https://github.com/ashrafsdrop) on 2026-11-25T01:19:45Z. --- Resolves VIC-BT-038 from #1249: ### Summary 1. **Unused Dimension Return Values**: In \crates/victory-shader/src/emit/lower.rs\, \image_get_resinfo\ lowering previously returned \one\ (1) for channels missing from the resource dimension (\!present[ch]\): - Per RDNA2 ISA specifications, non-present spatial dimensions (e.g. depth on 1D/2D views, or height on 1D views) query as 0, not 1. - For UAV queries, \ch == 3\ (mip levels) correctly retains 1 (representing a single mip level in DXIL). - Missing channels (\!present[ch]\) now evaluate to \self.s.m.i32(0)\. 2. **Tests**: Added unit test \ esinfo_returns_zero_for_unused_depth_channel_on_2d_texture\ in \lower.rs\ asserting successful lowering of \image_get_resinfo\ with all four channels (\dmask: 0xF\) on a 2D texture. ### Verification - \cargo test -p victory-shader\: 247 passed, 0 failed. - \cargo clippy -p victory-shader --all-targets --all-features -- -D warnings\: clean, 0 warnings. - \cargo run -p xtask -- policy\: 182 files ok.
upipibi commented 2026-11-25 02:06:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T01:25:53Z.


Overlap note, from reading the diffs (not run): #1313 (EatCodeSleep2, opened a day earlier for the same finding, VIC-BT-038 in #1249) makes the same change to image_get_resinfo: a channel DXIL leaves out reads 0 rather than 1, and a UAV still reports one level. One difference: #1313 keeps 1 for a missing extent of a cube view (kind == 5), while this PR returns 0 there too. #1313 now conflicts with main. Settling on one, and on the cube case, would avoid two versions.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149538334 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1938#issuecomment-7149538334). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T01:25:53Z. --- Overlap note, from reading the diffs (not run): #1313 (EatCodeSleep2, opened a day earlier for the same finding, VIC-BT-038 in #1249) makes the same change to `image_get_resinfo`: a channel DXIL leaves out reads 0 rather than 1, and a UAV still reports one level. One difference: #1313 keeps 1 for a missing extent of a cube view (`kind == 5`), while this PR returns 0 there too. #1313 now conflicts with `main`. Settling on one, and on the cube case, would avoid two versions. AI-assisted (Claude Code).
Headache3318 commented 2026-11-25 02:06:31 +00:00 (Migrated from github.com)

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


Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head bac64f0 applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 145 passed, 0 failed, 2 ignored. All tests pass, including the new resinfo_returns_zero_for_unused_depth_channel_on_2d_texture test.
  • cargo clippy -p victory-shader --all-targets --all-features -- -D warnings: 4 pre-existing errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150273334 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1938#issuecomment-7150273334). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T02:03:50Z. --- Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `bac64f0` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 145 passed, 0 failed, 2 ignored. All tests pass, including the new `resinfo_returns_zero_for_unused_depth_channel_on_2d_texture` test. - `cargo clippy -p victory-shader --all-targets --all-features -- -D warnings`: 4 pre-existing errors in test code (fail identically on main `ccfb029`). The PR introduces no new clippy warnings. Not tested: Windows MSVC build, the title itself. AI-assisted.
catminou4 commented 2026-11-25 04:06:07 +00:00 (Migrated from github.com)

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

Review: APPROVED


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

145 passed / 0 failed / 2 ignored. image_get_resinfo returns 0 for unused depth/height channels (+1 test) — resinfo completeness for typeless/partial views.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051251425 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1938#pullrequestreview-6051251425). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T03:05:20Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 145 passed / 0 failed / 2 ignored. image_get_resinfo returns 0 for unused depth/height channels (+1 test) — resinfo completeness for typeless/partial views.
Marvisak commented 2026-11-25 09:06:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:16:05Z.


Automated triage for the maintainers.

Needs work.

The change in crates/victory-shader/src/emit/lower.rs (image_get_resinfo lowering, the op == 72 branch) makes channels the view does not have (height of a 1D view, depth of 1D/2D/cube views) read 0 instead of 1. This changes emulation behaviour, and the PR gives no evidence for it beyond "per RDNA2 ISA specifications". Please cite the source: the section of the public RDNA2 ISA document, a console compiler output, or the title's own code that depends on it. Whether the hardware returns 0 or 1 for a missing extent is the whole point of the change.

  • The new test resinfo_returns_zero_for_unused_depth_channel_on_2d_texture only checks that lowering succeeds (!lowered.dxil.is_empty()). That was already true on main. It should check that the depth channel is the constant 0.
  • #1313 makes the same change for the same finding (VIC-BT-038 in #1249), except that it keeps 1 for a cube view's missing extent. The maintainers should settle on one PR and on the cube case.

CI: check passes.

What would change the verdict: a cited reference for the 0 value, including the cube case, and a test that asserts the value.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156816237 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1938#issuecomment-7156816237). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T08:16:05Z. --- <!-- victory-triage v1 head=bac64f0b2e980eb07ca02ea695f6699d17d973c5 verdict=needs-work at=2026-11-25T08:15:55Z --> Automated triage for the maintainers. **Needs work.** The change in `crates/victory-shader/src/emit/lower.rs` (`image_get_resinfo` lowering, the `op == 72` branch) makes channels the view does not have (height of a 1D view, depth of 1D/2D/cube views) read 0 instead of 1. This changes emulation behaviour, and the PR gives no evidence for it beyond "per RDNA2 ISA specifications". Please cite the source: the section of the public RDNA2 ISA document, a console compiler output, or the title's own code that depends on it. Whether the hardware returns 0 or 1 for a missing extent is the whole point of the change. - The new test `resinfo_returns_zero_for_unused_depth_channel_on_2d_texture` only checks that lowering succeeds (`!lowered.dxil.is_empty()`). That was already true on `main`. It should check that the depth channel is the constant 0. - #1313 makes the same change for the same finding (VIC-BT-038 in #1249), except that it keeps 1 for a cube view's missing extent. The maintainers should settle on one PR and on the cube case. CI: `check` passes. What would change the verdict: a cited reference for the 0 value, including the cube case, and a test that asserts the value. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 11:03:30 +00:00
ashrafsdrop commented 2026-11-25 11:05:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ashrafsdrop on 2026-11-25T10:54:44Z.


Closing in favor of #1313 which opened earlier for VIC-BT-038 with end-to-end readback testing in waterfall_tests.rs.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160337595 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1938#issuecomment-7160337595). Originally posted by [ashrafsdrop](https://github.com/ashrafsdrop) on 2026-11-25T10:54:44Z. --- Closing in favor of #1313 which opened earlier for VIC-BT-038 with end-to-end readback testing in waterfall_tests.rs.

Pull request closed

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!1936
No description provided.