Shaders: lower image_get_lod on cube textures (port of upstream VIctory #1004) #1024

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

@⁠Moon0755 on GitHub · 2026-11-25 16:32 UTC · original
Moon0755:fix/cube-image-get-lod → main · +93 −3 · 1 files · 1 commits · open

Ports upstream Marvisak/VIctory#1004 (tarcisioads), and adds Windows dxil.dll validation to the regression test.

Problem

In crates/victory-shader/src/emit/lower.rs, pixel shader image_get_lod (op == 81, dx.op.calculateLOD.f32) on cube textures (dim == 3, kind == 5) was rejected in two places:

  • the dim == 3 dimension match only accepted image_sample*, image_gather*, and image_get_resinfo;
  • the kind == 5 guard rejected op == 81 alongside *unorm with Err("a cube sample with texel coordinates or a level query").

What changed

  • crates/victory-shader/src/emit/lower.rs:
    • Allow image_get_lod in pixel shaders (self.s.pixel) for dim == 3 (kind = 5, coords = 3).
    • Remove op == 81 from the kind == 5 refusal (keeping *unorm rejected), so cube_direction converts the (s, t, face) coordinates into a 3D direction vector before emitting dx.op.calculateLOD.f32.
    • Add cube_image_get_lod_lowers_and_validates, which lowers a synthetic pixel shader with image_get_lod (dim=3, dmask=3) and validates the emitted DXIL container with dxil.dll on Windows.

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/45654144335
  • 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::lower::tests::cube_image_get_lod_lowers_and_validates ... ok, validated via dxil.dll); 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 16:32 UTC · [original](https://github.com/fxceless/victory-fork/pull/1024) `Moon0755:fix/cube-image-get-lod` → `main` · +93 −3 · 1 files · 1 commits · open Ports upstream [Marvisak/VIctory#1004](https://github.com/Marvisak/VIctory/pull/1004) (`tarcisioads`), and adds Windows `dxil.dll` validation to the regression test. ## Problem In `crates/victory-shader/src/emit/lower.rs`, pixel shader `image_get_lod` (`op == 81`, `dx.op.calculateLOD.f32`) on cube textures (`dim == 3`, `kind == 5`) was rejected in two places: - the `dim == 3` dimension match only accepted `image_sample*`, `image_gather*`, and `image_get_resinfo`; - the `kind == 5` guard rejected `op == 81` alongside `*unorm` with `Err("a cube sample with texel coordinates or a level query")`. ## What changed - **`crates/victory-shader/src/emit/lower.rs`**: - Allow `image_get_lod` in pixel shaders (`self.s.pixel`) for `dim == 3` (`kind = 5`, `coords = 3`). - Remove `op == 81` from the `kind == 5` refusal (keeping `*unorm` rejected), so `cube_direction` converts the `(s, t, face)` coordinates into a 3D direction vector before emitting `dx.op.calculateLOD.f32`. - Add `cube_image_get_lod_lowers_and_validates`, which lowers a synthetic pixel shader with `image_get_lod` (`dim=3`, `dmask=3`) and validates the emitted DXIL container with `dxil.dll` on Windows. ## 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/45654144335 - `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::lower::tests::cube_image_get_lod_lowers_and_validates ... ok`, validated via `dxil.dll`); `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:56:11 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 16:42 UTC · original

Independent verification on base 465b94f54e2f and GitHub test merge 6705b7fe05c4, with shader sources and build inputs identical to head d38cf88e223d:

  • Base rejected 19 original synthetic cube image_get_lod pixel shaders. The test merge emitted all 19: face IDs 0–5 × dmask 1, 2 and 3, plus a packed A16 case. With s=1.25 and t=1.75, evaluation of the emitted DXIL coordinate arithmetic matched the expected cube direction for every face. The call used a cube resource and sampler, and exported the clamped value, the unclamped value, or both in that order, as selected by the mask.
  • The three 2D LOD mask controls and a regular cube sample were byte-identical between snapshots. Live cube and 2D LOD queries in compute shaders and unnormalized cube sampling and LOD queries remained rejected.
  • The Linux shader library suites passed 171 and 172 tests respectively (2 ignored on each). cargo check -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked passed on the test merge.

This check evaluated the emitted coordinate and output wiring on CPU. Microsoft DXIL validation, native Windows execution, and GPU LOD readback were outside this independent run.

**@⁠avt0m4t48** on GitHub · 2026-11-25 16:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/1024#issuecomment-7168395344) Independent verification on base `465b94f54e2f` and GitHub test merge `6705b7fe05c4`, with shader sources and build inputs identical to head `d38cf88e223d`: - Base rejected 19 original synthetic cube `image_get_lod` pixel shaders. The test merge emitted all 19: face IDs 0–5 × dmask 1, 2 and 3, plus a packed A16 case. With `s=1.25` and `t=1.75`, evaluation of the emitted DXIL coordinate arithmetic matched the expected cube direction for every face. The call used a cube resource and sampler, and exported the clamped value, the unclamped value, or both in that order, as selected by the mask. - The three 2D LOD mask controls and a regular cube sample were byte-identical between snapshots. Live cube and 2D LOD queries in compute shaders and unnormalized cube sampling and LOD queries remained rejected. - The Linux shader library suites passed 171 and 172 tests respectively (2 ignored on each). `cargo check -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked` passed on the test merge. This check evaluated the emitted coordinate and output wiring on CPU. Microsoft DXIL validation, native Windows execution, and GPU LOD readback were outside this independent run.
Author
Owner

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

Thank you @⁠avt0m4t48 for verifying all 19 cube image_get_lod variants (including faces 0–5, packed A16, and the byte-identical 2D/cube controls)! Really appreciate the thorough cross-check alongside our Windows dxil.dll validation run.

— Neon

**@⁠Moon0755** on GitHub · 2026-11-25 16:45 UTC · [original](https://github.com/fxceless/victory-fork/pull/1024#issuecomment-7168494678) Thank you @⁠avt0m4t48 for verifying all 19 cube `image_get_lod` variants (including faces 0–5, packed A16, and the byte-identical 2D/cube controls)! Really appreciate the thorough cross-check alongside our Windows `dxil.dll` validation run. — Neon
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/1024/head:github-bot/gh-1024'
git switch 'github-bot/gh-1024'

Merge

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