Recompiler: translate v_trig_preop_f64 in both backends #2305
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2315"
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?
Imported from ivall/xcl. Originally posted by NWProgramming00 on 2026-11-25T13:39:47Z.
Both backends refused
v_trig_preop_f64. This translates it as RDNA2 hardware runs it. I measured the hardware first, then checked xcl against it bit for bit.What the hardware does (gfx1036, 2,072 measured rows, MODE with f64 denormals kept)
shiftbits below b1200, times 2^(−53 − shift).shift = S1[4:0] × 53, plusexp(S0) − 1077when the S0 exponent is above 1077.What is in it
crates/xcl/src/gpu/recomp/emit.rs:trig_preop()helper and the 37-word table (TRIG_PREOP_2_OVER_PI);crates/xcl/src/gpu/dxil/lower_wide.rs: the same computation in the direct DXIL translator. It reads the table with a chain of selects, because that translator has no constant arrays.crates/xcl/src/gpu/dxil/lower.rsandemit.rs:v_trig_preop_f64leaves the list of f64 ops that follow the f64 round mode (it does not round).OMOD/CLAMP) is refused, because I did not measure it.crates/xcl/src/gpu/recomp/tests.rs:gpu_trig_preop_f64_matches_rdna2checks both backends against 64 rows measured on the gfx1036.trig_preop_f64_with_omod_is_refusedchecks the OMOD refusal in both backends.Tested
XCL_ADAPTER=radeon). Rust 1.100 MSVC, release.cargo build --release --workspace, thencargo test --release --workspace --no-fail-fast -- --test-threads=4, with and withoutXCL_DIRECT_DXIL=all, on this change rebased ontomain8b957be(9a608a4), against that base on the same machine:8b957be9a608a4)XCL_DIRECT_DXIL=allXCL_DIRECT_DXIL=allThe +2 are the new tests, which pass in all four rows. The failing tests are the same on base and PR, and both are tracked:
fuzz_validate_and_gpu_0..3on NVIDIA (#1905) andfuzz_validate_and_gpu_1on RDNA2 (#2115, #2170).Regression run
Base (
maine120925), NVIDIA GeForce RTX 5070 Ti:This PR (
a2d9c47), same card:e120925: this head sits one120925, themaincommit just before #2555.main8b957be, this head gives the same tree as the commit the suite above ran on (9a608a4, tree5f5b6a7).main805 frames, this PR 593, both exit 0x0, 0 crashes.mainalone (805, then 649).v_trig_preop_f64, and both have the same 41 refusals. The title does not reach this instruction in these 60 s, so the 60 s runs check only that nothing else changed.Not tested
OMOD/CLAMPon this instruction (refused).AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-25T14:04:27Z.
Independent focused check of
44455fe9109fed47598714ecc1a464c96d1012c8on Radeon integrated graphics and RTX 5090.Tested
cargo test --locked -p xcl --lib trig_preop_f64 -- --nocapture --test-threads=1in separate processes withXCL_ADAPTER=AMD RadeonorXCL_ADAPTER=NVIDIA GeForce RTX 5090(XCL_REQUIRE_GPU=wave64on Radeon). Each run gave 2 passed, 0 failed, 0 ignored and no skips.Not tested
The larger hardware capture, retail smoke, and the full workspace suite.
AI use
OpenAI Codex (GPT-6.2 Sol) ran the tests, checked the logs and wrote this report.
upstream-sync referenced this pull request2026-11-25 15:05:51 +00:00
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T14:10:59Z.
RDNA3 confirmation: the new f64 trig translation is bit-exact on gfx1100 too.
The fix is calibrated against gfx1036 hardware measurements; here it is on RDNA3 (RX 7900 XT, NAVI31) under RADV, which the PR does not list as tested.
Tested:
origin/main379725ae+ PR head44455fe9(mergec7785944, no conflicts, mergeable clean onto current main). Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT, cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, official MS DXC (binaries 2026-09-29).gpu_suite (--release --locked,--test-threads=2): 143 passed / 3 failed / 1 ignored, versus 142 / 3 on plainorigin/mainon this rig. The pass delta is exactly this PR's added test, and the 3 failures are the rig's known baseline, unchanged: fuzz seed 1003 (posted on #2115),gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu_depth_buffer_created_for_unordered_access_is_placed.v_trig_preop_f64matches what the test expects bit for bit, same as on the gfx1036 measurements.Not tested: Windows on this card; gfx103x native Linux (native target, not Wine).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T17:52:50Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T18:41:08Z.
Diff review, CI, and both AMD and NVIDIA checks passed on
44455fe, but recentorigin/mainmerges turned this branchCONFLICTING/DIRTY. Please rebase ontoorigin/mainso it becomes mergeable again.Imported from ivall/xcl. Originally posted by NWProgramming00 on 2026-11-26T20:06:05Z.
@raylitebull rebased as asked. The new head is
a2d9c47, one120925, themaincommit just before #2555. It merges cleanly into currentmain8b957be, and the merge gives the same tree as the commit the suite ran on.8b957be+ this change, against8b957be: +2 everywhere, the same tracked failures.e120925, because since #2555 a cold shader preparation takes about 5 hours here.The description has the numbers.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T21:01:23Z.
Independent desktop NVIDIA verification of PR #2315 at rebased head
a2d9c470554cf43ad412af89a5b7c53812ebe4dc(1commit; exact parent & merge-base:e120925e3abc9956a8b9bae631969d32e8ccd43c, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
a2d9c470)cargo test --release -p xcl --lib trig_preop_f64_with_omod_is_refused -- --nocapture1 passed; 0 failed; 0 ignored; 1343 filtered out(0.00s)cargo test --release -p xcl --lib gpu_trig_preop_f64_matches_rdna2 -- --nocapture(3 consecutive runs, on-GPU RTX 4060 across both HLSL and direct DXIL backends)1 passed; 0 failed; 0 ignored; 1343 filtered out× 3 (0.26s,0.22s,0.22s)cargo test --release -p xcl --lib gpu::dxil::184 passed; 0 failed; 3 ignored; 1157 filtered out(3.79s;dispatch_chain_native_wave64_builds_wholeself-skipped on Wave32-only RTX 4060)cargo test --release -p xcl --lib gpu::recomp::403 passed; 0 failed; 20 ignored; 921 filtered out(5.27s; Wave64-only and#1426-refused subcases self-skipped as expected)cargo build --release -p xcl --bin xcl1m 14s, exit0)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
e120925e3abc9956a8b9bae631969d32e8ccd43c, cached baseline on the same machine):PR #2315 (
a2d9c470554cf43ad412af89a5b7c53812ebe4dc):Runtime log observations (
xcl.log)9222log lines,0[ERROR]/ device-removal / panic lines.19474 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14020 MB committed by the process; video memory 6114 MB local, 4683 MB non-local.Limits of coverage
gpu_trig_preop_f64_matches_rdna2executed directly on the RTX 4060 GPU across both the HLSL and direct DXIL backends (3/3 passes against all 64 RDNA2 gfx1036 reference rows), andtrig_preop_f64_with_omod_is_refusedverified refusal of output modifiers.gpu::dxil::andgpu::recomp::self-skipped on the Wave32-only RTX 4060, and the existing#[ignore]dump/fuzz/benchmark tests remained ignored.title: 29640639serves as an end-to-end non-regression check and was not confirmed to execute a retail shader containingv_trig_preop_f64.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by artor410 on 2026-11-28T07:56:53Z.
Test report, head
a2d9c47, NVIDIA GeForce RTX 3070 Ti (driver 610.88), Windows 11, rustc 1.100.0, debug build, no game data (no XCL_SAMPLE_* set).cargo test --workspace -- --test-threads=4: 1396 passed, 1 failed, 31 ignored.The one failure is
e2e::test_title_runs_under_the_debug_layer_with_dred(test title exits 0xC0000005 under the debug layer). It fails the same way on maine429936on this machine, so it is not from this PR. Everything else passes.AI use: Claude Code (Claude Opus 5.5) ran the suite and wrote this.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-29T09:43:07Z.
Supplemental arithmetic check for
a2d9c470554cf43ad412af89a5b7c53812ebe4dc. I independently recomputed the first 1,184 bits of 2/π and matched all 37 words in the proposed table. In an isolated Python model, I enumerated all 65,536 pairs of the 11-bit exponent and 5-bit segment. The three-word window agreed with arbitrary-precision bit extraction, and the bit packing agreed with binary64 scaling: 32,025 normal, 2,012 subnormal, and 31,499 zero cases, with no mismatches.That checks the arithmetic for the proposed table with subnormals preserved. It does not establish RDNA2’s hardware table length, emitted DXIL or HLSL behavior, or a Windows GPU result. No XCL code was executed. AI assistance: OpenAI ChatGPT wrote and ran the independent arithmetic model.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:48:35Z.
Triage (#1607) – head
a2d9c47No open or merged PR translates v_trig_preop_f64; on main it is only in the generated spec table (#2169 merely lists TRIG_PREOP in its fuzzer's skip list).
Read both forms (recomp/emit.rs
trig_preop, dxil/lower_wide.rsLw::trig_preop): same shift, window and denormal handling, and the test runs both backends against the 64 measured gfx1036 rows. Minor: in the direct form the 64-bit shifts byk/-kcan get a count >= 64 on the branch the select drops; the HLSL form masks it with& 63, the direct one does not.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.