Skip to content

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

Closed
JRamos1993 wants to merge 1 commit into
fxceless:mainfrom
JRamos1993:lod-array-coords
Closed

JRamos1993 wants to merge 1 commit into
fxceless:mainfrom
JRamos1993:lod-array-coords

Conversation

@JRamos1993

Copy link
Copy Markdown

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.
@JRamos1993

Copy link
Copy Markdown
Author

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):

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.

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.

1 participant