Repository navigation
gpu/recomp: exact RNE rounding and NaN handling for V_CVT_(PK)NORM_*_F16 - #80
Merged
Merged
Conversation
Contributor
|
Tested locally on Windows — both Key improvements verified:
Great precision fix for shader math. |
Collaborator
|
Merged. Tested on Windows 11 with an RX 9070 (RDNA4): |
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
…nd backend 1d split 1 of 2 (honest split: route halves stay under the line budget). Device frame-clock slots route on Vulkan objects only: xcl-dev#78 SetFrameIntervalX, xcl-dev#79 ScheduleFrameEventX (with ancillary handle routing), xcl-dev#80 WaitFrameEventX, xcl-dev#81 GetFrameStatisticsX — thin adapters over the Linux twin (d3d12x_frame_linux). register_ancillary remembers the schedule block's handles per type (E_INVALIDARG past the 63-handle cap, like Windows; Linux trusts the block — readable() is windows-only); the clock thread signals each with kernelx SetEvent at fire. Unscheduling clears. Null device keeps logging stubs: no behavior change while XCL_VULKAN_BACKEND is unset. Queue xcl-dev#30 PresentX + the real present follow in 1d(ii). Failing-first: the routing test failed pre-fix (E0599 no VulkanQueue; then E_FAIL at xcl-dev#81 with PresentX still stubbed); passes now (slots + ancillary-signal asserts, serialised on CLOCK_SERIAL with the twin's tests). Gates: check -p xcl --tests EXIT 0 (40 pre-existing warnings, none new); check --workspace EXIT 0; lib 794 passed/0 failed/1 ignored (+1 new). Title e2e + retail controls run at 1d(ii).
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.
Summary
Fixes two accuracy bugs in
V_CVT_NORM_U16_F16,V_CVT_NORM_I16_F16,V_CVT_PKNORM_U16_F16, andV_CVT_PKNORM_I16_F16in the RDNA2 → HLSL shader recompiler:f16viaf16tof32(x), multiplied by65535.0f/32767.0finfp32, and calledround(...). Nearfp32ULP exceeds.5to round up to.5and then tie-to-even to the wrong integer. For example,0x3801(0x801F), previously32800(0x8020)0x400F), previously16400(0x4010)clamp(x, -1.0f, 1.0f)lowers tomin/maxin DXIL, suppressing NaN to±1.0f(±32767) instead of returning0.Changes
crates/xcl/src/gpu/recomp/emit.rs:uintHLSL helperscvt_norm_f16(uint h, uint scale),cvt_norm_u16_f16(uint h), andcvt_norm_i16_f16(uint h)operating directly on raw IEEE-754 binary16 bit patterns (nofp64dependency; exact round-to-nearest-even across all 65,536 binary16 inputs,NaN → 0,±Inf / |x| ≥ 1 → ±scale, exact subnormal handling).v_cvt_norm_u16_f16,v_cvt_norm_i16_f16,v_cvt_pknorm_u16_f16, andv_cvt_pknorm_i16_f16to apply VOP3abs/negmodifiers directly on bit 15 before calling the helpers.crates/xcl/src/gpu/recomp/tests.rs:cvt_norm_f16_instructionsfor the new helper emission.gpu_cvt_norm_f16_exact_rounding_and_edge_casestesting all four instructions across0x3801/0xB801,±0.5,+qNaN/-sNaN,±Inf,±0.0, subnormals (0x0080,0x0081,0x0101),0x3BFF,±1.0, and VOP3ABS,NEG, and combinedABS+NEGmodifier order.Verification
XCL_ADAPTER=1,XCL_REQUIRE_GPU=wave64, D3D12 Agility SDK 1.620.2):cargo test -p xcl --lib cvt_norm_f16 -- --test-threads=1— passed (2 passed; 0 failed).cargo test -p xcl --lib gpu_more_atomics_sub_dword_scratch_valu -- --test-threads=1— passed (1 passed; 0 failed).