Shaders: return zero for unused image_get_resinfo extents #2457

Open
github-bot wants to merge 1 commit from github-bot/gh-2457 into main AGit
Owner

@⁠makmatvey on GitHub · 2026-11-25 13:52 UTC · original
makmatvey:cursor/shader-resinfo-unused-zero-c78e → main · +58 −6 · 2 files · 1 commits · open

What's wrong

image_get_resinfo filled unused extents with 1 (DXIL's unused-channel fill) for 1D, 2D and 1D-array views. On RDNA2 those channels are 0. Cubes still use 1 for the unused depth channel; UAVs still report one mip level.

Tracked as VIC-BT-038 in #1242 / #1249. Open #1313 covers the same fix but is triage: needs rebase / dirty against current main; this is a focused re-land.

What the change does

  • crates/victory-shader/src/emit/lower.rs: unused extents get 0 except cubes (kind == 5), which keep 1. UAV mip count stays 1.
  • crates/victory-shader/src/emit/waterfall_tests.rs: synthetic 2D image_get_resinfo (dmask 0xf) expects [3, 2, 0, 1] on hardware and WARP.

Tests

  • New image_resinfo_returns_zero_depth_for_a_2d_view (Windows GPU / WARP + dxil.dll when present).
  • cargo xtask policy: 182 files ok.
  • Full cargo test --workspace --locked / clippy left to Windows CI.

No game data used.

Refs #1249, #1242 (VIC-BT-038).

**@⁠makmatvey** on GitHub · 2026-11-25 13:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2457) `makmatvey:cursor/shader-resinfo-unused-zero-c78e` → `main` · +58 −6 · 2 files · 1 commits · open ## What's wrong `image_get_resinfo` filled unused extents with `1` (DXIL's unused-channel fill) for 1D, 2D and 1D-array views. On RDNA2 those channels are `0`. Cubes still use `1` for the unused depth channel; UAVs still report one mip level. Tracked as **VIC-BT-038** in #1242 / #1249. Open #1313 covers the same fix but is `triage: needs rebase` / dirty against current `main`; this is a focused re-land. ## What the change does - `crates/victory-shader/src/emit/lower.rs`: unused extents get `0` except cubes (`kind == 5`), which keep `1`. UAV mip count stays `1`. - `crates/victory-shader/src/emit/waterfall_tests.rs`: synthetic 2D `image_get_resinfo` (dmask 0xf) expects `[3, 2, 0, 1]` on hardware and WARP. ## Tests - New `image_resinfo_returns_zero_depth_for_a_2d_view` (Windows GPU / WARP + `dxil.dll` when present). - `cargo xtask policy`: 182 files ok. - Full `cargo test --workspace --locked` / clippy left to Windows CI. No game data used. Refs #1249, #1242 (VIC-BT-038).
Non-cube 1D/2D/1D-array image_get_resinfo filled unused width/height/depth
channels with 1 (DXIL's unused fill). RDNA2 returns 0 there. Cubes keep 1
for the unused depth channel; UAVs still report one mip level.

Refs #1249 / #1242 (VIC-BT-038). Open #1313 needs rebase; this is a focused
re-land on current main with a synthetic 2D GPU/WARP regression.

Co-authored-by: Matsvey Makushenka <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:06:29 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-25 15:41 UTC · original

Independent local validation for PR #2457 (Windows, Rust 1.100.0/MSVC, head a2649d8, no game data): cargo test --locked -p victory-shader --lib -> 248 tests passed, 0 failed, 3 ignored, exit 0; git diff --check clean. CPU-only regression run; synthetic unused image_get_resinfo scenario not replayed. AI-assisted (Hy4 flash). GPU/driver N/A for CPU tests.

**@⁠cloph-dsp** on GitHub · 2026-11-25 15:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2457#issuecomment-7167237949) Independent local validation for PR #2457 (Windows, Rust 1.100.0/MSVC, head a2649d8, no game data): `cargo test --locked -p victory-shader --lib` -> 248 tests passed, 0 failed, 3 ignored, exit 0; `git diff --check` clean. CPU-only regression run; synthetic unused image_get_resinfo scenario not replayed. AI-assisted (Hy4 flash). GPU/driver N/A for CPU tests.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:55 UTC · original

Automated triage for the maintainers.

This changes what image_get_resinfo returns for unused extents (crates/victory-shader/src/emit/lower.rs, the op == 72 branch): 0 instead of 1, except for cubes. CI passes, but it changes emulated shader behaviour on the strength of "(RDNA2)" alone, and the new test checks the values the new code produces rather than a reference. To move forward, please cite the evidence: the section of the public RDNA2 ISA document that defines the resinfo result per image type, or console compiler output that relies on it. Please also explain why cubes keep 1 for the unused channel while 1D/2D views get 0, since the same source should settle both. #1313 covers the same fix; the maintainers should pick one.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2457#issuecomment-7167441062) <!-- victory-triage v1 head=a2649d842905fb362b8e5955c2a1dea8e1562de9 verdict=needs-work at=2026-11-25T15:55:42Z --> Automated triage for the maintainers. This changes what `image_get_resinfo` returns for unused extents (`crates/victory-shader/src/emit/lower.rs`, the `op == 72` branch): 0 instead of 1, except for cubes. CI passes, but it changes emulated shader behaviour on the strength of "(RDNA2)" alone, and the new test checks the values the new code produces rather than a reference. To move forward, please cite the evidence: the section of the public RDNA2 ISA document that defines the resinfo result per image type, or console compiler output that relies on it. Please also explain why cubes keep 1 for the unused channel while 1D/2D views get 0, since the same source should settle both. #1313 covers the same fix; the maintainers should pick one. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

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

Evidence for the triage ask at a2649d8. Public sources only, no game data.

The RDNA 2 ISA does not define it. "RDNA 2" ISA Reference Guide (30 Nov 2020), §12.16 MIMG Instructions, IMAGE_GET_RESINFO (p. 217 of 283), says only: "Returns 4 integer values into VGPRs 3-0: {num_mip_levels, depth, height, width}." §8.2.3 Table 42 gives only the address (mipid). Nothing per image type, nothing on unused channels.

Cubes: the sources that cover them say 6 per cube, not 1.

  • GCN3 ISA (Aug 2016, rev 1.1), §12.16, p. 12-175: "For cubemaps, depth = 6 * Number_of_array_slices."
  • RDNA3 ISA (13 Dec 2022), §10.1, p. 95: "For cubemaps, depth = 6 * Number_of_array_faces. (DX expects the # of cubes, but gets # of faces instead)".
  • Mesa divides the cube-array count by 6 (nir_lower_tex.c#L1332-1347, enabled by RADV). So does AMD's LLPC (ImageBuilder.cpp#L1622-L1626).

1D/2D: no AMD text, but public PC RDNA 2 measurements give 0:

  • gfx1036 (AnyPS5#16554, data):
    • 1D T# with DIM 1D: (1024, 0, 0, 1)
    • 2D T# with DIM 2D: (1024, 64, 0, 1)
    • 1D-array T# with DIM 1D_ARRAY: (1024, slices, 0, 1)
  • gfx1031 (AnyPS5#7550 comment): an 8x8 cube T# with DIM CUBE gives (8, 8, 6, 1).

So the 0 for 1D, 2D and 1D-array matches PC RDNA 2 hardware, but the RDNA 2 document doesn't say it. The cube's 1 (main's value, kept here) matches no source: hardware and AMD's later documents give 6 per cube. The cube-array ×6 is in #1256.

  • Suggestion: change the code comment so it doesn't present the cube's 1 as RDNA 2 behaviour. Either say it is unverified, or return 6 for a single-cube view in a follow-up.
  • Still unknown: the console GPU itself (these are PC gfx1031/gfx1036 results) and console compiler output. #1313 cited the same AnyPS5 measurements.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠upipibi** on GitHub · 2026-11-25 17:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2457#issuecomment-7169585059) Evidence for the triage ask at a2649d8. Public sources only, no game data. **The RDNA 2 ISA does not define it.** "RDNA 2" ISA Reference Guide (30 Nov 2020), §12.16 MIMG Instructions, IMAGE_GET_RESINFO (p. 217 of 283), says only: "Returns 4 integer values into VGPRs 3-0: {num_mip_levels, depth, height, width}." §8.2.3 Table 42 gives only the address (mipid). Nothing per image type, nothing on unused channels. **Cubes: the sources that cover them say 6 per cube, not 1.** - GCN3 ISA (Aug 2016, rev 1.1), §12.16, p. 12-175: "For cubemaps, depth = 6 * Number_of_array_slices." - RDNA3 ISA (13 Dec 2022), §10.1, p. 95: "For cubemaps, depth = 6 * Number_of_array_faces. (DX expects the # of cubes, but gets # of faces instead)". - Mesa divides the cube-array count by 6 ([nir_lower_tex.c#L1332-1347](https://gitlab.freedesktop.org/mesa/mesa/-/blob/cfe81d69fc100921f9b492eda89211a127166926/src/compiler/nir/nir_lower_tex.c#L1332-1347), enabled by RADV). So does AMD's LLPC ([ImageBuilder.cpp#L1622-L1626](https://github.com/GPUOpen-Drivers/llpc/blob/40cb8d95ad8d6f7f1652e3fd47d39667594cce08/lgc/builder/ImageBuilder.cpp#L1622-L1626)). **1D/2D: no AMD text, but public PC RDNA 2 measurements give 0:** - gfx1036 ([AnyPS5#16554](https://github.com/boykopovar/AnyPS5/pull/16554), [data](https://gist.github.com/brumskysb/1ede1aa1c988707fbc0bfc6362eaf2a1)): - 1D T# with DIM 1D: `(1024, 0, 0, 1)` - 2D T# with DIM 2D: `(1024, 64, 0, 1)` - 1D-array T# with DIM 1D_ARRAY: `(1024, slices, 0, 1)` - gfx1031 ([AnyPS5#7550 comment](https://github.com/boykopovar/AnyPS5/pull/7550#issuecomment-6253134984)): an 8x8 cube T# with DIM CUBE gives `(8, 8, 6, 1)`. So the 0 for 1D, 2D and 1D-array matches PC RDNA 2 hardware, but the RDNA 2 document doesn't say it. The cube's 1 (main's value, kept here) matches no source: hardware and AMD's later documents give 6 per cube. The cube-array ×6 is in #1256. - Suggestion: change the code comment so it doesn't present the cube's 1 as RDNA 2 behaviour. Either say it is unverified, or return 6 for a single-cube view in a follow-up. - Still unknown: the console GPU itself (these are PC gfx1031/gfx1036 results) and console compiler output. #1313 cited the same AnyPS5 measurements. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2457/head:github-bot/gh-2457'
git switch 'github-bot/gh-2457'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2457'
git switch 'github-bot/gh-2457'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2457'
git switch 'github-bot/gh-2457'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2457'
git switch 'main'
git merge --squash 'github-bot/gh-2457'
git switch 'main'
git merge --ff-only 'github-bot/gh-2457'
git switch 'main'
git merge 'github-bot/gh-2457'
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!2457
No description provided.