Shaders: decode cube-array slice and face in image lowering #2522

Merged
fuzeofficlal merged 1 commit from upstream-pr/2522 into main 2026-11-30 14:12:02 +00:00
fuzeofficlal commented 2026-11-29 13:49:55 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by fuzeofficlal on 2026-11-29T13:49:55Z.


Summary

RDNA2 MIMG carries no separate dimension bit for cube-map arrays (dim:CUBE = 3 is shared by TextureCube and TextureCubeArray): the compiler packs the third coordinate operand as 8 * slice + face and expects channel 2 of image_get_resinfo to report the view's face count (NumCubes * 6).

  • Infer TextureCubeArray (DXIL kind 9) in crates/victory-shader/src/emit/lower/cube_array.rs when a dim == 3 sample or gather4 builds its face operand by multiplying by 8.0 (covering literal, inline, omod, SGPR/VGPR constant sources, and a16 half-float coordinates) or from a constant >= 8.0, when image_get_resinfo has a live channel-2 read, or when another cube site shares the same descriptor slot. Plain TextureCube sites remain kind 5.
  • Decode slice and face matching RDNA2 hardware behavior: split the face operand into idx & 7 with unsigned clamping of face IDs 6 and 7 to face 5 (-Z), pass float(idx >> 3) as the fourth sampling coordinate while keeping integer texel offsets undef for kind 9, and refuse cube gathers with offsets.
  • Scale image_get_resinfo channel 2 by 6 on TextureCubeArray handles so D3D12's cube count matches RDNA2's face count.

Verification

  • cargo test --locked -p victory-shader --lib emit::lower::cube_array:: — pass (DXIL validated with dxil.dll across image_sample*, a16, image_sample_b, and descriptor-linked image_get_resinfo).
  • cargo test --locked -p victory-shader --lib emit::valu_tests::cube_ -- --test-threads=1 — 3/3 pass across RTX 5090, AMD Radeon Graphics, and D3D12 WARP (2-cube and 3-cube arrays, face IDs 0..8, gather4, resinfo, and plain TextureCube non-regression).
  • cargo clippy --locked -p victory-shader --all-targets — 0 new warnings in touched files.
  • cargo run --quiet --locked -p xtask -- policy --staged — pass.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5551353027 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2522). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-29T13:49:55Z. --- ### Summary RDNA2 `MIMG` carries no separate dimension bit for cube-map arrays (`dim:CUBE` = 3 is shared by `TextureCube` and `TextureCubeArray`): the compiler packs the third coordinate operand as `8 * slice + face` and expects channel 2 of `image_get_resinfo` to report the view's face count (`NumCubes * 6`). - **Infer `TextureCubeArray` (DXIL kind 9)** in `crates/victory-shader/src/emit/lower/cube_array.rs` when a `dim == 3` sample or `gather4` builds its face operand by multiplying by `8.0` (covering literal, inline, `omod`, SGPR/VGPR constant sources, and `a16` half-float coordinates) or from a constant `>= 8.0`, when `image_get_resinfo` has a live channel-2 read, or when another cube site shares the same descriptor slot. Plain `TextureCube` sites remain kind 5. - **Decode slice and face matching RDNA2 hardware behavior**: split the face operand into `idx & 7` with unsigned clamping of face IDs `6` and `7` to face `5` (`-Z`), pass `float(idx >> 3)` as the fourth sampling coordinate while keeping integer texel offsets `undef` for kind 9, and refuse cube gathers with offsets. - **Scale `image_get_resinfo` channel 2 by 6** on `TextureCubeArray` handles so D3D12's cube count matches RDNA2's face count. ### Verification - `cargo test --locked -p victory-shader --lib emit::lower::cube_array::` — pass (DXIL validated with `dxil.dll` across `image_sample*`, `a16`, `image_sample_b`, and descriptor-linked `image_get_resinfo`). - `cargo test --locked -p victory-shader --lib emit::valu_tests::cube_ -- --test-threads=1` — 3/3 pass across RTX 5090, AMD Radeon Graphics, and D3D12 WARP (`2-cube` and `3-cube` arrays, face IDs `0..8`, `gather4`, `resinfo`, and plain `TextureCube` non-regression). - `cargo clippy --locked -p victory-shader --all-targets` — 0 new warnings in touched files. - `cargo run --quiet --locked -p xtask -- policy --staged` — pass.
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
trustno1-coder/VIctory-NVIDIA!2522
No description provided.