Shaders: the level of detail of an array texture takes no slice (3 programs) #720

Closed
github-bot wants to merge 1 commit from gh-pr/720/head into gh-pr/720/base
Owner

@⁠JRamos1993 on GitHub · 2026-11-25 05:38 UTC · original
JRamos1993:lod-array-coords → main · +160 −1 · 3 files · 1 commits · closed without merging

Part of #279.

Problem

3 pixel programs of the retail shader pack fail validation with out of bound coord must be undef. Their draws are dropped.

All three take the level of detail of a 2D array texture (image_get_lod, dim:SQ_RSRC_IMG_2D_ARRAY). The lowering passed calculateLOD all three coordinates, so the array slice went in as coord2. A level of detail only uses the spatial coordinates, and the validator wants the rest undefined. (The samples of the same texture in those programs pass the slice correctly.)

What

  • lower, image, op 81: calculateLOD takes the coordinates up to spatial, which is coords minus the slice of a 1D or 2D array; the others are undef. For every other texture kind they already were, since cs starts as undef.
  • Test: the_level_of_detail_of_a_2d_array_takes_no_slice, a synthetic pixel program with image_get_lod of a 2D array from a table. It emits, validates, and makes a pipeline on hardware and WARP. Without the change it fails with the same validator error as the title's programs.

Tested

RTX 5090, driver 621.24, Windows 11, main 310c6eb.

  • Retail pack, victory translate --validate --list:
    • 25,382 → 25,385 validated: the 3 programs. None lost.
    • With a local DXIL hash on each validated line, all 25,382 programs that validated before emit byte-identical DXIL.
  • Pipelines: --pipelines on the 3 creates 3 pipelines, 0 refused.
  • Checks:
    • cargo test -p victory-shader --locked --no-fail-fast -- --test-threads=4: 215 passed, 0 failed, 3 ignored.
    • cargo clippy -p victory-shader --all-targets --locked -- -D warnings, with and without --all-features: clean.
    • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4: 511 passed, 0 failed, 9 ignored.

Not tested

  • In game: these 3 programs are not reached in the scene my save gets to.
  • The returned level of detail: checked for validity only, not its value; the test host makes plain 2D views.

AI use

Claude Code with Claude Opus 5.5 found the failure on the retail pack, wrote the change and the test, ran the checks above and wrote this. The test uses a synthetic program. The title's shaders were only read on my machine, and nothing from them is in this PR.

**@⁠JRamos1993** on GitHub · 2026-11-25 05:38 UTC · [original](https://github.com/fxceless/victory-fork/pull/720) `JRamos1993:lod-array-coords` → `main` · +160 −1 · 3 files · 1 commits · closed without merging Part of #279. ## Problem 3 pixel programs of the retail shader pack fail validation with `out of bound coord must be undef`. Their draws are dropped. All three take the level of detail of a 2D array texture (`image_get_lod`, `dim:SQ_RSRC_IMG_2D_ARRAY`). The lowering passed `calculateLOD` all three coordinates, so the array slice went in as `coord2`. A level of detail only uses the spatial coordinates, and the validator wants the rest undefined. (The samples of the same texture in those programs pass the slice correctly.) ## What - **`lower`, `image`, op 81:** `calculateLOD` takes the coordinates up to `spatial`, which is `coords` minus the slice of a 1D or 2D array; the others are `undef`. For every other texture kind they already were, since `cs` starts as `undef`. - **Test:** `the_level_of_detail_of_a_2d_array_takes_no_slice`, a synthetic pixel program with `image_get_lod` of a 2D array from a table. It emits, validates, and makes a pipeline on hardware and WARP. Without the change it fails with the same validator error as the title's programs. ## Tested RTX 5090, driver 621.24, Windows 11, `main` `310c6eb`. - **Retail pack**, `victory translate --validate --list`: - 25,382 → **25,385 validated**: the 3 programs. None lost. - With a local DXIL hash on each validated line, **all 25,382 programs that validated before emit byte-identical DXIL**. - **Pipelines:** `--pipelines` on the 3 creates 3 pipelines, 0 refused. - **Checks:** - `cargo test -p victory-shader --locked --no-fail-fast -- --test-threads=4`: 215 passed, 0 failed, 3 ignored. - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4`: 511 passed, 0 failed, 9 ignored. ## Not tested - **In game:** these 3 programs are not reached in the scene my save gets to. - **The returned level of detail:** checked for validity only, not its value; the test host makes plain 2D views. ## AI use Claude Code with Claude Opus 5.5 found the failure on the retail pack, wrote the change and the test, ran the checks above and wrote this. The test uses a synthetic program. The title's shaders were only read on my machine, and nothing from them is in this PR.
`image_get_lod` was lowered to `calculateLOD` with three coordinates
whatever the texture, so on a 2D array the slice went in as the third. The
validator refuses that ("out of bound coord must be undef"): 3 pixel
programs of the retail pack stopped there. The coordinates past the spatial
ones are now undefined; for every other texture they already were.

A test emits `image_get_lod` of a 2D array, validates it and makes a
pipeline of it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:49:41 +00:00
github-bot closed this pull request 2026-11-26 03:49:41 +00:00
Author
Owner

@⁠JRamos1993 on GitHub · 2026-11-25 06:10 UTC · original

Closing as a duplicate of #260, which I missed when I checked for existing work (I searched issues, not pull requests). Sorry for the noise.

Measured on the retail pack against main 310c6eb (RTX 5090, local DXIL hash on each validated line):

  • #260 merged onto main validates the same 3 programs this PR does: 25,382 → 25,385. It loses none.
  • Every program's DXIL is byte-identical between #260 and this PR.

The synthetic test here (image_get_lod of a 2D array: emits, validates, makes a pipeline, and fails without the fix with the same validator error) is in crates/victory-shader/src/emit/image_lod_tests.rs on JRamos1993:lod-array-coords, if #260 wants one.

**@⁠JRamos1993** on GitHub · 2026-11-25 06:10 UTC · [original](https://github.com/fxceless/victory-fork/pull/720#issuecomment-7154512364) **Closing as a duplicate of #260, which I missed when I checked for existing work** (I searched issues, not pull requests). Sorry for the noise. Measured on the retail pack against `main` `310c6eb` (RTX 5090, local DXIL hash on each validated line): - #260 merged onto `main` validates **the same 3 programs** this PR does: 25,382 → 25,385. It loses none. - **Every program's DXIL is byte-identical between #260 and this PR.** The synthetic test here (`image_get_lod` of a 2D array: emits, validates, makes a pipeline, and fails without the fix with the same validator error) is in `crates/victory-shader/src/emit/image_lod_tests.rs` on `JRamos1993:lod-array-coords`, if #260 wants one.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.