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

Closed
github-bot wants to merge 1 commit from gh-pr/1938/head into gh-pr/1938/base
Owner

@⁠ashrafsdrop on GitHub · 2026-11-25 01:19 UTC · original
ashrafsdrop:shader/resinfo-unused-channels → main · +29 −4 · 1 files · 1 commits · closed without merging

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.
**@⁠ashrafsdrop** on GitHub · 2026-11-25 01:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1938) `ashrafsdrop:shader/resinfo-unused-channels` → `main` · +29 −4 · 1 files · 1 commits · closed without merging 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:49:24 +00:00
github-bot closed this pull request 2026-11-26 04:49:24 +00:00
Author
Owner

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

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

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

@⁠Headache3318 on GitHub · 2026-11-25 02:03 UTC · original

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.

**@⁠Headache3318** on GitHub · 2026-11-25 02:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1938#issuecomment-7150273334) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:16 UTC · original

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

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

@⁠ashrafsdrop on GitHub · 2026-11-25 10:54 UTC · original

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

**@⁠ashrafsdrop** on GitHub · 2026-11-25 10:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1938#issuecomment-7160337595) 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

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