Shaders/Lower: return 6 faces for channel 2 of image_get_resinfo on SQ_RSRC_IMG_CUBE #3008

Open
RVZO6 wants to merge 1 commit from upstream-pr/3010 into main
RVZO6 commented 2026-11-26 03:19:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-26T03:19:31Z.


Lower::image_op (crates/victory-shader/src/emit/lower.rs:8670-8685) previously placed TextureCube (kind == 5) in 2 | 5 | 6 with present[2] = false, returning 1 for channel 2 (depth) of image_get_resinfo on a cubemap.

Per public AMD documentation, compilers, and RDNA 2 hardware measurements:

  • AMD GCN3 ISA (Aug 2016, rev 1.1) §12.16, p. 12-175: "For cubemaps, depth = 6 * Number_of_array_slices."
  • AMD 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 RADV (nir_lower_tex.c) and AMD LLPC (ImageBuilder.cpp) both divide cubemap resinfo depth by 6.
  • Measured on gfx1031 hardware: an 8×8 DIM CUBE T# returns (8, 8, 6, 1).
  • Companion to #1256 (which scales TextureCubeArray, kind == 9, by × 6).

Emit constant 6 when kind == 5 && ch == 2, with tests in crates/victory-shader/src/emit/lower/cube_resinfo_tests.rs (keeping lower.rs at 520,845 B, well under the 512 KiB limit).

Verification

  • cube_image_get_resinfo_reports_six_faces lowers image_get_resinfo dmask:0xf dim:SQ_RSRC_IMG_CUBE, validates with dxil.dll, and executes on WARP SM 6.6 against a 3-mip 8×8 MippedCube, asserting [8, 8, 6, 3] (mip 0) and [4, 4, 6, 3] (mip 1).
  • Official Windows MSVC + WARP SM 6.6 CI (Rust 1.98.1, default + --tests + --features diagnostics clippy, xtask policy, full workspace tests): RVZO6/VIctory CI run #45747688145 (green, combined Wave 9 check on 63bcca4).
  • Not run: the title; any hardware GPU.

AI-assisted: T3 Code (Antigravity, gemini-4-neon).

<!-- greyfinch-sync:Marvisak/VIctory:issue:5503378051 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3010). Originally posted by [RVZO6](https://github.com/RVZO6) on 2026-11-26T03:19:31Z. --- `Lower::image_op` (`crates/victory-shader/src/emit/lower.rs:8670-8685`) previously placed `TextureCube` (`kind == 5`) in `2 | 5 | 6` with `present[2] = false`, returning `1` for channel 2 (`depth`) of `image_get_resinfo` on a cubemap. Per public AMD documentation, compilers, and RDNA 2 hardware measurements: - AMD GCN3 ISA (Aug 2016, rev 1.1) §12.16, p. 12-175: *"For cubemaps, depth = 6 * Number_of_array_slices."* - AMD 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 RADV (`nir_lower_tex.c`) and AMD LLPC (`ImageBuilder.cpp`) both divide cubemap `resinfo` depth by 6. - Measured on gfx1031 hardware: an 8×8 `DIM CUBE` T# returns `(8, 8, 6, 1)`. - Companion to #1256 (which scales `TextureCubeArray`, `kind == 9`, by `× 6`). Emit constant `6` when `kind == 5 && ch == 2`, with tests in `crates/victory-shader/src/emit/lower/cube_resinfo_tests.rs` (keeping `lower.rs` at `520,845 B`, well under the 512 KiB limit). ### Verification - `cube_image_get_resinfo_reports_six_faces` lowers `image_get_resinfo dmask:0xf dim:SQ_RSRC_IMG_CUBE`, validates with `dxil.dll`, and executes on **WARP SM 6.6** against a 3-mip 8×8 `MippedCube`, asserting `[8, 8, 6, 3]` (mip 0) and `[4, 4, 6, 3]` (mip 1). - Official Windows MSVC + WARP SM 6.6 CI (Rust 1.98.1, default + `--tests` + `--features diagnostics` clippy, `xtask policy`, full workspace tests): [RVZO6/VIctory CI run #45747688145](https://github.com/RVZO6/VIctory/actions/runs/45747688145) (green, combined Wave 9 check on `63bcca4`). - **Not run:** the title; any hardware GPU. AI-assisted: T3 Code (Antigravity, gemini-4-neon).
Dukestar69 commented 2026-11-26 03:31:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:31:30Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):

  • cargo test -p victory-shader --lib cube_resinfo: 2 passed, 0 failed (cube_resinfo_dxil_validates and cube_image_get_resinfo_reports_six_faces pass on RTX 5090 hardware and WARP).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068183485 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3010#pullrequestreview-6068183485). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T03:31:30Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, `dxil.dll` validator active): - `cargo test -p victory-shader --lib cube_resinfo`: **2 passed, 0 failed** (`cube_resinfo_dxil_validates` and `cube_image_get_resinfo_reports_six_faces` pass on RTX 5090 hardware and WARP). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 03:38:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T03:38:38Z.

Review: CHANGES_REQUESTED


Code review on df36af54 (static source inspection; no runtime GPU/DXIL validation executed):

  • P2 — Unconditionally returning 6 for channel 2 on SQ_RSRC_IMG_CUBE misreports TextureCubeArray views (crates/victory-shader/src/emit/lower.rs:8681-8684, crates/victory-gpu/src/descriptor/host.rs:1118, 1498):
    • GFX10 uses SQ_RSRC_IMG_CUBE (dim == 3, kind == 5) for both single cubemaps and cubemap arrays (descriptor/host.rs:1118 maps both TextureCube and TextureCubeArray to cube descriptors while preserving the D3D12 SRV dimension).
    • Returning self.s.m.i32(6) unconditionally for kind == 5 && ch == 2 reports 6 even for a multi-cube array (e.g., 2 cubes = 12 faces), while the DXIL handle declares TextureCube.
    • Suggest either reading the actual slice/cube count when the view is a cube array (coordinating with cube-array support) or explicitly rejecting/gating cube-array resinfo queries rather than silently returning 6.
  • File size check: patched emit/lower.rs is 520,845 B (within the 512 KiB limit).
<!-- greyfinch-sync:Marvisak/VIctory:review:6068227157 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3010#pullrequestreview-6068227157). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T03:38:38Z. **Review:** CHANGES_REQUESTED --- Code review on `df36af54` (static source inspection; no runtime GPU/DXIL validation executed): - **P2 — Unconditionally returning `6` for channel 2 on `SQ_RSRC_IMG_CUBE` misreports `TextureCubeArray` views (`crates/victory-shader/src/emit/lower.rs:8681-8684`, `crates/victory-gpu/src/descriptor/host.rs:1118, 1498`)**: - GFX10 uses `SQ_RSRC_IMG_CUBE` (`dim == 3`, `kind == 5`) for both single cubemaps and cubemap arrays (`descriptor/host.rs:1118` maps both `TextureCube` and `TextureCubeArray` to cube descriptors while preserving the D3D12 SRV dimension). - Returning `self.s.m.i32(6)` unconditionally for `kind == 5 && ch == 2` reports `6` even for a multi-cube array (e.g., 2 cubes = 12 faces), while the DXIL handle declares `TextureCube`. - Suggest either reading the actual slice/cube count when the view is a cube array (coordinating with cube-array support) or explicitly rejecting/gating cube-array `resinfo` queries rather than silently returning `6`. - File size check: patched `emit/lower.rs` is `520,845 B` (within the 512 KiB limit).
kotekompotek commented 2026-11-26 04:40:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T04:40:29Z.

Review: APPROVED


LGTM — cube resinfo channel 2 = 6 matches GCN3 §12.16/RADV behavior; gated to kind==5 only so other dims keep the previous result; the hardware test checks both mips.

<!-- greyfinch-sync:Marvisak/VIctory:review:6068634527 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3010#pullrequestreview-6068634527). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T04:40:29Z. **Review:** APPROVED --- LGTM — cube resinfo channel 2 = 6 matches GCN3 §12.16/RADV behavior; gated to kind==5 only so other dims keep the previous result; the hardware test checks both mips.
Marvisak commented 2026-11-26 07:01:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:17:22Z.


Automated triage for the maintainers.

For image_get_resinfo on a cube (DXIL kind 5), Lower::image_op in emit/lower.rs now returns the constant 6 in channel 2 instead of 1. Previously channel 2 counted as "not present" for cubes in the 2 | 5 | 6 arm. The evidence is public: the AMD ISA manuals' rule that a cubemap's depth is 6 times the number of slices, the RADV/LLPC lowering that divides by 6, and a stated gfx1031 (RDNA2) measurement. That is the kind of evidence a semantics change needs. The fix touches only kind 5, and cube arrays (kind 9) are left to #1256. The WARP test in lower/cube_resinfo_tests.rs checks [8, 8, 6, 3] at mip 0 and [4, 4, 6, 3] at mip 1.

Minor: the inline comment's list of citations could be cut to one short reference.

CI: check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184281621 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3010#issuecomment-7184281621). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T06:17:22Z. --- <!-- victory-triage v1 head=df36af54077e1d131fd6686b2489094ce6b992a1 verdict=merge-candidate at=2026-11-26T06:21:00Z --> Automated triage for the maintainers. For `image_get_resinfo` on a cube (DXIL kind 5), `Lower::image_op` in `emit/lower.rs` now returns the constant 6 in channel 2 instead of 1. Previously channel 2 counted as "not present" for cubes in the `2 | 5 | 6` arm. The evidence is public: the AMD ISA manuals' rule that a cubemap's depth is 6 times the number of slices, the RADV/LLPC lowering that divides by 6, and a stated gfx1031 (RDNA2) measurement. That is the kind of evidence a semantics change needs. The fix touches only kind 5, and cube arrays (kind 9) are left to #1256. The WARP test in `lower/cube_resinfo_tests.rs` checks `[8, 8, 6, 3]` at mip 0 and `[4, 4, 6, 3]` at mip 1. Minor: the inline comment's list of citations could be cut to one short reference. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
upipibi commented 2026-11-28 04:35:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T04:35:38Z.


Hardware run, since the PR has WARP only: RTX 3070 8 GB, driver 616.56, Windows 11, head df36af5. cube_resinfo_tests 2 of 2 passed, 3 runs, on the hardware adapter and on WARP in the same process (the test asserts both). So the NVIDIA host returns [8, 8, 6, 3] for mip 0 and [4, 4, 6, 3] for mip 1.

The 6 is the translator's constant, so the card confirms the width, height and level count around it rather than the face count itself. The face-count rule rests on the ISA text and the gfx1031 measurement cited above.

AI-assisted (Claude Code, Claude Opus 5.5 built this head and ran the test on this card).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7234137404 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3010#issuecomment-7234137404). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T04:35:38Z. --- Hardware run, since the PR has WARP only: RTX 3070 8 GB, driver 616.56, Windows 11, head `df36af5`. `cube_resinfo_tests` 2 of 2 passed, 3 runs, on the hardware adapter and on WARP in the same process (the test asserts both). So the NVIDIA host returns `[8, 8, 6, 3]` for mip 0 and `[4, 4, 6, 3]` for mip 1. The 6 is the translator's constant, so the card confirms the width, height and level count around it rather than the face count itself. The face-count rule rests on the ISA text and the gfx1031 measurement cited above. AI-assisted (Claude Code, Claude Opus 5.5 built this head and ran the test on this card).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3010:upstream-pr/3010'
git switch 'upstream-pr/3010'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3010'
git switch 'upstream-pr/3010'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3010'
git switch 'upstream-pr/3010'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3010'
git switch 'main'
git merge --squash 'upstream-pr/3010'
git switch 'main'
git merge --ff-only 'upstream-pr/3010'
git switch 'main'
git merge 'upstream-pr/3010'
git push origin 'main'
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!3008
No description provided.