Shaders: biased samples with 16-bit coordinates #569
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/569"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by SAitken91 on 2026-11-24T05:03:35Z.
image_sample_bwith a16 was refused up front ("a biased image sample with 16-bit coordinates"): 108 programs in shaders.rpf, mostly mirror-reflection and ped pixel shaders.Change
legacyF16ToF32) instead of being read as f32._o) now read their coordinates from the dword after the offset. Before, they were read from the offset dword's high half.Results
victory translate --validate shaders.rpf: vertex/pixel validated 12172 → 12208 (44 more emitted). The error is gone from the list. The rest of the 108 stop at other cases further in.Testing
cargo test -p victory-shader: 69 passed. Clippy and rustfmt are clean.This is independent of #539, #554, #563 and #565.
Written with the help of Claude (AI).
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by KoLolX3 on 2026-11-24T05:31:48Z.
Check on Linux, not Windows: pass. Head
aed963792merged ontomaind2a4bae1f(clean merge).core,formats,game,loader,pe,pipeline,shader): PR92 passed, 7 failed,main92 passed, 7 failed.cargo xwin check --workspace --target x86_64-pc-windows-msvc, coversvictory-gpu,victory-hleand the app): PR ok,mainok.main168.mainhere as well (not this PR): 7 tests invictory-loaderandvictory-pethat parse their own test binary as a PE image, which is an ELF file on Linux.victory-gpu/victory-hletests and the game itself.On: AMD Ryzen 7 5700, 62 GB RAM, Artix Linux 7.3.4-artix1-2, rustc 1.98.1 (the repo's pinned toolchain), cargo-xwin 0.24.1. No game data. Automated check only: the code itself was not reviewed.
Imported from Marvisak/VIctory. Originally posted by iurysf on 2026-11-24T06:17:07Z.
Tested offline against main
d2a4baewithvictory translate --list --validateover the title'sshaders.rpf+ executable (26,096 programs), dxil.dll 1.9.2602.17:AI-assisted.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T07:10:56Z.
Review: APPROVED
Tested
aed9637on Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (264 passed, 0 failed).victory translate <title exe> --validate --pipelinesgives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines. These 12 do not use a16 samples, so I could not reproduce the shaders.rpf figures.legacyF16ToF32rather than reading it as f32 is right for that layout.No issues found.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T07:23:37Z.
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate, against maind2a4bae:cargo test -p victory-shaderAll four clear the 108 "biased image sample with 16-bit coordinates" programs identically. #73 and #318 also clear the 27
image_sample_d_clrefusals, but those programs then stop on another reason (emitted count unchanged). #306 additionally clears 15 of the 16 validator error kinds (only the mesh 32 KiB output size remains, see #459); it overlaps #554/#565/#381. Windows 11, dxil.dll from SDK 10.0.26100.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T12:44:22Z.
Review: COMMENTED
This enables
image_sample_b*(biased image sample) with 16-bit coordinates, which was previously rejected. The operand-layout reasoning in the comment is coherent: witha16, each whole-dword extra (texel offset word, the bias itself, compare value) occupies two 16-bit slots, hencefirst = 2 * extras, and the bias is read withto_floatinstead ofas_floatbecause it sits in the low half as f16.Two things before this can be approved:
valu_testscase for a biased image sample with a16 coordinates — this is exactly the kind of operand-indexing change that silently reads the wrong VGPRs if the2 * extrasmath is off. A host-execution test (therun_wave_cs-style harness or an image-sample variant) would pin it.Test-merge with current main (
ffe310e) is clean;cargo test -p victory-shader --locked(macOS arm64, rustc 1.98.1) → 96 passed / 0 failed — existing tests unaffected, but they don't touch the new path.Imported from Marvisak/VIctory. Originally posted by SAitken91 on 2026-11-24T13:42:33Z.
@catminou4 agreed on the missing test. The layout follows LLVM's AMDGPU MIMG lowering (bias is f16 in the low half of a whole dword under a16; offset and compare stay whole dwords), which mercuryVM checked against the same reference on RTX 5070 earlier; the gain is measured on the title's shaders (+36 VS/PS validated) but no test executes an a16 biased sample yet. A Windows-gated host-execution case with a16 coordinates and a non-zero bias would pin the
2 * extrasindexing.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:25:06Z.
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.a16 biased samples are in main's image() (extras keep a VGPR each, bias converted with legacyF16ToF32).
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed