Shaders: widen and pack 16-bit integer stage IO without f16 conversion #3805
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3805"
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 Vemast on 2026-11-28T23:33:19Z.
Summary
Lower::exportandLower::interpincrates/victory-shader/src/emit/lower.rsso 16-bit integer stage attributes (uint16/sint16) in VS/MS exports and PS flat inputs are widened/masked and packed directly as integers rather than passed throughlegacyF16ToF32andnarrow16, which corrupted integer bit patterns, NaN/infinity-range patterns, and negative signed values.emit::synthetic_tests::sixteen_bit_integer_stage_io_preserves_bits_and_signscovering both unsigned and signed 16-bit stage IO across vertex/pixel pipelines.Verification
cargo test -p victory-shader --lib sixteen_bit_integer_stage_io_preserves_bits_and_signs(validated bydxil.dll, ran on hardware D3D12 + WARP)cargo clippy -p victory-shader --all-targetscargo run -p xtask -- policyImported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-28T23:33:30Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T23:55:32Z.
I ran the original
sixteen_bit_integer_stage_io_preserves_bits_and_signsfixture from1279ffaon both63bcca4and the PR head. It passed on both on app-local WARP.The test-only follow-up
a98a99cchanges the upper packed unsigned value from 3 to0x7c01(31,745). That bit pattern is a signalling NaN when interpreted as an FP16 value. With the exact same fixture, main returns[65535, 32257, -16, -23]because the FP16 round trip quiets0x7c01to0x7e01. The PR with the stronger fixture returns the expected[65535, 31745, -16, -23].This used WARP 1.0.22, Agility 1.620.2 and the DXIL validator. Both strict shader Clippy configurations and the asset policy passed. The test-only commit is based directly on your PR head. Please retain the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the regression into another commit. Test branchAI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-29T00:08:55Z.
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
1279ffa6680fa8d59d02b24674aa76e3a1eb12ff, base/parent63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-shader --lib -- emit::synthetic_tests::sixteen_bit_integer_stage_io_preserves_bits_and_signs --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 305 filtered, exit 0.git grep -Ffor the test name on the base returned no match (test is new);git diff --check HEAD^ HEADclean (2 files, +273/-12; just over the usual size preference, but CPU-only).CARGO_TARGET_DIR(target-3805-watch) withCARGO_BUILD_JOBS=2, never shared.AI-assisted (Hy4 flash).
Imported from Marvisak/VIctory. Originally posted by lmouz823-lang on 2026-11-29T03:51:55Z.
@Vemast @andrewpozdnakov7-jpg, independent native Windows / RTX 4060 Laptop verification of the stronger stage-IO regression.
I compared main
63bcca43c6a00a758510398fa43096ce7e4f7df0with this PR's1279ffa6680fa8d59d02b24674aa76e3a1eb12ff, using the same fixture from Andrew's test-onlya98a99cbd3b0b2f7036f3c8c71021e56a9fb5938. The production fix and test authors' commits were retained. Coordination claim.Environment
Windows 11 build 26200, i9-14900HX, RTX 4060 Laptop 8 GB, NVIDIA 610.88, Rust 1.98.1 MSVC, release/locked, separate target directories. Microsoft SDK DXIL validator 1.8.2502.11. WARP identified as Microsoft Basic Render Driver. The installed system
d3d10warp.dllfile version is 10.0.26100.8521.Identical-fixture results
The table uses 20 fresh processes with matching archived test EXEs. All four returned pixels agreed in each trial.
0x7c01[65535, 32257, -16, -23][65535, 31745, -16, -23][65535, 3, -16, -23][65535, 3, -16, -23]interpmethod[0, 0, -1, 0]exportmethod[57344, 8192, 0, 1]On the RTX 4060 as well as WARP, main changes the integer pattern
0x7c01(31745) into0x7e01(32257). The full fix preserves it. The original value 3 passes both versions, and the single-method controls separately exercise both production changes.To establish actual execution, temporary probes in the identical fixture required successful validator loading and validation for both VS and PS, required the selected backend to run, and resolved the D3D12 device's LUID through DXGI. Hardware identified as NVIDIA GeForce RTX 4060 Laptop, vendor
0x10de, software=false. WARP identified as Microsoft Basic Render Driver, software=true. Device creation errors failed the probe. Successful trials asserted all four pixels. Failure trials stopped at the first pixel assertion, with all four readbacks retained in the log.Final unchanged-source checks
After restoring the unchanged
a98a99csource and rebuilding, the exact original stronger test passed three more times, each 1 passed, 0 failed, 0 ignored. The 33 lowerer tests also passed. Package all-target Clippy passed with-D warningsin default and all-features configurations, the asset policy passed, andgit diff --check main HEADpassed.Coverage is the generated VS-to-PS,
pack2=truepath, including the signed-integer and float16 control channels. The full workspace suite, MS-output path,pack2=falsepath and gameplay performance remain unmeasured in this verification.AI-assisted with OpenAI Codex. Raw logs, source/binary hashes and the primary 20-process matrix were independently cross-checked.
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-30T16:23:15Z.
Verified locally on Windows, Rust 1.100.0 (MSVC, Scoop rust-msvc), synthetic inputs only — no game data.
Base
63bcca43c6a00a758510398fa43096ce7e4f7df0, head1279ffa6(worktreepr-3805-watch, dedicatedCARGO_TARGET_DIR=D:\Victory-Contrib\target-3805).Negative control:
git grep -F sixteen_bit_integer_stage_io_preserves_bits_and_signs 63bcca43 -- crates/victory-shader/src→ no match, so the test is new on the base.git diff --check 63bcca43..1279ffa6→ clean.Command and result:
cargo test --locked -p victory-shader --lib -- emit::synthetic_tests::sixteen_bit_integer_stage_io_preserves_bits_and_signs --exact --test-threads=1 --quiet→ 1 passed; 0 failed; 305 filtered outGPU/driver: N/A (CPU-only codegen assertion, no device used).
AI-assisted: Hy4 flash. No game data, assets, extracted shaders or DRM used at any point.
Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-12-01T14:03:09Z.
I separated the two stage changes at
1279ffa6by cross-linking VS and PS containers from the head and63bcca43. On both the RTX 4090 Laptop and WARP, a packed fixture containing0x7e01,0x7c00,0x8000and0x7fffgave the following four-component result at every pixel of a 2×2 draw. The final channel adds a float16 control of 1.[32257, 31744, -32768, 32768][32257, 31744, -32768, 32768][8192, 0, 0, -8191][0, 0, -4, 1]For these inputs the parent's two conversions cancel in the end-to-end draw. Holding one stage fixed exposes the representation difference at each side of the interface.
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.