Shaders: sweep typed buffer formats and f16 ALU against exact references #1574
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1575"
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?
Imported from Marvisak/VIctory. Originally posted by DovisLe on 2026-11-24T19:23:39Z.
Two
#[ignore]d synthetic sweeps incrates/victory-shader/src/emit/valu_sweep_tests.rs. Each one runs on the host GPU and on WARP, compares the results with exact references computed on the CPU, and prints every mismatch grouped by backend, operation and channel, with an example input.sweep_typed_buffer_formats: all 77 GFX10 buffer formats throughtbuffer_load_format_xyzw, with 72 input sets per format. The reference is the ISA conversion: UNORM and SNORM correctly rounded, the scaled and integer formats, the small floats, and missing channels 0, 0, 0, 1.SWEEP_NORM_ONLY=1limits it to the 20 norm formats (about 2 minutes).SWEEP_D16=1addstbuffer_load_format_d16_xyzw, which needs #169.sweep_f16_alu:v_add/sub/mul/fma_f16,v_pk_add/mul/fma_f16(both lanes),v_cvt_f16_f32andv_cvt_f32_f16, against the f64 result rounded to the nearest-even half.They're meant for checking rounding fixes. Results on a Radeon 860M (RDNA 3.5, driver 32.0.32029.2010) and WARP:
main(ccfb029, after the rebase)mainbefore the rebasev_fma_f16fixed; the rest needs #422)run_wideisrun_caseswith a 4-dword UAV, so the wide formats' inputs fit. The normal suite is unchanged (cargo test -p victory-shader --lib: 120 passed, 0 failed).cargo clippy -p victory-shader --all-targets [--all-features] --locked -- -D warningsis clean. Run the sweeps withcargo test -p victory-shader --lib sweep -- --ignored --nocapture.A side finding: WARP's
uitofprounds twice for inputs of 2^31 and up. The 860M is correct.AI-assisted (Claude). Tested on a Radeon 860M and WARP.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T19:30:29Z.
Review: APPROVED
Verified locally merged onto
origin/main(Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib(default suite compilesvalu_sweep_tests.rscleanly and respects#[ignore]onsweep_typed_buffer_formatsandsweep_f16_alu)cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— okClean opt-in sweep harness comparing typed buffer formats and f16 ALU ops against exact f64 RNE reference calculations across hardware and WARP. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by matheusfermiano-source on 2026-11-24T19:32:51Z.
The same sweeps on a second AMD GPU and driver, an RDNA2 Radeon 660M under Proton on Linux (RADV, Mesa 26.3.1, vkd3d-proton 3.1.0). They agree with your table.
main+ this PR (856f0ce)a746d53) +valu_sweep_tests.rs4f5fa47) +valu_sweep_tests.rsmainthe f16 groups coverv_add,v_sub,v_mul,v_fma,v_pk_add,v_pk_mul,v_pk_fmaandv_cvt_f16_f32. Example:v_add_f16(0x7bff, 0x7bff)gives0x7bff, want0x7c00.mainthe norm groups cover 17 formats, from8_UNORMto16_16_16_16_SNORM, all off by one ulp. Example:8_8_8_8_UNORMof0x7fgives0x3efeff00, want0x3efefeff.emit::tests::stub_pipeline_is_created, fails onmainhere too, because vkd3d-proton accepts a zeroed DXIL hash (see #1218).Built on Linux with llvm-mingw for
x86_64-pc-windows-gnullvm(Rust 1.98.1);dxil.dllfrom DXC 1.9.2609 was loaded. Synthetic tests only, no game files. AI-assisted (Claude Code, Opus 5.5); every run was on this machine.Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-24T20:32:19Z.
On PR head
856f0ce, the RTX 5080 reproduced the normalized-buffer rounding differences reported on Radeon. Native WARP matched the CPU reference for every typed-buffer result. Both adapters showed the same half-precision mismatch counts in each operation group.Of the 205 RTX buffer mismatches, 169 were UNORM and 36 were SNORM. For example, loading
0x7fas8_UNORMshould yield the nearest float32 to127/255, bit pattern0x3efefeff. The RTX returned0x3efeff00, one representable float higher. WARP matched the reference. For FP16, both adapters returned0x7bff(65,504) forv_add_f16(0x7bff, 0x7bff); the nearest-even result is0x7c00(positive infinity).Windows 11 build 26300.10075, NVIDIA driver
32.0.16.2124, Rust1.98.1MSVC. Test-only logging identified the D3D12 devices by adapter LUID as NVIDIA GeForce RTX 5080 and Microsoft Basic Render Driver. The FP16 counts above include both lanes of packed operations. The two sweeps completed in 567 s and both failed their reference assertions.Follow-up with the two rounding fixes. I merged #422 (
a746d53, round-to-nearest-even FP16 conversion) and #1112 (4f5fa47, normalized typed-buffer loads) into the same #1575 head and reran both full sweeps on the same adapters. All mismatch counts dropped to zero.Both adapters now return
0x3efefefffor8_UNORM(0x7f)and0x7c00for the FP16 overflow example above. The sweeps passed in 559 s with the same CPU references and all 77 formats enabled. The ordinary shader library suite reported 123 passed, 0 failed and 3 ignored (the two opt-in sweeps and a benchmark). Four optional compiler-comparison cases reported skips within the pass count.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:31:12Z.
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main:mainhas moved since the last triage, and the branch now conflicts incrates/victory-shader/src/emit/valu_tests.rs. It will be reviewed again once it is rebased onto currentmain.Previous verdict for this head: merge candidate.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:48:06Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.144 passed / 0 failed / 2 ignored. Typed-buffer format + f16 ALU sweep against exact reference — broad conformance coverage; the sweep itself is the value.
Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:25:08Z.
Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at
2974745.cargo test --workspace --locked --no-fail-fast-> 693 passed, 5 failed, 12 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T01:54:52Z.
@DovisLe I resolved the conflict with main
63bcca43on your original2974745history. Both default sweeps now pass on the RTX 5080 (621.40) and built-in Microsoft WARP. Each adapter independently matched 21,252/21,252 typed-buffer channels and 2,076/2,076 FP16 lane results (1,716 ALU/conversion readback dwords). The 77-format sweep now dispatches all 69 inputs for a format together and fails if neither adapter runs. Tested branch · Conflict resolution aloneThe optional D16 reference needed three adjustments. UINT/SINT saturate, normalized channels round the exact ratio once, and 32-bit FLOAT narrows toward zero. I also added the four 16-bit UNORM/SNORM codes that distinguish single rounding from conversion through f32. NaN payloads are still accepted by class. Native RDNA2 buffer measurements · FLOAT behavior and cross-backend regression
D16 mismatches per adapter, across 22,484 field comparisons (77 formats × 73 input rows × 4 channels). @dooprazol, the two middle rows show which conversions your scaled fix and the normalized fix each cover. The RTX 5080 and WARP returned the same counts in every column.
63bcca43628ab89)95dc5d2, includes #1927)For example, #2843 alone gave
0x3bfefor16_UNORM(0xffaf); a single rounding gives0x3bfd. Conversely, #1940 alone gave0x7bfffor16_USCALED(65535); the nearest half is infinity (0x7c00), which #2843 produced. Both backends passed all 22,484 ordinary 32-bit channel checks in the optional run as well. The combined branch passes strict shader Clippy and the asset policy check. These are synthetic Windows readbacks. Reproducible combined branch · 32-bit #1940 follow-upTo pick up the test changes on your PR branch:
In PowerShell, set
$env:SWEEP_D16 = '1'before the command to run the optional D16 comparison.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.