Shaders: reverse the halves of an i64 Bfrev with shifts and masks on AMD #2237
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2237
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2237/head"
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?
@oni-swr on GitHub · 2026-11-25 10:59 UTC · original
oni-swr:dxil-bfrev-i64-shifts→main· +62 −3 · 2 files · 1 commits · merged 2026-11-25 18:16 UTCPart of #2115. AMD's driver returns
x | bfrev(x)forBfrev.i32(trunc(mul i64))when the product is the same on every lane. The i64Bfrevlowering (reverse each 32-bit half, swap) goes through exactly that shape, so fuzz seed 817 read0xfe53ffffwhere the CPU has0x4a43fdeb. The halves are now reversed with five shift-and-mask steps. Reduced form:Bfrev.i64(mul i64 3, 5).Seeds on the RX 7800 XT,
main568e7dbplus this commit's base:IMax.i64fed by ani64udiv chain: the same chain with compare + select, or withIMin/UMax, passes. #1946 (i64 min/max as compare + select) fixes it: with itsops.rschange applied locally 783 goes to 0 mismatches. I did not include that change.So
fuzz_validate_and_gpu_1here still fails on 722 until #2192 and #1946 are in.What is in it
crates/xcl/src/gpu/dxil/ops.rs:bfrev32_shifts, used for both halves in the i64 case ofShader::bfrev.Bfrev.i32on an i32 is unchanged.crates/xcl/src/gpu/dxil/ops_tests.rs:bfrev_i64_of_a_uniform_product_matches_cpu(products3*5and the seed 817 constants). It fails without the change (low word0xf000000f, expected 0) and passes with it.Tested
a5af72b(rebased ontomain1a0bbe3).cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 1250 passed, 1 failed, 46 ignored. The failure isfuzz_validate_and_gpu_1, which stops at seed 722 (#2192); 783 (#1946) is behind it. The other failures seen before the rebase (pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa,gpu_image_get_resinfo_past_last_level) are gone.SKIPPEDlines (f16 / f32 per-lane forms refused, andheap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows); not coverage.bfrev_i64_of_a_uniform_product_matches_cpufails without the change on this card (low word0xf000000f, expected 0) and passes with it.debug_seedfor 817: 64 mismatching results before, 0 after.Regression run
Independent paired run on exact PR head
a5af72bba1a0d25fbd59f37a6a952b33874ce734vsmain1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6by @luckyteagirl (AMD Radeon RX 6800M, driver30.0.13002.13003, Windows 11 26200, Rust 1.99.0 MSVC, 7 s each, fresh data/cache directories; see comment):Main:
PR head:
Not tested
Bfrev.i32(trunc(mul i64))outside the i64 lowering is hit by a real shader.AI use
Claude Code (Claude Sonnet 5.5) reproduced the seeds, reduced them, wrote the change and the test, ran the suite and wrote this description; independent RX 6800M smoke blocks pasted from @luckyteagirl's comment.
🤖 Generated with Claude Code
@luckyteagirl on GitHub · 2026-11-25 12:19 UTC · original
Independent Windows/RX 6800M verification of exact PR head
a5af72bba1a0d25fbd59f37a6a952b33874ce734, with a same-duration owned-title smoke comparison against main1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6.Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. The worktrees and Cargo targets were isolated. No game files were copied or attached.Tested
XCL_ADAPTER=6800M XCL_REQUIRE_GPU=wave64 XCL_DIRECT_DXIL=1 cargo test --locked -p xcl --lib -j 2 bfrev_i64_of_a_uniform_product_matches_cpu -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, no skip. The new fixture ran on native wave64.cargo build --locked --workspace -j 2andcargo build --locked --release --workspace -j 2both passed on the exact PR head.XCL_ADAPTER=6800M XCL_DIRECT_DXIL=1 cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output: main 1012 passed, 169 failed, 26 ignored in the library; PR 1012 passed, 170 failed, 26 ignored. Both also failed the sameoffline_compute_pipeline_is_reused_by_a_second_processintegration test. Both emitted 9SKIPPEDmessages. The sole added library failure name wasgpu::dxil::ops_tests::bfrev_i64_of_a_uniform_product_matches_cpu, atCreateComputePipelineStateafter device suspension0x887A0005; it passed in the focused run. The broad suite is red on this driver, so this is not a clean full-suite result.Regression run
Same owned title, seven seconds each, default translation mode, fresh separate data/cache directories. Both runs completed with no memory guard, crash or device removal. These are the exact
xcl-smokeblocks:Main:
PR head:
Limits: An attempted 12-second PR run hit my external guard at 856 MB free system commit and was stopped before it emitted a smoke block; I excluded it from the comparison. The seven-second pair reached only the first frame, and no title dispatch of this bit-reversal form was observed. The synthetic fixture is the opcode check. The report does not establish a runtime performance or world-load improvement. If the PR head changes, its smoke block must be rerun for the new commit.
AI use: OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows builds and tests, monitored the owned-title smoke runs, compared the failure names and drafted this report. No game data was uploaded.
@frenziedcoder on GitHub · 2026-11-25 14:19 UTC · original
NVIDIA test report for
a5af72b: no new test failures (the 4 that fail also fail on1a0bbe3), its own GPU testbfrev_i64_of_a_uniform_product_matches_cpupasses on NVIDIA too (the shift-and-mask reversal isn't vendor-gated, so it runs here as well), and a clean smoke pair on the retail title (1614 vs 1671 frames).Tested
stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact heada5af72bba1a0d25fbd59f37a6a952b33874ce734, no local changes.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 1247 passed, 4 failed, 46 ignored; the PR's own testbfrev_i64_of_a_uniform_product_matches_cpuand the existingint64_bit_ops_match_cpupass. SKIPPED:gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu(const_mask, wave64: no wave64),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 packed, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 compares, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 conversions, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 rounding, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 three-source, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 transcendentals, wave64: no wave64),gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu(f64, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer carries, wave64: no wave64),gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(mask_ff0_flbit, wave64: no wave64),gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows),test_title_draws_with_a_root_signature_under_the_debug_layer(no d3d12SDKLayers.dll),uploads_start_from_each_subresources_state(no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))).fuzz_validate_and_gpu_0,fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_2,fuzz_validate_and_gpu_3ingpu::dxil::fuzz_tests. They fail the same way on the base1a0bbe3here (0x8007000EfromCreateComputePipelineStateon seeds 70, 545, 1019 and 1507, the NVIDIA refusal @PHeitor1 reported on #1679), so this PR adds no failure. (Seed 1019's program is 3,208 bytes here against 3,020 on the base: the longer reversal.)Regression run (
scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen;XCL_PSO_PRELOAD=0for both builds, because this machine's preload list holds the program of #1307)base (
1a0bbe3, this PR's merge base withmain):this PR:
Not tested: this code in the title: it is on the opt-in direct-DXIL path (
XCL_DIRECT_DXIL), which the smoke runs leave unset (default HLSL backend), so they show only that nothing else regressed; the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD, which the description and @luckyteagirl's run cover.AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report.
@fromthemoonx on GitHub · 2026-11-25 14:21 UTC · original
Second NVIDIA run (RTX 3060, 32-lane): passes at the head and merged onto current
main, and the new test passes here without the fix too, so only AMD runs check it. This adds to frenziedcoder's RTX 5080 report:cargo test --workspace --no-fail-fast -- --test-threads=4ata5af72bmain06c9f55(no conflicts)bfrev_i64_of_a_uniform_product_matches_cpu, 10 runsops.rsfrom the base1a0bbe3(3 runs)x | bfrev(x)behaviourSKIPPED: the same 24 lines at the head (
no wave64, the refused per-lane f16/f32 forms). The merged tree has one more,dispatch_chain_native_wave64_builds_whole: no wave64, from6c34370onmain.Hardware: RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, DXC 1.9.2602.17.
Not tested: a title, a release build.
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 16:42 UTC · original
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!
@cindertheblue on GitHub · 2026-11-25 17:27 UTC · original
Tested the head
a5af72bon two more AMD GPUs where seed 817 reproduces, a second RDNA3 card and an RDNA2 iGPU. The fix works on both.Tested
gfx1036), driver 32.0.21045.5002, on the same machine. Windows 11 Home 26200.9974, rustc 1.99.1, DXC 1.8.2502.11 (SDK 10.0.26100), debug, no local changes. "Control" is the head with onlycrates/xcl/src/gpu/dxil/ops.rsrestored from1a0bbe3.bfrev_i64_of_a_uniform_product_matches_cpu(3 runs)debug_seed,FUZZ_SEED=817debug_seed,FUZZ_SEED=783Without the change the new test fails the same way as on your RX 7800 XT:
case 0 low word, left4026531855(0xf000000f), right0. 783 is unchanged, as you say.cargo test --workspace --no-fail-fast -- --test-threads=4, once each:main1a0bbe3Each tree had
cargo build --workspacefirst. The extra pass is the new test. The failure isfuzz_validate_and_gpu_1on both trees, which stops before 817: atseed 722on the RX 7600 XT andseed 540on the iGPU. The same 8SKIPPEDlines in all four runs.Not tested: a release build, a title or smoke run,
XCL_DIRECT_DXILvariants, NVIDIA.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment from their output.