Repository navigation
Shaders: read known FP16/FP64 rounding mode bits - #2782
andrewpozdnakov7-jpg wants to merge 2 commits into
Conversation
|
Selector decode matches the hwreg encoding (regid[5:0] | offset[10:6] | (size-1)[15:11]), MODE=1, and the [2,4) field bound correctly restricts reads to the tracked FP16/FP64 rounding bits while refusing unmodeled fields. The test's cross-check (FP32 set to mode^3) would catch reading the wrong field. |
|
Independent WARP/CPU verification of head Environment: Windows 11 x64, WARP/CPU only ( Tests ( Negative control: disabling the Clippy: Review: Selector decode (id[5:0], offset[10:6], size-1[15:11]) is correct; only MODE[3:2] is modelled and any other register/field is rejected, and an unknown AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5). |
|
Reviewed and verified
|
|
Automated triage for the maintainers. This lowers This is a recommendation for a maintainer to look, not an approval. Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):
cargo test -p victory-shader --lib emit::valu_tests::read_fp_round_mode_field_after_each_setting: 1 passed, 0 failed (RTX 5090 hardware + WARP).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
…d merged tests with the branch Marvisak#2811 on this branch turned `Lower::mode16` into `FpMode16 { round, denorm }` and moved the MODE update into `FpMode16::after`. Three refreshed PRs still used the old `Option<u8>` and the removed `round16_after`, so victory-shader did not build: - Marvisak#2782 reads MODE[3:2] for `s_getreg_b32`: it now reads `mode16.round`. - Marvisak#2886 updates the mode inside whole-wave sections: it now calls `mode16.after`, as the main lowering loop does. - Marvisak#2917 rounds toward zero when FP_ROUND_16_64 is 3: it now checks `mode16.round`. Tests from Marvisak#2152, Marvisak#2817, Marvisak#2952, Marvisak#3038 and a `mod.rs` test used the older `lower::Parts`, `HostShader`, `Translated` and `emit::emit` signatures; they get the branch's fields (`Target::ANY`, no console flow, no native f16, `written_root_uavs`, `threads`, `atomics64`) as the other tests do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fuzeofficlal
left a comment
There was a problem hiding this comment.
s_getreg_b32 selector decoding (MODE[3:2] offsets (2, 1), (3, 1), (2, 2)) and bit extraction match RDNA2, and read_fp_round_mode_field_after_each_setting passes on both RTX 5090 and WARP (clippy and xtask policy also pass).
Two functional issues need fixing before merge (plus a minor formatting nit):
-
Whole-wave sections skip
mode16updates (crates/victory-shader/src/emit/lower.rs:1367-1375)- When
self.sectionsemitsj in i + 1..endviasection_instand jumpsi = end,round16_afteris not applied to instructions inside the section. As_round_modeinside a whole-wave section (e.g.,s_or_saveexec_b32; s_round_mode 0xc; restore EXEC; s_getreg_b32) leavesself.mode16stale, sos_getreg_b32silently reads0instead of3. Updatingself.mode16acrossi + 1..endavoids stale reads.
- When
-
Destination guard misses
EXEC_HI(lower.rs:3566,:3581)inst.write(Reg::S(EXEC)).is_some() || self.is_mask(lo)only checksEXEC_LO(EXEC) andst.masks, missingEXEC_HI/st.highsin Wave64, and writing a numeric constant intoVCCcan turn a downstreams_cbranch_vccnzinto a per-lane bit test rather than a wave-wide nonzero check.
Minor formatting nit: rustfmt --edition 2024 --check flags crates/victory-shader/src/emit/lower.rs:3586 and crates/victory-shader/src/emit/valu_tests.rs:252.
|
Thanks @fuzeofficlal. 7102a71 advances the rounding mode through whole-wave sections. The added shader reads The lowering also rejects All three focused tests, strict all-features shader Clippy, and the asset policy check passed locally. AI-assisted with Codex. Synthetic shaders only. |
A shader that reads the FP16/FP64 rounding field through
S_GETREG_B32stops translation on main. The lowering now extracts the requested bits from the same statically known MODE value used by FP16 arithmetic. It accepts a read of both rounding bits or either bit individually. AMD specifies that hardware-register reads place the result in the low bits of the destination. RDNA 2 ISA referenceThe same synthetic readback on
13f91castops with unsupporteds_getreg_b32. With this commit, all 12 cases return the expected values on app-local WARP SM 6.6 with the DXIL validator. The test sets all four rounding modes, reads the full field and its two one-bit slices, and gives FP32 a different rounding value.All 32 VALU tests in the app-local run passed, including the runtime identity check. The existing FP16 rounding test passed before and after. Strict shader Clippy and staged asset policy passed. Coordination claim
Please retain the Git author on cherry-pick or rebase. If you fold this change into another commit, please include
Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>.