Repository navigation
Conversation
Assign the half-float sign only when the scaled magnitude is nonzero. Add bit-exact synthetic zero-crossing and exhaustive scaling checks against independent arithmetic. Keep the separate minimum-endpoint fix in PR ItsNotRexed#6120 independent. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Superseded by #6175 at the same tested commit. Please continue review there. Existing branch and history are retained; nothing was merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: #6089 (comment)
Depends on: #6120
What and why
Fix the pre-existing signed BC6H zero-sign defect reported at #6089 (comment). An interpolant of -1 scales to integer zero, so its half-word must be 0x0000 rather than 0x8000. Only restore the negative sign when the final magnitude is nonzero.
One production line changes. Add bit-exact tests against an independent signed-integer truncation oracle, all 16 interpolation weights of 272 synthetic mode-14 blocks crossing zero, and a short format note. Reference: Microsoft BC6H finalization. No Microsoft source code or game content is copied.
Conflict, not a code dependency: based independently on main at 561b65a. #6120 at a574976 fixes a different defect (the -32768 endpoint) in the same
_bc6h_finishhunk. Its branch was not changed and its fix is not included here. Whichever lands second must preserve both changes: on #6120's implementation the final condition becomesval < 0 and h. The separate minimum-endpoint behavior is unchanged by this PR.Tested
Windows CPU, Python standard library, synthetic inputs only:
python -I tests\test_ttpf_mips.py -k bc6h_finish_scalingpython -I tests\test_ttpf_mips.py -k bc6h_signed_mode14_zeropython -I tests\test_ttpf_mips.pypython -I tests\test_bcpack.pypython -I tests\test_bcpack_history_calib.pypython -I tests\test_ttpf_assets.pypython -m compileall -q make_game.py tools testsgit diff --checkpython -I -(in-memory compatibility experiment)Across all 65,536 signed and 65,536 unsigned interpolants, comparison with the base implementation found exactly one changed result: signed -1, 0x8000 -> 0x0000. The persisted oracle test covers signed -32767..32767 and unsigned 0..65535; it deliberately leaves #6120's separate -32768 defect alone. Scaling division is exact in binary before truncation for these bounded integers.
Also loaded #6120's two production functions in memory, applied this zero-sign guard, and combined its revised BC6H tests with this branch's suite: 80 tests passed. All 65,536 signed interpolants then matched the independent arithmetic oracle, including -32768 -> 0xfc00. No checkout or modification of the author's branch was needed.
No new GPU run in this PR. The prior independent native D3D11 measurement on RTX 4070 Ti / driver 610.88 is linked in the original finding and #6120 review; it is not presented as a new run. Shader-translator validation: not applicable.
AI-assisted: yes
Checklist
docs/design.md, with how it was confirmed.The translator-rule item is not applicable: no translator changes.