Shaders: v_fmac_f32 in VOP3 applies abs and neg to its accumulator #3158
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!3158
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3158"
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?
@Moon0755 on GitHub · 2026-11-26 10:30 UTC · original
Moon0755:fix/fmac-accumulator-modifiers→main· +46 −1 · 2 files · 1 commits · openProblem
In the VOP3 encoding
v_fmac_f32(0x12B) has two explicit sources; the accumulator is the destination register. Bit 2 ofabsand ofnegstill acts on RDNA2: it applies to the accumulator.fields.rsdecodes the bit, but the arm inlower.rsreads the accumulator without it, so the modifier is dropped with no refusal.Example:
a = 1.0,b = 2.0, accumulator1.0,negbit 2. RDNA2 gives1.0(0x3f800000),maingives3.0(0x40400000).Source of the expected values
The AnyPS5 project measured this on RDNA2 (RX 6750 XT, gfx1031). Its PR 18285 reports 1,372 rows in each of four float-mode settings:
negbit 2 givesfma(a, b, -d)andabsbit 2 givesfma(a, b, |d|)on every row, and the src2 register field is ignored. It keeps 16 rows in its testcore/libs/prx/libSceAgcDriver/tests/execution/VFmacF32AccumulatorModifiers.cpp. The test here uses those 16 rows as numbers, from the table for IEEE mode off with 32-bit denormals flushed (the modesemantics_tests.rsmodels). No code is taken from that project.Fix
In the
v_fmac_f32arm oflower.rsthe accumulator getsabsandnegbit 2 the way a source gets its bits: the absolute value first, then a subtraction from -0.The arm is shared with
v_mac_f32andv_mac_legacy_f32, so they get the same treatment. There is no measurement for those two; before this change they dropped the bit asv_fmac_f32did.Test
New:
semantics_tests::v_fmac_f32_accumulator_modifiers_match_rdna2_oracle, the 16 measured rows throughnegbit 2 and throughabsbit 2 (signed zeros, infinities, NaN and denormal accumulators, a sum that cancels to zero). No existing test or model changes; the existing probes leave bit 2 out for the two-source forms.Verification
GitHub Actions on
windows-latest, on the fork, with the jobs narrowed tovictory-shaderandxtask. The runner has no hardware adapter, so the probes ran on WARP only.303 passed; 0 failed; 3 ignored; both probes report 0 model mismatches;302 passed; 1 failed, the new test only, with 12 of 16 mismatches fornegand 8 of 16 forabs.Not checked
v_mac_f32andv_mac_legacy_f32with bit 2: by analogy only, as said above.neg: RDNA2 flips the NaN's sign bit (two of the 16 rows). The test accepts any NaN there, as the other float probes do, and the negation is the same subtraction the sources use.— Gemini & Fable
@cloph-dsp on GitHub · 2026-11-26 10:40 UTC · original
Independent local verification of head
cf8f543on Windows 11, Rust 1.100.0/MSVC:VICTORY_WARP=1 cargo test --locked -p victory-shader --lib emit::semantics_tests::v_fmac_f32_accumulator_modifiers_match_rdna2_oracle— 1 passed, 0 failed.git diff --check origin/main HEAD— clean.Host GPUs: RTX 5060 Laptop (driver 621.24) and Radeon 780M RDNA3; this run used WARP. A worktree-local
CARGO_TARGET_DIRwas used to avoid a stale shared-target binary. Synthetic operand cases only; no game assets or DRM material used. AI-assisted (Hy4 flash).@oni-swr on GitHub · 2026-11-26 10:44 UTC · original
Independent WARP verification of head
cf8f543c(parent main63bcca4). Synthetic only, no game data.Setup:
VICTORY_D3D12_WARP=1,VICTORY_WARP=1; DXGI adapter reported "Microsoft Basic Render Driver" (software, 0 video memory); the physical GPU was not opened. Both the "hardware" and "warp" labels in the semantics harness resolve to WARP underVICTORY_WARP=1. dxil.dll 1.8.2502.11 validated every module. rustc: rustc 1.98.1 (48a229cea 2026-09-01).cargo test -j 4.Result: no defect found in the change.
emit::semantics_tests::v_fmac_f32_accumulator_modifiers_match_rdna2_oraclepasses on head. Withlower.rstaken from main and the PR's test kept, it fails: neg row set 12 of 16 mismatches, abs row set 8 of 16 (e.g.negwith[1.0, 2.0, 1.0]wants0x3f800000, main gives0x40400000). So the test discriminates the fix.abs[2]andneg[2]together, 24 inputs (acc in ±0, ±large, ±fractional; a in 2, -3, 0.25), expectedfma(a, b, -|acc|)from an independent f32 model: 0 mismatches on WARP.-0.0 - acc) is the same form used for the other VOP3 source modifiers inlower.rs; abs is applied before neg, as the modifier order requires.cargo test -p victory-shader --no-fail-fast -- --test-threads=1: head 299 passed, 4 failed, 3 ignored; main 298 passed, 4 failed, 3 ignored. The same 4 fail on both (synthetic_tests:a_mask_joined_with_data_at_a_uniform_loop_is_its_number,gathers_at_a_level_match_the_hardware,permutes_mask_high_address_bits_and_divergent_branches,permutes_read_the_lane_named_and_zero_from_lanes_left_out), so none comes from this PR.Limits: the 16 expected rows in the PR's test are quoted from an external hardware measurement; I did not have that source or RDNA2 hardware, so I checked WARP against the PR's rows and my own model, not against a console. The edit sits in the arm shared by
v_mac_f32andv_mac_legacy_f32; VOP2 encodings carry no abs/neg bits so they are unaffected, and I did not look for or add a VOP3 test of those two.AI use: Claude Code (Claude Sonnet 5.5) ran this verification; Claude Code (Claude Opus 5.5) coordinated. No game files, dumps, shader names or hashes were used.
@Dukestar69 on GitHub · 2026-11-26 10:50 UTC · original · approved these changes
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-shader --lib v_fmac_f32_accumulator_modifiers_match_rdna2_oracle -- --test-threads=1: passed on RTX 5090 and WARP.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Clean fix applying VOP3
abs/negmodifiers to thev_fmac_f32accumulator.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@JAEdotUK on GitHub · 2026-11-26 12:51 UTC · original
Hardware test report: head
cf8f543Environment: AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029, Windows 11 (10.0.26200.9974), rustc 1.98.1. WARP not forced. The harness output does not name the adapter; the RX 9070 XT is the only physical GPU in this machine (the other adapters are virtual displays), so the "hardware" label is that GPU.
cargo test -p victory-shader --lib --locked v_fmac_f32_accumulator_modifiers_match_rdna2_oracle -> 1 passed, 0 failed. Both probes: 16 inputs, model mismatches hardware 0, warp 0, hardware/warp differ on 0.
Control: with lower.rs taken from main and the PR's test kept, the same test fails. Neg probe: hardware 13 and warp 12 of 16 mismatches. Abs probe: hardware 9 and warp 8 of 16. Hardware and warp also disagree on 2 rows in each probe on main (for example inputs 7f7fffff, 40000000, ff7fffff: hardware 7f7fffff, warp 7f800000); with the PR applied they agree on all rows.
Not run: v_mac_f32 / v_mac_legacy_f32 with bit 2, Clippy, xtask policy, any game files. Synthetic tests only.
AI use: this report was prepared with Claude (Claude Sonnet 5.5); the test run was done by me on my own machine.
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.