shader: preserve the direct fract binary32 upper bound #3287
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3287
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3285"
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?
@wish131400 on GitHub · 2026-11-28 05:17 UTC · original
wish131400:shader/direct-fract-f32-bound→main· +188 −2 · 4 files · 1 commits · merged 2026-11-28 05:42 UTCThe direct DXIL frontend emits
v_fract_f32as an uncapped DXILFrc. For tiny negative inputs such as -2^-30 and -2^-28, the desktop result rounds to 1.0. The project's gfx1013 contract requires the greatest binary32 below 1.0; amul:2output modifier therefore also produces an incorrect 2.0. Fixes #3285. The Python paths already received the corresponding bound in #267 and #2010; this change covers the newer native direct frontend.Apply an ordered upper-bound comparison before output scaling and clamp. NaNs pass through unchanged. Add a source-built request fixture for eight inputs across VOP1, source-negated VOP3, clamp and
mul:2, with two wave32 groups and guard words. The modified frontend is already part of the generated cache revision.Validation at head
309c50e0, rebased ontoaeef65b2:compile_dxilandnative_store_replayrebuilt successfully after the rebase.native_fract_f32_controlspassed; the pre-rebase patch also passednative_f16_alu_ir,native_frexp_f32_controlsandnative_mad32_controls.python -B tests/docs_links_check.py: 142 Markdown files / 661 links passed.git diff --checkpassed.Measured readbacks: Windows 10 build 19045, RTX 4070 Ti SUPER, driver 32.0.15.7270, DXC 1.9.2609, Agility 1.620.2, D3D12 debug layer disabled. The ordinary Windows 10 fixture executable returns capability skip 77 for SM6.6; the measured run locally relinked the same fixture objects with Agility version/path exports and used the existing matching runtime. This is documented in the experiment note; no SDK runtime is added to the repository. No console hardware or full-program result is claimed.
All instruction bytes are constructed by the fixture. No game assets or SDK implementation code are included.
@Leyukaka on GitHub · 2026-11-28 05:28 UTC · original
I reviewed the diff (not run). I found nothing wrong with the cap itself. Some notes on its form and on the fixture:
fcmp oge float %r, 1.0on theFrcresult.tools/startup/gfx2hlsl.pydeliberately compares the bits instead (asuint(f) == 0x3f800000u), because FXC foldedfrac(value) >= 1.0fto false. The direct path only assembles and validates, with no optimizer pass, and the PR's control asserts thatfcmp oge floatis in the dumped container. I have not checked whether a driver backend can useFrc's range to fold it. A bit comparison would avoid the question.-2^-25(0xb3000000) is an exact binary32 tie:1 - 2^-25rounds to even, which is 1.0, and needs the cap. Its neighbour0xb3000001gives0x3f7fffffwithout the cap. The fixture uses-2^-30and-2^-28, which are well inside the capped range, so the edge of that range is not pinned.negand the cap. All the tiny inputs are already negative, so theneg0form turns them into positive values that never reach the cap. A tiny positive input such as0x33000000withneg0would cover it.fract()would raise on them:math.floor(inf)raisesOverflowErrorbefore the cap.MODE[5:4] = 3),-2^-149is another input that needs the cap. I have not checked whetherFrckeeps or flushes denormal inputs on the host adapter, which would change the result to 0.AI-assisted.
github-bot referenced this pull request2026-11-28 05:37:29 +00:00
@R0Y00 on GitHub · 2026-11-28 05:42 UTC · original · approved these changes
Independent Release check on
309c50e0:ctest --preset release --no-tests=error -V -R '^native_fract_f32_'passed 2/2 without a capability skip. On Windows 11 build 26200.9974 with the standard fixture executable, SDK DXC 10.0.26100 and RTX 4060 Laptop driver 32.0.16.1656, the physical readback matched 2,048 result words and 16 guards. The ordered comparison preserves NaNs and applies the cap before scaling/clamping. The uncapped and NaN-losing reference controls differ.