Shaders: abs / neg on the shift-add and align ops act on the sign bit #2020
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!2020
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2020"
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?
@upipibi on GitHub · 2026-11-25 03:16 UTC · original
upipibi:fix/int-sign-mods→main· +52 −5 · 2 files · 2 commits · openVOP3
absandnegonv_lshl_add_u32,v_add_lshl_u32,v_alignbit_b32andv_alignbyte_b32stopped translation with "integer operand modifiers". RDNA2 applies them to a source's bit 31, as for a float:absclears it andnegflips it. There is no integer negate or absolute value.Sources: boykopovar/AnyPS5#25964 measured every
abs/negcombination on the two shift-adds on gfx1036 (RDNA2) and gfx1201 (RDNA4), 196/196 words matching on each. boykopovar/AnyPS5#25799 measured the align ops on gfx1036: on src1 the bit reaches the result, and on src0 and the shift amount it can't change it. xcl-dev/xcl#2058 is the same fix in XCL, where the modifiers were silently dropped.What is in it
emit/lower.rs,src: for those four opcodes,absandnegbecomex & 0x7fffffffandx ^ 0x80000000on the source. Every other integer operation still returns "integer operand modifiers" when it has them, since only these four are measured.emit/valu_tests.rs:shift_add_and_align_take_sign_bit_modifierscovers neg on src2 ofv_lshl_add_u32, abs on src0 ofv_add_lshl_u32, and neg and abs on src1 of both align ops. Each case is built so the modifier can't be shifted out.Tested on Windows 11, RTX 3070 (Ampere, driver 616.56), debug, on
main940d32f:lower.rschange the build stops withUnsupported { what: "integer operand modifiers" }.cargo test -p victory-shader --locked: 245 passed, 3 failed, 3 ignored. The 3 are #1744's NVIDIA failures onmain.cargo clippy -p victory-shader --all-targets --locked -- -D warningsandcargo xtask policy: pass.Not tested: AMD hardware, a title.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
@jeremygold02 on GitHub · 2026-11-25 03:33 UTC · original
Triage verdict — Ready for maintainer decision; one useful test addition (
ea7dff7)Evidence
srclimits the sign-bit handling to the four measured opcodes. For those, it clears bit 31 before flipping it, consistent with the published shift-add and align measurements. Other integer opcodes still reject these modifiers.Checks and limits
Next step
This verification was AI-assisted.
@upipibi on GitHub · 2026-11-25 03:39 UTC · original
Added the combined case in
eed34ee. Two rows now set ABS and NEG on the same source:v_add_lshl_u32with-|src0|andv_lshl_add_u32with-|src2|on0x8000_0001. Both must give bit 31 set. With the two operations swapped locally (neg, then abs), the first row fails on hardware (0x00000004, want0x80000004), so the order is pinned now. RTX 3070 (616.56): the test passes, andvictory-shadergives 245 passed with only #1744's 3 NVIDIA failures, the same asmain.AI-assisted (Claude Code).
@Calvix2k on GitHub · 2026-11-25 03:42 UTC · original
Verified on Windows 10 19045 (RX 7800 XT), head
eed34eeplus the device-skip patch from #1991 (this host has no SM 6.6 device, so the probes would otherwise fail for an unrelated reason):cargo test -p victory-shader --lib— 248 passed, 0 failed, 3 ignored, includingabs and neg together on one shift-add source give -|x|.On the semantics: treating
absas clearing bit 31 andnegas flipping it is the right model for these four ops if the hardware does them as sign-bit operations rather than two's complement — and the order (abs then neg, so both set gives -|x|) matches the float convention the comment cites. Restricting it to the four names and keeping the refusal for the other integer ops is the conservative half, which I would keep.The GPU-valued cases skip here and run in CI; no unrelated failure in the suite on this tree.
@Marvisak on GitHub · 2026-11-25 09:18 UTC · original
Automated triage for the maintainers.
Merge candidate. Recommending a look, not approving.
emit/lower.rssrc, VOP3abs/negonv_lshl_add_u32,v_add_lshl_u32,v_alignbit_b32andv_alignbyte_b32now clear bit 31 (abs) and then flip it (neg) instead of stopping translation. Every other integer op still returns "integer operand modifiers". The evidence is cited: per-combination measurements on RDNA2/RDNA4 hardware in another project, linked in the PR.valu_tests.rsshift_add_and_align_take_sign_bit_modifiers, including the two combined abs+neg rows that fix the order of the two operations. Applying the bit operation to the align ops' shift operand is harmless because only its low bits are used.srcin a different way, so whichever lands second needs a small rebase.CI:
checkpassing.Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 09:50 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
eed34eedontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@bvtterbroot on GitHub · 2026-11-25 18:40 UTC · original
AMD check at
eed34ee(base940d32f), on an RDNA3 and an RDNA2 GPU:cargo test -p victory-shader -p victory-gpu --locked: 391 passed, 0 failed, 5 ignored, on both GPUs. That includes its new test (shift_add_and_align_take_sign_bit_modifiers).Synthetic tests only, no game files. Tested with AI assistance (Claude Code).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.