Skip to content

Tests: the dot products run with operands loaded at run time, not literals - #1900

Closed
fiestorra wants to merge 1 commit into
Marvisak:mainfrom
fiestorra:test/dot4-operands-from-user-data
Closed

fiestorra wants to merge 1 commit into
Marvisak:mainfrom
fiestorra:test/dot4-operands-from-user-data

Conversation

@fiestorra

Copy link
Copy Markdown
Contributor

The test no longer needs literals: its operands come from user data now

I took the two things the report settled into a change, because you are right that the translator is not where the fix goes and the test is.

What changes: fspx_programs_run_with_the_hardwares_dot_products builds its program with build_valu_cs — a plain compute shader whose four root constants are the case's inputs — and the multiplicands and accumulator reach v_dot4_i32_i8 through v_mov_b32 vN, sN at run time, instead of v_mov_b32 vN, <literal>. The case inputs are [a, b, acc, 0], so the three literal-multiplicand cases are gone.

Why the operands could not stay literals in an FSPX program: in an ACCC-shaped program the user data are the hardware's own SGPRs (s0-s3 are the thread's ids), so a shader of that shape cannot carry operands at all — it can only name them as literals, which is exactly the form the RDNA1 driver folds into v_dot4c and zero-extends. So the test runs the same instructions with values loaded at run time, which is the shape a title's shader has whenever its multiplicands are computed rather than declared. Its fspx_cs helper goes with the change (nothing else used it), and the doc comment says why the program is no longer ACCC-shaped.

What I could not verify, said plainly: my machine is an RTX 4090, where the literal and run-time forms agree, so here the test passed before and passes after — 209 passed, 2 ignored, unchanged. The evidence that it now passes on RDNA1 is yours to give; the reasoning is your table, where "none" and "accumulator only" are the signed result and every case with a literal multiplicand is not. The inline 2.0 (sel_hi_lo, bytes below 0x80) is untouched and stays a constant, as you said it could.

Recipe: cargo test -p victory-shader --locked --lib (209 passed, 2 ignored); cargo clippy --workspace --all-targets with and without --all-features clean under -D warnings; rustfmt --check 0 hunks on the file, which is also 0 on main, so nothing of the file was reformatted.

Pull request: #1893

No game data is involved: an opcode, two constants and test counts.

Written with an AI assistant.

…erals

On an RDNA1 host the driver folds a constant multiplicand into the dot
instruction's constant form (v_dot4c) and zero-extends that operand's bytes,
so v_dot4_i32_i8 with a literal v_mov operand gives 0x80007FF5 where the
signed product is 0x7FFFFBF5 (Marvisak#1782, measured on an RX 5700; WARP and
runtime operands agree with the reference everywhere).

That is the driver's, not the lowering's, so what changes here is the test:
its operands reach the shader through the user data of a plain compute
shader, which is the shape a title's shader has when its multiplicands are
computed, and the three cases that used a literal multiplicand now use those
values. An FSPX-shaped program cannot carry them - its user data are the
hardware's own SGPRs - which is why the test had literals in the first place;
its helper goes with the change, and the doc comment says so.

209 passed, 2 ignored on this machine, where both forms agree; the case for
the change is the RDNA1 card in the issue.
@fiestorra
fiestorra force-pushed the test/dot4-operands-from-user-data branch from d2241ba to 799f9a2 Compare November 25, 2026 01:42
@Headache3318

Copy link
Copy Markdown

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 799f9a2 applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 144 passed, 0 failed, 2 ignored. All tests pass.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 4 pre-existing errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

1 similar comment
@Headache3318

Copy link
Copy Markdown

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 799f9a2 applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 144 passed, 0 failed, 2 ignored. All tests pass.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 4 pre-existing errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 25, 2026
…rands loaded at run time, not literals

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 3bdccbc on Windows 11, RTX 5070, MSVC:

  • cargo test -p victory-shader -- --test-threads=1 passes the dot-product test on the head.
  • The 5 failures there (rect corner, two stride tests, row order, gather4 at a level) also fail on main on this host.
  • Merged into our fork together with #1896: the same results, and clippy is clean.

Loading the operands as user data is the right test. With literals, the driver folds them into the dot's constant form, so the test was really checking a driver fold, not the translation. A title's operands are computed at run time, which is what the test now does.

AI-assisted (Claude Code).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. Dot-product tests load operands at runtime so the hardware path is exercised rather than constant-folded — same class of fix as #1879, good.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Proposed close: duplicate of a better open PR, #1790. Both PRs fix the RDNA1 failure of emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products (#1782), and both pass on the reporter's RX 5700 (comparison table in #1782). This PR does it by deleting fspx_cs and running the cases through build_valu_cs. The test no longer exercises the ACCC container path its name and purpose refer to. #1790 makes the operands run-time values (v_add_nc_u32 vN, literal, v4 with v4 loaded from the zeroed UAV). It keeps the ACCC program, the cases and the expected values, and its author showed the test still catches a signed/unsigned lowering error.

CI check passes here. The change itself is not wrong. It just covers less than #1790 for the same fix.

This PR will be closed in 48 hours unless the author pushes a change (for example, one that keeps the ACCC path) or a maintainer removes the label.


Generated by Claude Code

@sinan-cmyk

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

I merged head 799f9a2 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 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).

@fiestorra

Copy link
Copy Markdown
Contributor Author

Closing: main runs the dot products with run-time operands already

Main's 49761f9 ("Shader tests: dot products take their operands at run time", #1790) made the operands a literal plus a word of the zeroed UAV, which is the change this branch proposed, and the comment in main now names the same reason (#1782: the RDNA1 driver zero-extends bytes of a multiplicand it sees as a constant). Nothing left to rebase.

Written with an AI assistant.

@fiestorra fiestorra closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants