Skip to content

Shader tests: check 125 more instructions on the hardware - #2015

Open
0x00trace wants to merge 1 commit into
Marvisak:mainfrom
0x00trace:test/semantics-gaps
Open

0x00trace wants to merge 1 commit into
Marvisak:mainfrom
0x00trace:test/semantics-gaps

Conversation

@0x00trace

Copy link
Copy Markdown

The translator lowers 125 instructions that semantics_tests had no probe for (10 of them appear in other test files). This adds five tests that run them on the host GPU against a model of the ISA:

  • more_scalar_alu_matches_the_hardware: logic in both widths with SCC, 64-bit shifts and bit counts, carries and borrows through SCC, SOPK immediates, bit sets and tests, 64-bit compares and selects.
  • more_integers_match_the_hardware: high 24-bit products, v_mad_u64_u32/v_mad_i64_i32, v_sad_*, v_perm_b32, v_swap_b32, the reversed borrows.
  • sixteen_bit_integers_match_the_hardware: add, subtract, multiply, shifts, min and max, with the destination's high half kept.
  • more_floats_match_the_hardware: f16 floor, ceil, trunc and rndne, v_subrev_f16, and the literal f32 multiply-adds over operands whose result is exact.
  • more_compares_match_the_hardware: the i16, u16, i32, u32, i64 and u64 compares, and the f16 ones.

All of them pass, so nothing in the translator changes. To see that they can fail, I broke the lowering seven ways (signedness of v_mad_i64_i32, v_mul_hi_i32_i24 and the compares, s_bitset, v_sad_u16, s_flbit_i32, s_addk_i32); each break fails a test.

Left out: v_msad_u8, whose masking rule I could not settle from a public source, and v_mbcnt, which needs the lane's index in the model.

Tested on 940d32f, RTX 5080 (driver 620.73.04), MinGW build under Wine 11.22 with vkd3d-proton 3.1, no game data:

  • cargo test -p victory-shader --lib -- --test-threads=1: 243 passed, 4 failed on main; 248 passed and the same 4 failed here. One of the 4 is fixed by Shaders: floor, ceil and fract read denormals as zeros #1994.
  • Clippy for x86_64-pc-windows-msvc, also with --all-features: clean. cargo xtask policy: ok. The file stays rustfmt-clean.

Not tested on Windows, on WARP (there is none under Wine, so "warp" is the same GPU there) or on AMD.

🌴 AI-assisted, made with Claude Code · from astrosteveo/VIctory

Scalar logic in both widths, 64-bit shifts, carries through SCC, SOPK
immediates, bit sets and tests, 16-bit integers, differences, permutes,
64-bit multiply-adds, f16 rounding, the literal multiply-adds, and the
integer, 64-bit and f16 compares: the translator lowers them, and the
semantics tests had no probe for them.

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

Copy link
Copy Markdown

Native Windows result, RTX 5090 + WARP

Ran this branch (6c88e38, on 940d32f) natively on Windows 11 (10.0.26300), RTX 5090 (Blackwell, driver 32.0.16.1692), Rust 1.98.1 MSVC:

cargo test -p victory-shader --lib --locked -- --test-threads=1 semantics_tests → 37 passed, 0 failed, 1 ignored.

All five new tests pass on the hardware adapter and on WARP: 0 model mismatches on either, 0 hardware/WARP differences. Validator: Windows SDK dxil.dll 1.6.2112.

No game data; the title was not run. AI-assisted (Claude Code), run on my own machine.

@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. 125 more instructions covered by hardware checks — big test-coverage addition; the new checks are Windows-gated hardware tests so macOS only verifies compilation (144 green). Hardware run on Windows CI/dev machines is the real proof.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/semantics_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


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 6c88e38 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).

@sinan-cmyk

Copy link
Copy Markdown

more_floats_match_the_hardware fails on Ada with driver 32.0.16.1088

On an RTX 4070 SUPER (Ada, driver 32.0.16.1088, default adapter, VICTORY_WARP unset), with head 6c88e38 merged onto main 940d32f, cargo test --locked -p victory-shader --lib gives 248 passed and 4 failed. Three failures are the NVIDIA ones from #1835 that main has too. The fourth is new in this PR: emit::semantics_tests::more_floats_match_the_hardware.

Only the two probes with the denormal literal 0x00000001 differ. WARP matches the model on all of them:

Probe Hardware mismatches WARP mismatches
v_fmamk_f32 v5, v1, lit(0x00000001), v2 56 of 144 0
v_fmaak_f32 v5, v1, v2, lit(0x00000001) 28 of 144 0

The other literals (0x40400000, 0xbf800000) and the other new probes match on the hardware too.

Every mismatch fits one pattern. The driver seems to flush the literal to 0 and then fold the + 0 away:

  • fmamk (v1 * K + v2): the result is v2 unchanged. For example, v1 = 0, v2 = -0 gives 0x80000000 where the model wants +0. v2 = 0x00000001 comes back as 0x00000001 where the model wants it flushed to 0.
  • fmaak (v1 * v2 + K): the result is the product, with no + 0 applied. For example, 0 * -1 gives -0 (0x80000000) where the model wants +0.

@chemist6913's RTX 5090 with driver 32.0.16.1692 passes all five probes, so this may be fixed in newer drivers. I can't tell from these two runs whether the driver version or the GPU architecture makes the difference. Still, a merged test that fails on a current Ada driver will show up as red in NVIDIA test reports.

AI-assisted (Claude Code). Synthetic tests only.

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.

5 participants