Shaders: fix GFX10 independent a16/g16 gradient dword packing in fields.rs with 21 tests #1116
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 geiyiliyabumo on 2026-11-24T15:52:36Z.
Summary
Fixes a real GFX10/RDNA2
image_addr_dwordsbug incrates/victory-shader/src/gfx10/fields.rs(previously 0 unit tests) wherea16and_g16gradient packing were conflated, and adds 21 deterministic synthetic unit tests covering a 47-case image-address matrix plus per-encoding field decoding.Because external PR creation is currently restricted (
collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:geiyiliyabumo/VIctory@test/shader-gfx10-fieldsgeiyiliyabumo/VIctory@bcce91f(based onmainffe310e)Changes (
crates/victory-shader/src/gfx10/fields.rs)a16and_g16are independent (a16packs coordinates/LOD/clamp/mip;_g16opcodes pack gradients, matching LLVM'sgetAddrSizeMIMGOp). Previouslyimage_addr_dwordspacked gradients undera16and failed to pack them for_g16withouta16(e.g.image_sample_d2D witha16=truereturned 3 instead of 5 dwords;_g16withouta16returned 6 instead of 4).crates/victory-shader/src/emit/lower.rs:5631appears to share the same stalea16assumption when reading gradient VGPRs.Verification (Windows 11 x64 MSVC)
rustfmt --edition 2024 --check crates/victory-shader/src/gfx10/fields.rs: PASScargo xtask policy: PASS (154 files ok)cargo clippy -p victory-shader --all-targets --locked -- -D warnings: PASS (0 warnings)cargo test -p victory-shader --locked -- gfx10::fields::: 21 passed, 0 failed (victory-shader141 passed, 1 ignored)AI-assisted; synthetic tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by kackosa on 2026-11-24T17:17:01Z.
Here is the follow-up fix addressing the stale a16 assumption in crates/victory-shader/src/emit/lower.rs:5631 noted in the issue description, ensuring gradient and coordinate VGPR unpacking works with independent a16 and _g16:
Matches image_sample_d, image_sample_d_o, image_sample_d_g16, and image_sample_d_o_g16 to op 63 (sampleGrad.f32).
Fixed offset_word detection for opcodes with o followed by other tokens (name.split('').any(|t| t == "o")).
Separated gradient and coordinate unpacking: gradients unpack from f16 only when _g16 is set (packed per direction); coordinates unpack from f16 only when a16 is set.
Fixed 32-bit dwords (offset, bias, cmp) so they aren't truncated by a16.
Added lowering tests for all 4 permutations of (g16, a16).
Complete patch:
0001-fix-gfx10-independent-a16-g16-gradient-packing.patch
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:03:49Z.
Automated triage for the maintainers.
Still present on
main(63bcca4):image_addr_dwordsincrates/victory-shader/src/gfx10/fields.rspacks gradients two per dword whenevera16is set and ignores the_g16opcodes. The lowering follows the same rule: thesampleGradarm of image lowering inemit/lower.rsreads 16-bit gradients undera16, and the_g16sample opcodes are refused at lowering. @DrDarkDK's check on #1535 shows the effect: ana16image_sample_d_osampled the wrong texel.Now addressed by open PR #2372 (labelled
triage: merge candidate). It carries both halves in one PR: #1209'sfields.rscommits cherry-picked with their author kept, plus the lowering change, with a GPU test that fails onmain(ana16image_sample_dreads 4000 instead of 3066). The 2026-11-26 comment offers a further fix on a fork (2d45b56) for ana16mip-query case on #2372's head, posted in that PR's discussion; it belongs in review there.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T03:25:47Z.
#2372 is the open PR carrying the independent gradient and coordinate packing changes for this issue. I tested the remaining a16 mip-query regression on its exact head
3c7c10f. The same Windows/WARP fixture reads0×0for two packed mip operands before the follow-up and4×2and2×1after 2d45b56. The fixture also passes on upstream63bcca4and in the patched merge. I posted the commit and test details in the existing PR discussion.Please retain the Git author when moving the follow-up, or add this trailer if you fold it into another commit.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted with Codex.