Shaders: return zero for unused image_get_resinfo extents #2455

Closed
makmatvey wants to merge 1 commit from upstream-pr/2457 into main
makmatvey commented 2026-11-25 13:52:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by makmatvey on 2026-11-25T13:52:04Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5492652760 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2457). Originally posted by [makmatvey](https://github.com/makmatvey) on 2026-11-25T13:52:04Z. --- ## 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).
DenRakEiw commented 2026-11-25 13:54:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T13:54:25Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Returning zero for unused image_get_resinfo extents passes all waterfall tests including the new 2D depth-zero readback test.
  • cargo test -p victory-shader waterfall_tests: 6/6 passed on RTX 5090, 6/6 passed on WARP (including image_resinfo_returns_zero_depth_for_a_2d_view).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6058884539 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2457#pullrequestreview-6058884539). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T13:54:25Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Returning zero for unused `image_get_resinfo` extents passes all waterfall tests including the new 2D depth-zero readback test. - `cargo test -p victory-shader waterfall_tests`: 6/6 passed on RTX 5090, 6/6 passed on WARP (including `image_resinfo_returns_zero_depth_for_a_2d_view`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 14:11:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:11:07Z.

Review: APPROVED


Tested locally: merged into main 940d32f69b, cargo test -p victory-shader --locked on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — zero returned for unused image_get_resinfo extents.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059173830 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2457#pullrequestreview-6059173830). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:11:07Z. **Review:** APPROVED --- Tested locally: merged into main 940d32f69b, `cargo test -p victory-shader --locked` on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — zero returned for unused image_get_resinfo extents.
cloph-dsp commented 2026-11-25 16:09:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T15:41:43Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167237949 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2457#issuecomment-7167237949). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T15:41:43Z. --- 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.
Marvisak commented 2026-11-25 16:09:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:55:56Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167441062 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2457#issuecomment-7167441062). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:55:56Z. --- <!-- 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)_
upipibi commented 2026-11-25 18:02:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T17:29:45Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169585059 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2457#issuecomment-7169585059). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T17:29:45Z. --- 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).

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