Skip to content

Recompiler tests: GPU checks for VOP3 bit-field, perm, align and min3/max3/med3 - #445

Open
AC-Storm-YT wants to merge 1 commit into
xcl-dev:mainfrom
AC-Storm-YT:recomp-vop3-int-tests
Open

AC-Storm-YT wants to merge 1 commit into
xcl-dev:mainfrom
AC-Storm-YT:recomp-vop3-int-tests

Conversation

@AC-Storm-YT

Copy link
Copy Markdown

Eleven 32-bit VOP3 integer instructions the recompiler translates had no test: v_bfi_b32, v_bfm_b32, v_perm_b32, v_alignbit_b32, v_alignbyte_b32 and v_min3 / v_max3 / v_med3 for u32 and i32. This adds one GPU test for them. Test only: nothing outside tests.rs changes.

What is in it

  • gpu_vop3_integer_bit_and_minmax3 (crates/xcl/src/gpu/recomp/tests.rs): one kernel with all eleven instructions, run as wave64 and wave32 (gpu_waves), 32 dispatches of operand triples from a fixed LCG – edge values (0, 1, 31, 32, 33, 0x7FFFFFFF, 0x80000000, 0xFFFFFFFF, every v_perm_b32 selector kind: bytes 0..7, the sign selectors 8..11, 12 and 13+) mixed with arbitrary words. Each result is compared bit for bit with the instruction's RDNA2 definition computed on the CPU (not with the emitted HLSL).

Tested

  • AMD Radeon RX 9070 XT (RDNA4, wave64), driver 32.0.32029.2010; AMD Ryzen 7 9800X3D; Windows 11 Pro build 26200; Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug; DXC 1.8.2502.11
  • cargo test --workspace -- --test-threads=4 on this branch's head: 677 passed, 0 failed, 41 ignored. No SKIPPED tests.
  • The new test fails when the emitter is broken: with each of these changes made to emit.rs by hand (and reverted), it reported wrong results for that instruction – v_med3_i32 compared unsigned (1407 results), v_perm_b32 selector 8 reading s0 (37), v_alignbyte_b32 shifting by 4 bits a byte (1215), v_bfm_b32 with the wrong zero-width case (488), v_max3_u32 ignoring src2 (629).

Regression run
Not needed: the PR changes only crates/xcl/src/gpu/recomp/tests.rs.

Not tested

  • NVIDIA / Intel and wave32-only GPUs: wave32 ran on the RX 9070 XT only.
  • Operand modifiers (neg / abs / clamp / op_sel) and inline-constant or SGPR operands: every source is a VGPR.

AI use

  • Claude Code with Claude Opus 5.5 wrote the test and this description, and ran the tests and the emitter-break checks on my machine. I can't review the bit-level semantics myself.

@PHeitor1

Copy link
Copy Markdown
Contributor

Tested 77eab20 merged onto main 2997c9a.

RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed, so the debug-layer tests run), rustc 1.100.0 MSVC, debug, cargo test --workspace --no-fail-fast -- --test-threads=4, no XCL_SAMPLE_*.

Pass: 677 passed, 0 failed, 41 ignored. SKIPPED: only the 2 no wave64 tests (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware). gpu_vop3_integer_bit_and_minmax3 runs on the GPU and passes. Build clean.

Run and written with Claude Code (Claude Opus 5.5).

@CryingLaughing

Copy link
Copy Markdown
Contributor

The exact PR head 77eab20adfdb2472c77a747db16c3e9e6e7fabb4 passed on an RTX 4080. This adds Ada wave32 coverage alongside the RDNA4 and Blackwell runs above.

Tested

  • NVIDIA RTX 4080, driver 621.01, Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC x64, DXC 1.8.2502.11, debug. XCL_ADAPTER=4080, synthetic fixtures, all XCL_SAMPLE_* variables unset.
  • cargo test -p xcl --lib --locked -j 4 gpu_vop3_integer_bit_and_minmax3 -- --show-output passed 1/1 on native wave32. The fixture checks 11 instructions across 32 waves of 32 lane inputs against Rust results.
  • cargo build --workspace --locked -j 4 passed. cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output reported 677 passed, 0 failed, 41 ignored. That includes four explicit capability skips and opt-in game-data tests that returned early.
  • SKIPPED for native wave64: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware. SKIPPED for D3D12 debug-layer availability: test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state.

Not tested

  • Native wave64, other adapters, release builds, retail titles.

AI use

  • OpenAI Codex (GPT-6 family, exact variant unavailable) ran the commands, checked the logs, and drafted this report.

@AC-Storm-YT
AC-Storm-YT marked this pull request as ready for review November 24, 2026 01:05
@13hourstilliland

Copy link
Copy Markdown
Contributor

Adding an Ampere 8 GB (RTX 3070, 32-lane waves) run on the exact PR head 77eab20.

Tested

  • Commit: 77eab20adfdb2472c77a747db16c3e9e6e7fabb4 (PR Recompiler tests: GPU checks for VOP3 bit-field, perm, align and min3/max3/med3 #445 head), clean worktree
  • Hardware: NVIDIA GeForce RTX 3070 8 GB, driver 610.88; Intel Core i5-12600K, 31.8 GB RAM; Windows 11 Home build 26200.9974
  • Toolchain: Rust 1.100.0 (stable-x86_64-pc-windows-gnu, not MSVC); DXC 1.9.2609.5 (01b62ad4) via XCL_DXC_DIR; debug build; no XCL_SAMPLE_* set
  • Targeted command: cargo test -p xcl --lib -- gpu_vop3_integer_bit_and_minmax3 --show-output
    • Result: 1 passed, 0 failed, 0 ignored (ran on the GPU, no skip)
  • Full workspace command: cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output (interactive desktop session)
    • Result: 677 passed, 0 failed, 41 ignored across 16 test binaries (xcl lib: 637 passed, 0 failed, 21 ignored; e2e: 3/0)
  • SKIPPED (4, not coverage):
    • no wave64 (2): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware
    • no D3D12 debug layer (2): test_title_draws_with_a_root_signature_under_the_debug_layer, uploads_start_from_each_subresources_state

Not tested

  • AMD / wave64 hardware, MSVC toolchain, release build, retail title / scripts/smoke.ps1, D3D12 debug-layer tests

AI use

  • Hermes Agent, gemini-4-neon: ran the commands and wrote this report from the logs; the human reviewed it.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@github-actions

Copy link
Copy Markdown

Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 28, 2026
…/max3/med3

v_bfi_b32, v_bfm_b32, v_perm_b32, v_alignbit_b32, v_alignbyte_b32 and
v_min3 / v_max3 / v_med3 (u32 and i32) are translated but had no test.
One kernel runs all eleven as wave64 and wave32 over 32 dispatches of
operand triples (edge values and every v_perm_b32 selector kind, mixed
with arbitrary words by a fixed LCG), and compares each result with the
instruction's RDNA2 definition computed on the CPU.

Checked that it fails when the emitter is broken: v_med3_i32 compared
unsigned, v_perm_b32 selector 8 reading s0, v_alignbyte_b32 shifting by
4 bits a byte, v_bfm_b32's zero-width case and v_max3_u32 ignoring src2
each made it report wrong results.
@AC-Storm-YT
AC-Storm-YT force-pushed the recomp-vop3-int-tests branch from 77eab20 to ccd516e Compare November 29, 2026 20:46
@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@AC-Storm-YT

Copy link
Copy Markdown
Author

Rebased onto main. It still adds GPU tests for v_bfi_b32, v_bfm_b32, v_perm_b32, v_alignbit_b32, v_alignbyte_b32 and v_min3/v_max3/v_med3 (u32 and i32), which are translated but had no test; it only waits for a maintainer.

@relativespace2K

relativespace2K commented Nov 30, 2026 •

Copy link
Copy Markdown

merge-check
base: 53e85fb
head: ccd516e
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2789 passed, 6 failed, 49 ignored; failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, ram_budget::tests::windows_takes_a_working_set_maximum_and_lifts_it, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (in --test gpu_two_pass_cache_e2e, so 5 failing tests give 6 failures). The same five fail on base 53e85fb alone (2788 passed, 6 failed, 49 ignored there), so none comes from this PR; its new GPU test passed and is not among the SKIPPED lines, so it ran on the RX 6800 XT in both wave sizes. 13 SKIPPED lines, all environmental: no D3D12 debug layer / d3d12SDKLayers.dll, no heap windows, no GPU_UPLOAD, per-lane f16/f32 forms refused.
review: no blocking finding; one file, every line read. The references are computed on the CPU from the ISA's definitions and not from the translator: v_perm_b32's selector decode covers bytes 0..7, the 16- and 32-bit sign replicas (8..11), the zero byte (12) and the all-ones byte (13 and above); the funnel shift builds the 64-bit pair the same way; med3 is the ordinary median written as max(a,b).min(min(a,b).max(c)), which is the definition and not a guess. The operand mix deliberately reaches the sign bit, shift counts of 0, 31 and past 31, and it runs over every lane of a wave in both wave32 and wave64, with the failures de-duplicated so the message names one bad triple per case. No duplicate: #1057, #1206 and #1576 cover neighbouring instruction groups; none of them runs these eleven.
performance: none: tests only.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6800 XT 16 GB (RDNA2, wave64), driver 32.0.21045.29003; Ryzen 5 5600, 32 GB RAM; Windows 10 IoT Enterprise LTSC 2024, 10.0.26100 build 26100.9974; Rust 1.100.0; DXC 1.9.2602.17; debug build. DeepSeek Harness coding agent, model DeepSeek V4.1 Flash.

@github-actions github-actions Bot added the needs-1st-check Passes gates; needs first independent merge-check (#3041) label Nov 30, 2026
@github-actions github-actions Bot added needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Nov 30, 2026
@tiagonleal

tiagonleal commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 9dfbe3e
head: ccd516e
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails the same way on the base alone (2885 passed, 1 failed, 51 ignored; fixed by #3513). The new test gpu::recomp::tests::gpu_vop3_integer_bit_and_minmax3 runs on this card as wave32 only (no wave64 here) and passes, in the suite, alone, and alone with XCL_DIRECT_DXIL=0 (HLSL path). It really compares GPU results here: with the expected V_BFI_B32 value changed on purpose, it fails with lines such as V_BFI_B32(0x00000000, 0x00000000, 0x0000001f) = 0x0000001f, want 0x0000001e.
review: whole diff read (+88/-0, gpu/recomp/tests.rs). I checked each expected value against the RDNA2 definitions. V_BFI_B32 is (S0 & S1) | (~S0 & S2). V_BFM_B32 is ((1 << S0[4:0]) - 1) << S1[4:0]. V_PERM_B32 takes the bytes of {S0, S1} with S1 low; selectors 8 to 11 give the sign of S1[15], S1[31], S0[15] and S0[31]; 12 gives 0x00 and 13 and above give 0xFF. V_ALIGNBIT_B32 is {S0, S1} >> S2[4:0] and V_ALIGNBYTE_B32 is {S0, S1} >> 8 * S2[1:0]. The med3 helper takes the min of max(a, b) and max(min(a, b), c), which is the median. The signed variants work on sign-extended values. All of them match. Without a GPU, gpu_waves() returns an empty list and the test passes without a SKIPPED line. Partial overlap only: integer_programs_on_the_gpu (gpu/recomp/lower.rs, the program at about lines 3084-3097 on this base) already runs V_BFI, V_BFM, V_ALIGNBIT, V_ALIGNBYTE, V_MIN3_U32, V_MAX3_I32 and both V_MED3 on one operand set. V_PERM_B32, V_MAX3_U32 and V_MIN3_I32, and the edge operands (sign bit, shift counts 0, 31 and above 31, every perm selector kind), are new here.
performance: test-only change; no smoke run.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite and test runs, checked the expected values against the ISA and the merged source and wrote this)

  • Tiago

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head ccd516e

Overlaps with other test-only PRs in gpu/recomp/tests.rs: #1576 also checks all 11 of these ops (plus ffbh/bcnt/SAD/LERP/16-bit min3) on fixed inputs; #1057 (alignbit/alignbyte/perm), #1226 (bfi/bfm/perm and bit scans) and #1199 (min3/max3/med3 i32/u32/i16) cover subsets. None of them makes this exact change, and this one is the earliest and the only one that runs randomized edge operands on both wave sizes.
The CPU references in check_vop3_integer_bit_and_minmax3 match the RDNA2 definitions (v_perm_b32 selectors 8-11 take bits 15/31 of S1 then S0, 12 is 0x00, 13+ is 0xFF; bfm/alignbit mask the counts to 5 bits, alignbyte to 2). 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) off-goal Does not bear on the current goal (world loading); waits until it is reached ready-to-merge Has 2 independent safe merge-checks on current head (#3041) stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants