Shaders: biased samples with 16-bit coordinates #569
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!569
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/569/head"
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?
@SAitken91 on GitHub · 2026-11-24 05:03 UTC · original
SAitken91:shader/a16-biased-sample→main· +6 −5 · 1 files · 1 commits · closed without mergingimage_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
image_sample_b with a16 was refused ("a biased image sample with 16-bit coordinates"). With a16 the extra addresses (offset, bias, compare) still take a whole dword each, a bias being f16 in the low half (as LLVM's AMDGPU backend lays it out), and the packed coordinates start at the next dword. The extras now count two 16-bit halves each with a16, and the bias converts from f16. This also moves the coordinates of a16 gathers with offsets (`_o`) to the dword after the offset; they were read from the offset dword's high half. translate --validate on shaders.rpf: vertex/pixel 12172 -> 12208 validated (44 more emitted); the error is gone from the list. Co-Authored-By: Claude Opus 5.5 <[email protected]>@KoLolX3 on GitHub · 2026-11-24 05:31 UTC · original
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.
@iurysf on GitHub · 2026-11-24 06:17 UTC · original
Tested offline against main
d2a4baewithvictory translate --list --validateover the title'sshaders.rpf+ executable (26,096 programs), dxil.dll 1.9.2602.17:AI-assisted.
@slint6614-dev on GitHub · 2026-11-24 07:23 UTC · original
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.@SAitken91 on GitHub · 2026-11-24 13:42 UTC · original
@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.@Marvisak on GitHub · 2026-11-25 00:25 UTC · original
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