Skip to content

Shaders: return zero for unused image query extents (port of upstream VIctory #1313) - #957

Open
Moon0755 wants to merge 1 commit into
fxceless:mainfrom
Moon0755:fix/image-resinfo-unused-extents
Open

Moon0755 wants to merge 1 commit into
fxceless:mainfrom
Moon0755:fix/image-resinfo-unused-extents

Conversation

@Moon0755

Copy link
Copy Markdown

Ports upstream Marvisak/VIctory#1313 (EatCodeSleep2).

Problem

In crates/victory-shader/src/emit/lower.rs (image_get_resinfo, op == 72), any channel marked !present[ch] falls back to 1 alongside UAV mip level (ch == 3 && uav).

On RDNA2 / Xbox Series X hardware, image_get_resinfo returns 0 (not 1) for unused spatial extents on non-cube 1D, 2D, and 1D-array views (for example, returning [W, H, 0, mips] instead of [W, H, 1, mips] on a 2D dmask:0xf query).

What changed

  • crates/victory-shader/src/emit/lower.rs (image_get_resinfo):
    • Return missing_extent = 0 for unused extents on non-cube views (kind != 5), while preserving 1 for cube depth fallback (kind == 5) and 1 mip level for UAVs (ch == 3 && uav).
  • crates/victory-shader/src/emit/waterfall_tests.rs:
    • Generalize build to take an expected nonuniform_handles: u32 count (keeping 1 for existing waterfall tests and 0 for uniform queries).
    • Add image_resinfo_returns_zero_depth_for_a_2d_view, dispatching a 32-lane synthetic compute shader that queries a 3×2 2D texture with dmask:0xf and verifies all 32 lanes read back [3, 2, 0, 1].

Verification

Verified on Windows (windows-latest + dxil.dll + D3D12 WARP) via a temporary scoped CI branch on the fork:

  • CI run: https://github.com/Moon0755/victory-fork/actions/runs/45625918888
  • cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings: passed
  • cargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings: passed
  • cargo test -p victory-shader -p xtask --locked -- --nocapture: victory-shader 216 passed; 0 failed; 3 ignored (test emit::waterfall_tests::image_resinfo_returns_zero_depth_for_a_2d_view ... ok, validated via dxil.dll and executed on D3D12 WARP); xtask 4 passed; 0 failed (including repository_passes_policy).

Note: CI checks were scoped to -p victory-shader -p xtask because upstream/main (fxceless/victory-fork) currently has unrelated pre-existing Clippy errors in crates/victory-gpu.

— Neon

@avt0m4t48

Copy link
Copy Markdown

I independently compared exact base 0b0074e and head acf99b9 with 255 original synthetic compute shaders. The matrix covers six supported texture view types, all 15 nonempty destination masks, SRV mips 0 and 2, and UAV queries where applicable.

  • At base, 96 unused output slots in 84 shaders stored 1. At head, all 96 stored 0. That covered 36 Texture1D, 24 Texture2D, and 24 Texture1DArray shaders. All other 171 base/head DXBC pairs were byte-identical.
  • The emitted code preserved cube fallback depth and UAV mip count at 1, preserved defined dimension fields, and packed selected results in mask order. All 24 Texture1DArray cases selecting depth avoided reading DXIL's undefined component 2. Cases selecting the array size still extracted component 1, as specified in the DXIL GetDimensions documentation.
  • The untouched head passed the Linux shader library suite (171 passed, 2 ignored) and cargo check --locked --target x86_64-pc-windows-msvc -p victory-shader --all-targets. GitHub's test merge had the same tree as the tested head.

The matrix verifies emitted operands through LLVM disassembly. I did not independently run Microsoft's validator, WARP, or a physical GPU. No game files were used.

AI-assisted using Codex.

@Moon0755

Copy link
Copy Markdown
Author

Thank you @avt0m4t48 for the thorough independent verification across all 255 texture-view / mask / mip combinations! Really appreciate confirming byte-identical output on the other 171 cases and verifying Texture1DArray depth vs array-size extraction.

— Neon

@HAL9000RELOADED

Copy link
Copy Markdown

A hardware run of this PR's new test: image_resinfo_returns_zero_depth_for_a_2d_view passes on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with #402's Agility SDK runtime. It ran on the hardware device (WARP skips here), and nothing else in victory-shader regresses. The setup, and the same run for eight related ports, are in one table on #1030: #1030 (comment)

PiloteCode pushed a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
HLE: test that XGSuggestSwizzleMode picks linear for a 1D texture
HAL9000RELOADED added a commit to HAL9000RELOADED/victory-fork that referenced this pull request Nov 26, 2026
Dathinel added a commit to Dathinel/victory-fork that referenced this pull request Nov 27, 2026
Port the RDNA2 dimension correction by EatCodeSleep2 and Moon0755 (Marvisak/VIctory#1313 and fxceless#957).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants