Recompiler: cube sc / tc negate by the sign bit on both backends #2338
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2348"
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 Victorbriez on 2026-11-25T16:13:56Z.
Both backends negated the sources of
v_cubesc_f32/v_cubetc_f32withfsub -0.0, x: the HLSL helpers through-x, the direct lowering throughfneg. A driver may flush a denormal there: NVIDIA does on the HLSL path, sov_cubetc_f32returned ±0 for a denormal source; RADV under vkd3d-proton does on the direct path (reported below). Both now flip the sign bit. Fixes #2347.What is in it
bc43fd6): aneg_bitshelper in the HLSL prelude, used bycube_scandcube_tc(crates/xcl/src/gpu/recomp/emit.rs); anfneg_bitshelper used bycubein the direct lowering (crates/xcl/src/gpu/dxil/prelude.rs); and the GPU testgpu_cube_coordinates_negate_denormals_by_signon both backends (crates/xcl/src/gpu/recomp/tests.rs)Tested
bc43fd6(onmain3ceb550), no uncommitted changesmain(hlsl lane 0: tc0x80000000, want0x80000001) and passes with the fix on both backendscargo test --workspace --no-fail-fast -- --test-threads=4:main3ceb5501346 passed, 1 failed, 46 ignored; this PR 1347 passed, 1 failed, 46 ignored (the new test). The one failure is the same on both,a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrierfrom #2074, and is not touched hereV_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32, #2182); 1 × no heap windows; 1 × Developer Mode off (0x887A002D); 2 × no xgameruntime.dllvalu_fuzz_backends_agree(its file added locally, not part of this PR):main1 instruction differs (V_CUBETC_F32, 58 of 256); this PR 0 differ, 333 of 341 compared (oneda3db7, the same change before this rebase; not rerun onbc43fd6)Regression run
scripts/smoke.ps1onmainand on this head, I will add both blocks here. Until then this stays a draft.Not tested
AI use
🤖 Generated with Claude Code
upstream-sync referenced this pull request2026-11-25 17:07:11 +00:00
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T16:41:26Z.
Tested: current PR head merged onto current
origin/main(clean,a5b31491), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).The new test goes red on this lane, but only on the
direct_dxilbackend.gpu_suite (--release --locked,--test-threads=2): 145 passed / 4 failed / 1 ignored vs baseline 144 / 3. The three baseline failures are this rig's known set (fuzz seed 1003 of #2115,gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu_depth_buffer_created_for_unordered_access_is_placed); the 4th is the newgpu_cube_coordinates_negate_denormals_by_sign.--test-threads=1, always the first assert of the second backend loop:direct_dxil lane 0: (sc, tc) of [0000ffff, 00000001, bf800000]->left: [2147483648, 2147483648]right: [2147549183, 2147483649](tests.rs:9690).0x8000FFFF/0x80000001(denormals negated by sign bit), got0x80000000twice, i.e. the GPU returned-0.0for both: the denormals were flushed to zero. Thehlslbackend loop passes on this lane (the PR's fix holds there); it is thedirect_dxilbackend's emitted code that still loses denormals on RADV, exactly thefsub -0.0, xclass the test doc-comment warns about.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
[PR #2348] Recompiler: cube sc / tc negate by the sign bit on the HLSL backendto [PR #2348] Recompiler: cube sc / tc negate by the sign bit on both backendsImported from ivall/xcl. Originally posted by Victorbriez on 2026-11-25T17:10:43Z.
Thanks, you are right, and the description was wrong about the direct backend: its
fneg(crates/xcl/src/gpu/dxil/lower.rs) isfsub -0.0, xtoo, not a sign-bit flip. NVIDIA keeps the denormal there, RADV under vkd3d-proton does not.eda3db7(onmain50a9fde) flips the sign bit in the directcubeas well (fneg_bitsincrates/xcl/src/gpu/dxil/prelude.rs, an integer xor). On the RTX 3070 the test still passes on both backends and #2169's fuzzer finds no difference; the description has the new counts. Could you rerungpu_cube_coordinates_negate_denormals_by_signon your RADV lane with this head?AI use: Claude Code (Claude Opus 5.5) checked the report against the code, wrote the change and this reply; I checked it before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T18:27:08Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). 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 emirduran707 on 2026-11-25T19:54:45Z.
Independent AMD RDNA4 (native wave64) test report on exact head
bc43fd6dc4035f3687fe2667024b65e9742442f6(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1345 passed, 3 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.gpu::recomp::tests::gpu_cube_coordinates_negate_denormals_by_sign.main:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722) andfuzz_validate_and_gpu_3(seed 1599) on this GPU, plusgpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier(from50a9fde/ #2074, fixed later onmainin #2420).Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:26:22Z.
Review: COMMENTED
No source-level defect found. The sign-bit XOR is consistent across HLSL and Direct-DXIL, preserves bit patterns, and the new GPU test covers both backends with denormals; the submitted RDNA4 report and head smoke are encouraging. Merge readiness is administrative: all current PR-description checks fail because the required full main baseline smoke block is missing (a summary is not enough). Please add the complete main block and rerun the description check.
Imported from ivall/xcl. Originally posted by Victorbriez on 2026-11-25T20:17:44Z.
Thanks a lot, this is the AMD / native wave64 run and the regression run this PR was missing.
PR checksneeds bothxcl-smokeblocks pasted under Regression run, and themainone has to be the block itself, not a summary. Could you paste the fullxcl-smoke v1block of yourmain68a284arun (the 1573 frames / 14420 MB one)? I will then put both blocks in the description, credited to you, with your hardware and the counts.AI use: Claude Code (Claude Opus 5.5) read the report and drafted this reply; I checked it before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T08:15:24Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:52:52Z.
Triage (#1607) – head
bc43fd6This fixes #2347. No other open or merged PR changes the negation in
cube_sc/cube_tc. On main, the HLSL prelude still uses-x/-y/-z, and the DXILLw::cubestill usesfneg. Both backends now flip the sign bit, and the new GPU test compares both against fixed bit patterns that include denormals. #1101 and #1639 only add cube tests. No problems found in the diff.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.