Shaders: read known FP16/FP64 rounding mode bits #2782
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!2782
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2782"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 20:21 UTC · original
andrewpozdnakov7-jpg:codex2/read-mode-round16→main· +33 −0 · 2 files · 1 commits · openA 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 <[email protected]>.@kotekompotek on GitHub · 2026-11-25 20:38 UTC · original
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.
@oni-swr on GitHub · 2026-11-25 20:57 UTC · original
Independent WARP/CPU verification of head
c89141382fdec3e7051650dfee5b4af78569c0e1merged cleanly ontoorigin/main13f91caee25f2fdf2c062be5f7a27f058e51cbca.Environment: Windows 11 x64, WARP/CPU only (
VICTORY_WARP=1,VICTORY_D3D12_WARP=1), no physical GPU, no game files; Windows SDK 10.0.26100.0 x64dxil.dll1.8.2502.11.Tests (
cargo test --no-fail-fast): victory-shader: 268 passed, 3 failed, 3 ignored (baseline 267 passed, 3 failed, 3 ignored; +1 new test, which executes on the WARP device for all four rounding modes and three field slices). victory-shader baseline onorigin/main: 267 passed, 3 failed, 3 ignored; the 3 failures (synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number,gathers_at_a_level_match_the_hardware,permutes_read_the_lane_named_and_zero_from_lanes_left_out) fail identically onorigin/mainunder WARP, so they are not caused by this PR.Negative control: disabling the
s_getreg_b32branch makesread_fp_round_mode_field_after_each_settingfail (lowering error); restored afterwards.Clippy:
cargo clippy -p <affected crates> --all-targets -- -D warningsclean (exit 0).fmt:
cargo fmt --checkis not clean onorigin/mainitself (891 diff hunks across many files); this PR: 893 hunks (+2 vs main, in the touched files).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
mode16is rejected rather than guessed. Diff contains no game files, dumps, shader names or retail hashes.AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5).
@fuzeofficlal on GitHub · 2026-11-25 21:05 UTC · original
Reviewed and verified
c8914138on Windows 11 (RTX 5090 + WARP + Windows SDK10.0.26100.0dxil.dll) againstmain(13f91ca).s_getreg_b32(register, offset, width)and strictly accepting onlyregister == 1(MODE),offset >= 2,offset + width <= 4while rejecting unknown/unmodeled fields and unknown dynamic/joined modes is clean and minimal.git merge-treeagainst13f91ca,#2743, and#2791, but since#2743and#2791changeLower::mode16fromOption<u8>toFpMode16 { round, denorm },self.mode16.ok_or(...)(lower.rs:3384) will need to becomeself.mode16.round.ok_or(...)if merged after either of them.cargo test --locked -p victory-shader --features host --lib -- valu_tests::: 31 passed, 0 failed (includingread_fp_round_mode_field_after_each_settingacross all 4 rounding modes × 3 bit slices on both RTX 5090 and WARP).cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings;cargo xtask policy: 184 files ok.@Marvisak on GitHub · 2026-11-25 23:24 UTC · original
Automated triage for the maintainers.
This lowers
s_getreg_b32inemit/lower.rsfor reads of MODE[3:2], the FP16/FP64 rounding field, from the statically trackedmode16. It refuses any other register or field, and also refuses when the mode is unknown. I checked the selector decode (id[5:0], offset[10:6], size-1[15:11], MODE = 1) against the public RDNA2 ISA and againstround16_after, which decodess_setregthe same way. The new test sets the FP32 field to a different value so that a read of the wrong field fails. One note: the value read is only as good asmode16's starting value (Some(0), which the FP16 arithmetic lowering already assumes). If #2743 or #2791 lands first,self.mode16.ok_or(...)needs to follow theirFpMode16change. CI passes.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
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.