Shaders: f32 floor, ceil and fract flush denormal operands #2968
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!2968
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2968"
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?
@neonbyte1 on GitHub · 2026-11-26 01:48 UTC · original
neonbyte1:pr/ftz→main· +13 −1 · 1 files · 1 commits · openThe console reads f32 denormals as zeros of their sign. DXIL
floor,ceilandfracleave that to the host, and vkd3d-proton on NVIDIA does not advertise FP32 denorm flush, sov_floor_f32,v_ceil_f32andv_fract_f32of a denormal kept it.v_fract_f32of0x80000001gave0x3f7fffff(just under 1.0) instead of 0. The operand is now flushed on the bits first, asmax/minand the float-to-int conversions already do.Tests (Linux, Wine 11.22, vkd3d-proton 3.1-83 from GE-Proton11-14, RTX 5090, driver 620.73.04; run with
cargo xtask wine-testfrom #1218):emit::semantics_tests::rounding_matches_the_hardwarefailed before on the 5090 and on the vkd3d-proton software path, 2 of 38 inputs each for floor, ceil and fract. It passes with this change.victory-shader: 299 passed, 3 failed, against 298/4 onmain(63bcca4). The other 3 failures are Wine/vkd3d-proton gaps fixed elsewhere: #1266, and a PR of mine that follows.cargo clippy --workspace --all-targets(with and withoutdiagnostics) andcargo xtask policyare clean.Translation over the whole shader pack: no program starts or stops translating. 11,157 programs emit different DXIL, all from the added flush. That's broad, so I ran it in game: two 7-minute runs on our NVIDIA/Wine test build, with no crash or new drops (556 against 558 dropped draws a frame, 86 against 90 indirect). Frame 1500 was still the loading screen in both, so this is not a visual comparison.
Not tested on Windows. On a host that flushes denormals already, the extra
and/selectis a no-op.AI-assisted (Claude); measured on my machine, no game data shared.
@neonbyte1 on GitHub · 2026-11-26 03:38 UTC · original
Thanks for checking. On a ±denormal case:
emit::semantics_tests::rounding_matches_the_hardwarealready covers it. It feeds0x80000001,0x807fffffand0x007fffff(and their neighbours) tov_floor_f32,v_ceil_f32andv_fract_f32, and compares against the hardware and WARP. Under vkd3d-proton on NVIDIA it failed on exactly those inputs before this change (fractof0x80000001gave0x3f7fffff) and passes with it. So I'd leavevalu_testsas is, unless a maintainer prefers a dedicated case.@Marvisak on GitHub · 2026-11-26 05:32 UTC · original
Automated triage for the maintainers.
Merge candidate. In
lower.rs, in the VOP1 float arm,v_fract_f32(DXIL op 22) andv_floor_f32/v_ceil_f32(27 / 28) now pass their operand throughftzfirst. Thev_cvt_flr_i32_f32/v_cvt_rpi_i32_f32path already does this. The evidence is the hardware-referencedrounding_matches_the_hardwaretest already onmain, which feeds these ops ±denormals. A host that keeps denormals fails it, and with this change it passes.truncandrndneare rightly left alone, since a denormal gives ±0 from them either way. On hosts that already flush, the change costs one compare and select.CI: passing. Recommending a look, not approving.
Generated by Claude Code
github-bot referenced this pull request2026-11-26 08:11:12 +00:00
@fuzeofficlal on GitHub · 2026-11-26 02:00 UTC · original · reviewed
Reviewed and verified against
main(63bcca43) on Windows 11 (RTX 5090 + WARP +dxil.dll) — clean fix and ready to merge:self.ftz(a)after source modifiers (abs/neg) inv_fract_f32,v_floor_f32, andv_ceil_f32(crates/victory-shader/src/emit/lower.rs:6340-6347) flushes subnormals to signed zero (±0.0) while leavingNaNand±Infuntouched, matching RDNA2 behavior on NVIDIA drivers (where-denormotherwise produced-1.0forfloorand0x3F7F_FFFFforfract).emit/lower.rssize on63bcca43: 521,164 B (+601 B, 3,124 B under the 512 KiB policy limit).±denormregression case tovalu_testsforv_floor_f32/v_ceil_f32/v_fract_f32would lock this behavior in directly.)Local verification:
cargo test --locked -p victory-shader -- fract floor ceil denorm: 7/7 passed (GPU + WARP +dxil.dll)cargo clippy --locked -p victory-shader --tests -- -D warnings: 0 warningscargo xtask policy: 191 files ok@Dukestar69 on GitHub · 2026-11-26 02:01 UTC · original · approved these changes
Tested merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP,dxil.dllvalidator active):cargo test -p victory-shader --lib emit::semantics_tests::arithmetic_matches_the_hardware: 1 passed, 0 failed (hardware + WARP, 0 mismatches).cargo test -p victory-shader --lib emit::lower::tests: 33 passed, 0 failed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Flushing f32 denormal operands via
self.ftz(a)beforefract(op 22),floor(op 27), andceil(op 28) matches RDNA2 FTZ behavior and avoids vkd3d/NVIDIA denormal retention.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@kotekompotek on GitHub · 2026-11-26 02:19 UTC · original · reviewed
Verified: flushing the operand to zero before DXIL floor/ceil/fract matches the console's denormal-as-zero reads and the existing ftz treatment for max/min and the floor conversions in this same lowering — needed precisely because vkd3d can't request FP32 denormal flush on NVIDIA. ops 27/28/22 are the right sites.
@fyernald on GitHub · 2026-11-26 05:04 UTC · original · approved these changes
A native Windows data point, since this was tested under vkd3d-proton: RTX 3080 (driver 617.42), Windows 10 22H2. Base is
main63bcca4+ #486 (Agility opt-in) + #2596 (so the suite gets past the #2571 crash).e4a11fd)emit::semantics_tests::rounding_matches_the_hardwarecargo test -p victory-shader --lib -- --test-threads=1So the native NVIDIA D3D12 driver already gives the console's results for those denormal inputs here. The failure you saw is specific to vkd3d-proton. The change doesn't move anything on Windows, and it stops the result from depending on the driver's denorm mode, the same as
max/minalready do.@Jackster on GitHub · 2026-11-26 16:24 UTC · original
Windows 11, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010),
victory-shaderbuilt with--features hostso the hardware backend runs:emit::semantics_tests::rounding_matches_the_hardwarepasses on unpatched63bcca4here, and with this PR. The 2-of-38 floor/ceil/fract mismatches you saw on the 5090 and on vkd3d-proton do not reproduce on RDNA3, so on this adapter the added flush is a no-op.Synthetic only. AI-assisted.
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.