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

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

@⁠Moon0755 on GitHub · 2026-11-25 13:44 UTC · original
Moon0755:fix/image-resinfo-unused-extents → main · +56 −13 · 2 files · 1 commits · open

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

**@⁠Moon0755** on GitHub · 2026-11-25 13:44 UTC · [original](https://github.com/fxceless/victory-fork/pull/957) `Moon0755:fix/image-resinfo-unused-extents` → `main` · +56 −13 · 2 files · 1 commits · open Ports upstream [Marvisak/VIctory#1313](https://github.com/Marvisak/VIctory/pull/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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:54:36 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 15:31 UTC · original

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.

**@⁠avt0m4t48** on GitHub · 2026-11-25 15:31 UTC · [original](https://github.com/fxceless/victory-fork/pull/957#issuecomment-7166975967) 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](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#getdimensions). - 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.
Author
Owner

@⁠Moon0755 on GitHub · 2026-11-25 16:15 UTC · original

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

**@⁠Moon0755** on GitHub · 2026-11-25 16:15 UTC · [original](https://github.com/fxceless/victory-fork/pull/957#issuecomment-7167725890) 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
Author
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-25 18:00 UTC · original

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

**@⁠HAL9000RELOADED** on GitHub · 2026-11-25 18:00 UTC · [original](https://github.com/fxceless/victory-fork/pull/957#issuecomment-7170317573) 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: https://git.gtahub.st/github/fxceless--victory-fork/pulls/1030
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/957/head:github-bot/gh-957'
git switch 'github-bot/gh-957'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-957'
git switch 'github-bot/gh-957'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-957'
git switch 'github-bot/gh-957'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-957'
git switch 'main'
git merge --squash 'github-bot/gh-957'
git switch 'main'
git merge --ff-only 'github-bot/gh-957'
git switch 'main'
git merge 'github-bot/gh-957'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.