Shaders: fix GFX10 independent a16/g16 gradient dword packing in fields.rs with 21 tests #1209
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!1209
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1209/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?
@geiyiliyabumo on GitHub · 2026-11-24 16:26 UTC · original
geiyiliyabumo:test/shader-gfx10-fields→main· +1193 −51 · 2 files · 2 commits · closed without mergingSummary
Closes #1116
Full verification details and change notes are documented in #1116 (commit
bcce91f, based onmainffe310e).Verification (Windows 11 x64 MSVC)
rustfmt --edition 2024 --checkon edited files: PASScargo xtask policy: PASS (zero game files/data)cargo clippy --all-targets --locked -- -D warnings(default +--features diagnosticswhere applicable): PASSAI-assisted; synthetic tests only, no game files.
@shortselow-byte on GitHub · 2026-11-24 16:51 UTC · original
Tested at head
bcce91f(onmainffe310e): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT.gfx10::fields21 passed; workspace 363 passed, 0 failed; both clippy runs (default and--all-features) clean;cargo xtask policyok.The a16 rule here matches what I found independently from LLVM's GFX10 assembler tests (
gfx10_asm_mimg.s):image_sample_d2D a16 → 5, 3D a16 → 8,image_sample_cd_cl2D a16 → 6,image_sample_c_d_o2D_ARRAY a16 → 8 (details in a comment on #318, which packs gradients under a16 the other way).The
lower.rsfollow-up you mention exists on my fork, since I can't open PRs here:shortselow-byte/VIctory@6fab60con branchshader/gfx10-operand-size-tests. It addsimage_address(k, whole, a16)(offset, bias, compare and gradients take a VGPR each; with a16 the coordinates and LOD/mip go two per VGPR), reads gradients as f32, and has a unit test. With only itslower.rspart applied on top of this PR (keeping yourfields.rs),image_addresses_after_whole_dwordspasses, the workspace has 364 passed, 0 failed, and both clippy runs are clean. Not run against the title.@fuzeofficlal on GitHub · 2026-11-24 16:53 UTC · original
Heads-up on a silent miscompilation hazard if
fields.rsis updated without updating the consumer incrates/victory-shader/src/emit/lower.rs:image_sample_dwitha16 = true(g16 = false) reads the wrong VGPRs inLower::image: Onceimage_addr_dwordssizes 2Dimage_sample_d ... a16to 5 VGPRs (4 full-dwordf32gradients + 1 packedf16coordinate dword),Lower::imagestill indexes both gradients and coordinates throughaddr_val(first + ...)using*a16(k / 2) and passes the gradients throughlegacyF16ToF32. That reinterprets the low/high 16 bits of thef32dhgradients asf16, and readsv2(dvxbits) as the(u, v)texture coordinates instead ofv4!image_sample_d_g16and whole-dword prefix (_o) witha16:Lower::imagedoes not yet match"image_sample_d_g16", and indexingoffset_word(_o) throughaddr_val(0)whena16 = truemasks off its upper 16 bits. Splittingaddr_at(base, half, k)so0..firststays full dwords, gradients unpack fromfirstandfirst + grad_regsbyg16, and coordinates unpack fromfirst + 2 * grad_regsby*a16keeps decoding and lowering aligned.Verified across all four
(a16, g16)combinations withdxil.dllvalidation and anisotropic 4x4 quadrant/gradient GPU readback on RTX 5090 and WARP — reference commit if you want to fold theemit/lower.rsside into this PR:github.com/fuzeofficlal/VIctory@d4022c4c28@geiyiliyabumo on GitHub · 2026-11-24 17:16 UTC · original
Thanks @shortselow-byte and @fuzeofficlal for verifying the RDNA2 \16/_g16\ rule and flagging the \emit/lower.rs\ consumer mismatch!
Folded the \Lower::image\ fix into this PR so decoding and lowering stay aligned:
Re-verified \gfx10::fields\ (21/21 passed), \emit::lower\ (11/11 passed), \cargo clippy -p victory-shader --all-targets -- -D warnings, and \cargo xtask policy.
AI-assisted; synthetic tests only, no game files.
@rezioliver-collab on GitHub · 2026-11-24 17:33 UTC · original
I ran an offline A/B comparison of
ffe310eandbcce91fon Windows 11 with Rust 1.98.1 (MSVC) anddxil.dll1.8.2502.11. I ranvictory translate --validate --list --jobs 1twice per revision against the same localshaders.rpf.Each run processed 26,503 containers and validated 21,724 shaders (12,155 vertex/pixel, 1,417 compute, and 8,152 mesh). All 25,889 listed outcomes matched by archive offset and stage across the four runs, with zero validation gains or losses.
I also ran the same four synthetic 2D
image_addr_dwordscases on both revisions. A16-only went from 3 to the expected 5 dwords, and G16-only went from 6 to the expected 4. Both control cases passed on both revisions. All 21gfx10::fieldstests passed onbcce91f, andcargo xtask policypassed on both commits.These results cover the original
fields.rschange atbcce91f, before theLower::imagefollow-up.AI use : Assisted by GPT 6.2 Sol.
@Zipettte on GitHub · 2026-11-24 18:00 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at bcce91f:
cargo test -p victory-shaderpasses, 141 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@andrewpozdnakov7-jpg on GitHub · 2026-11-24 18:45 UTC · original
I ran the same synthetic 2D texture fixture against
bcce91fa689cb817671872c2ed930208df3fc9dfand the currentae0b48e6daf7dbbad8c5d8af504726f5efac1bf4on WARP. Atbcce91f,image_sample_dwith A16 coordinates returned red values[1.0, 1.0]instead of[5.5, 7.0]. Atae0b48e, both values matched for all four A16/G16 combinations. The sampler uses linear magnification and point minification, so the readback checks the coordinates and whether the gradients select the intended filter.The test-only commit is directly on
ae0b48e. With it, the shader suite on WARP passed 142 tests with one ignored. Microsoft DXIL validation, strict shader Clippy andcargo xtask policypassed.@geiyiliyabumo on GitHub · 2026-11-24 21:07 UTC · original
Thanks @andrewpozdnakov7-jpg for the independent A/B verification on
ae0b48eacross all four A16/G16 combinations with DXIL validation!AI-assisted; synthetic tests only, no game files.
@Marvisak on GitHub · 2026-11-25 01:18 UTC · original · edited 2026-11-25 03:25 UTC
Automated triage for the maintainers.
Merge candidate. This makes a16 and g16 independent for image gradients.
image_addr_dwords(gfx10/fields.rs) packs gradients only for_g16forms, andLower::imagereads whole-dword prefixes (offset, bias, compare, mip) unpacked, gradients by g16, and coordinates and LOD by a16. It also mapsimage_sample_d_g16. The evidence is in the PR thread: LLVM's GFX10 assembler tests giveimage_sample_d2D a16 as 5 dwords, and a WARP readback matches all four a16/g16 combinations after the lowering fix. An A/B over 21,724 shaders showed no validation changes. The new indexing agrees withmain's op table (bias only onimage_sample_b, gathers unchanged). CI passes. Please put the LLVM reference in the description or a short comment. This takes a different approach from #318, which packs gradients under a16, so only one of them should land.Generated by Claude Code
@geiyiliyabumo on GitHub · 2026-11-25 02:31 UTC · original
Rebased cleanly onto \main\ (\
ccfb029), preserving cube 2D-per-direction gradients, \image_sample_d_cl, and \op == 81\ level-query coordinate count alongside independent \16/\g16\ unpacking. \cargo test -p victory-shader --locked fields::tests, \cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings, and \cargo xtask policy\ all pass.@Marvisak on GitHub · 2026-11-25 21:59 UTC · original
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing as a duplicate of #2372, which carries this PR's two commits unchanged (identical patch ids) and adds the lowering of
image_sample_d_cl_g16, removes the then-stale refusal of 16-bit gradients on 1D and 3D images, and adds a GPU readback test. The rule itself is right: a16 leaves gradients at 32 bits on a target with G16. One thing to carry over to #2372: under a16 this now readsimage_get_resinfo's mip as a whole dword, wheremaincorrectly takes the low 16 bits.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed