Shader tests: verify every normalized MTBUF field without Int64ShaderOps #1112
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!1112
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1112"
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?
@Razdva122 on GitHub · 2026-11-24 15:49 UTC · original
Razdva122:shader/mtbuf-normalize-i32→main· +180 −0 · 2 files · 2 commits · closed without mergingThis PR adds regression coverage for normalized MTBUF loads from #1060. Main already contains the 32-bit rounding implementation from
da82e44. The remaining diff adds a test module and registers it in the shader test suite.The first test checks the DXIL feature flags for all 20 normalized formats and validates the shaders when a validator is available. The second dispatches synthetic shaders with separate input and output buffers, reads back the results and compares every present channel with an f64 reference rounded to f32. Together the cases cover 962,048 field values, including the packed 11-bit fields.
@steven-seagull27 supplied the updated merge and ran the tests separately on an RTX 5080 and Microsoft WARP. Both recorded zero mismatches, and all 20 shaders kept the Int64ShaderOps flag clear. Hardware and WARP results
AI-assisted with Codex.
@MichaelSmithAI on GitHub · 2026-11-24 15:55 UTC · original
We ran the two focused Win64 tests on the exact PR head
4f5fa47on an RTX 4090 under Wine/GE 3.2. Both passed. We then replaced the normalization arithmetic on our #1060 integration branch with this PR’s 32-bit rounder, retaining #1060’s missing-channel rule. Across all 20 normalized MTBUF formats, the GPU readback matched the f64 reference rounded to f32 for each present field, and every absent channel returned zero. The emitted DXIL for all 20 formats also passed the check for an absent Int64ShaderOps flag.This verifies that the two changes compose. The RTX 4090 supports Int64, so execution on hardware lacking that capability and any effect on title output remain open.
@adamdotpy on GitHub · 2026-11-24 16:34 UTC · original
Deep review on Windows 11 / Rust 1.98.1,
4f5fa47on currentmain(ffe310e, merges as it stands), isolated target dir.Verified here:
cargo test -p victory-shader --lib122 passed / 1 ignored, including both new tests —normalized_mtbuf_loads_need_no_int64(asserts SFI0 bit0x8000is clear for all twenty unorm/snorm formats and validates withdxil.dllwhen present) andnormalized_mtbuf_loads_round_every_field_value, which ran on the hardware GPU and WARP here. Clippy--all-targets --all-features --locked -D warningsclean;cargo build --release -p victorybuilds.I checked the rounding exhaustively, independently of the GPU test. I reimplemented
norm_bits's integer steps in Python and compared them against exact round-to-nearest-even (viaFraction) for every possible field value: all unorm widthsn = 1..16— 131,070 values — and all snorm widthsw = 2..16— 131,068 values. Zero mismatches in both. The most negative snorm input yields exactly-1.0, which is the console's behaviour and comes from clamping to-(2^(w-1)-1)rather than to the minimum representable. So the claim "correctly rounded for every field value" is now proven for the whole input space, not just the sampled rows the GPU test runs.Why the bit trick is right, which is the part worth a second read:
base = bits - (n << 23)is exactlyv / 2^nin f32 bits (no underflow forv >= 1andn <= 16), and multiplying by2^n/(2^n-1)addsM/(2^n-1)ULPs whereMis the 24-bit significand — an odd denominator, so(M + max/2)/maxrounds with no ties. Adding the correction to the bit pattern lets a full-scale input carry into the next exponent for free. The snorm sign survives becausebaseis computed from the signed bit pattern, and the sign bit is above the exponent field that gets decremented.Three smaller notes.
norm_bitssilently assumesn <= 24(exact significand) andn < 31(1 << non i32).buffer_formatonly yields norm widths up to 16 — the 32-bit families areUint/Sint/Floatand never reachnorm_bits— so it holds today; adebug_assert!(n <= 24)would pin it if a wider norm format ever appeared.mtbuf_testsmodule takessuper::valu_tests::ONE_AT_A_TIMEbefore touching a device, which is exactly right and worth calling out because #383'srun_cases_onmissed it and its parallel release runs segfault 2-in-6. This one will not.Nothing I would change. The one thing I could not verify from here is the gfx1036 console measurement the test's expectations come from (#1060) — but with the formula exhaustively equal to round-to-nearest-even, that measurement and the implementation agree by construction.
@Zipettte on GitHub · 2026-11-24 18:01 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 4f5fa47:
cargo test -p victory-shaderpasses, 122 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@DovisLe on GitHub · 2026-11-24 19:23 UTC · original
Physical-GPU result: Radeon 860M (RDNA 3.5, driver 32.0.32029.2010) and WARP, at
4f5fa47. Bothnormalized_mtbuf_loads_*tests pass, and thevictory-shaderlib suite passes. A sweep of all 20 UNORM/SNORM formats throughtbuffer_load_format_xyzw(72 inputs per format, every channel, 11,040 results against the correctly rounded quotient; #1575) finds 32 mismatch groups onmain. All of them are 1 ULP and on the 860M only; WARP is exact. The example is 8_UNORM0x7F, which gives0x3efeff00instead of0x3efefeff. With this PR there are 0 on both.@steven-seagull27 on GitHub · 2026-11-24 20:46 UTC · original
Your normalized MTBUF load fix covers a rounding difference we also reproduced on an RTX 5080. I ran all 77 typed-buffer formats from #1575 (
856f0ce) on native Windows, then repeated the sweep with this PR (4f5fa47) and #422 (a746d53) merged together. The RTX 5080 went from 205 mismatches to zero (169 UNORM and 36 SNORM across 32 format/channel groups). Microsoft WARP matched all 21,252 reference values in both runs.For
8_UNORMinput0x7f, the RTX originally returned0x3efeff00, one float32 step above the correctly rounded value of127/255. In the combined run, it returned0x3efefeff, matching the CPU reference and WARP. NVIDIA driver32.0.16.2124, Windows 11 build 26300.10075. Full results and reproduction command on #1575@Marvisak on GitHub · 2026-11-25 00:35 UTC · original · edited 2026-11-25 16:01 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (merge-candidate) was for an older state ofmain.Generated by Claude Code
@steven-seagull27 on GitHub · 2026-11-26 01:37 UTC · original
@Razdva122 I resolved the conflict on your
a291bc6head. Main already rounds these loads with 32-bit DXIL operations. The merge keeps that implementation and adds your two regression tests unchanged. They exercise every field value in all 20 packed and unpacked UNORM/SNORM formats, including 11-bit fields. Tested merge · Rounding change already on mainBoth tests passed on main
63bcca43with your test file added. I also ran each adapter separately and confirmed its DXGI name. All 20 emitted shaders had theInt64ShaderOpsflag clear.On the PR branch at
a291bc6, you can fast-forward to the tested merge:Shaders: round normalized MTBUF loads without Int64ShaderOpsto Shader tests: verify every normalized MTBUF field without Int64ShaderOps@mercuryVM on GitHub · 2026-11-24 19:27 UTC · original · approved these changes
Tested 4f5fa479 on Windows 11, RTX 5070, MSVC:
cargo test -p victory-shader -- --test-threads=1passes on the head (122 passed, 1 ignored), including the 20-format MTBUF tests against the f64 reference.clippy -D warnings(default and all features) are all clean.I checked the integer rounding by hand:
x / 2^nis exact: an exponent subtract on an exactly converted integer, n ≤ 16.S + S/max.round(S/max)never ties, becausemax = 2^n - 1is odd.x = max, where the result is exactly 1.0. Every otherxstays in its own power of two.On a full game package,
translate --validate --listkeeps every program's result, with 0 programs changed (counts only compared).AI-assisted (Claude Code).
@Razdva122 on GitHub · 2026-11-26 12:19 UTC · original
Closing this PR because main already includes the 32-bit normalized MTBUF rounding fix in
da82e444ec. The final diff contains only the additional exhaustive tests. They passed for all 20 formats on an RTX 5080 and Microsoft WARP, with zero mismatches across 962,048 field values on each backend. The tests remain available at commit3e85d5c3e1. Test reportPull request closed