Skip to content

Recompiler: direct DXIL v_cmp_class_f16 reads the mask half OP_SEL[1] picks (stacked on #1214) - #1980

Open
regiumlepidi wants to merge 2 commits into
xcl-dev:mainfrom
regiumlepidi:direct-dxil-pr1214
Open

regiumlepidi wants to merge 2 commits into
xcl-dev:mainfrom
regiumlepidi:direct-dxil-pr1214

Conversation

@regiumlepidi

@regiumlepidi regiumlepidi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1214. Part of #1269.

#1214 makes v_cmp_class_f16 read the class mask from the half that OP_SEL[1] picks for SRC1, in the
HLSL path (recomp/emit.rs). The direct RDNA2 -> DXIL translator (XCL_DIRECT_DXIL=1,
gpu/dxil/lower_valu.rs) still read the low half, so the PR's own GPU test fails there
((0,0) instead of (4294967295,0)). This adds the same rule to the direct path.

What is in it

If #1214 merges first, only the second commit remains; if the author prefers to take it into #1214, this can be closed.

Tested

  • RTX 5070 Ti 16 GB (Blackwell, wave32), driver 617.42, Ryzen 7 9800X3D, Windows 11 26300; Rust 1.100.0, debug
  • cargo test --workspace -- --test-threads=4, default path: 941 passed, 4 failed, 25 ignored (23 SKIPPED GPU tests); the new test passes
  • same with XCL_DIRECT_DXIL=1: 941 passed, 4 failed, 25 ignored (23 SKIPPED); the new test passes
  • the 4 fuzz_validate_and_gpu_* failures are the same on main on this machine (DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905, E_OUTOFMEMORY on this driver)
  • control: gpu_cmp_class_f16_honours_opsel1 with XCL_DIRECT_DXIL=1 on the first commit alone: FAILED (so the second commit is what fixes it)

Regression run
Run by @Toons29 on a retail title, AMD Radeon RX 9070, release build, 60 s (#1980 (comment)); blocks as posted there. Within the CONTRIBUTING.md limits: frames 100 % of main, no crash, no device removal.

main:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1623 (PresentX 1623)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14648 MB

PR:

xcl-smoke v1
commit: 8b5aea71c9e39d89b515c782b15a59e5031c69bf
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1630)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14813 MB

Not tested

  • wave64 (this GPU runs wave32 only)
  • release build, real titles

AI use

  • Claude Code, model Claude Opus 5.5 (Anthropic). The agent wrote the fix, ran the tests above and opened this PR from the regiumlepidi account at the account owner's request.

🤖 Generated with Claude Code

b3IKK and others added 2 commits November 25, 2026 01:20
In V_CMP_CLASS_F16 (rdna2_spec.rs), SRC1 is a 16-bit operand so
OP_SEL[1] == 1 selects its upper 16-bit half as the class mask.
The emitter applied half(0, &ua) to SRC0 but passed ub unchanged,
ignoring OP_SEL[1].

Select SRC1 via half(1, &ub), with a GPU test covering OP_SEL[1]=0/1
and OP_SEL=3 across wave32 and split wave64.

Assisted-by: OpenCode (Gemini 4 Neon)
… picks

The direct DXIL translator (XCL_DIRECT_DXIL=1) shifted the whole 32-bit
SRC1 by the class index in v_cmp_class_f16, so OP_SEL[1] never selected
the mask's high half, as the HLSL path did before xcl-dev#1214. Take the half
OP_SEL[1] picks, as xcl-dev#1214 does in the HLSL path.

xcl-dev#1214's GPU test failed with XCL_DIRECT_DXIL=1 on an RTX 5070 Ti and
passes with this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DarkPanda69

Copy link
Copy Markdown

AMD run with native 64-lane waves, which this PR lists as not tested (the author's GPU runs wave32 only).

Tested: pass, head 8b5aea7 applied on main 6567c5f, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu:: --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, waves 32..64: 465 passed, 2 failed, 21 ignored. gpu_cmp_class_f16_honours_opsel1 ok. The 2 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and _3, which fail the same way on main 6567c5f without this PR on this card.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 467 passed, 0 failed, 21 ignored. Same test ok.

Not tested: release build; the whole workspace suite; a title.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@JJAutoCompare

Copy link
Copy Markdown

Arc A770 verification for XCL PR #1980
#1980

2026-11-25 | STOR-WINLAB | 8b5aea7
The PR was open at this head before and after the run. The assigned checkout was clean and detached at the same SHA. Read AGENTS.md and CONTRIBUTING.md, which match the previous checkout. The PR lists an RTX 5070 Ti author run and has two existing reports covering AMD and NVIDIA. Its conversation, inline comments, reviews, and a repository search for the exact fixture with A770 showed no Arc duplicate. The overlapping PR #1214 is the stated HLSL prerequisite.

Tested

Windows 11 Enterprise Evaluation 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175. Rust and Cargo 1.100.0 (x86_64-pc-windows-msvc). Both runs logged dxcompiler and DXIL 1.9.2609.5. The test profile was unoptimized with debug info disabled.

Prebuilt outside the Arc mutex with cargo test --locked -p xcl --lib --no-run (exit 0, 40.06 s). CARGO_TARGET_DIR=L:/XclTooling/pr2014-1c971de6/target, CARGO_BUILD_JOBS=2, CARGO_INCREMENTAL=0, CARGO_PROFILE_DEV_DEBUG=0, CARGO_PROFILE_TEST_DEBUG=0. XCL_ADAPTER=A770 and XCL_DXC_DIR=$env:LOCALAPPDATA/XclTooling/dxc-1.9.2609/bin/x64. TEMP and TMP used build-temp, test-0-temp, or test-1-temp under L:/XclTooling/pr1980.

Each invocation below ran in its own powershell.exe -NoProfile -ExecutionPolicy RemoteSigned process, with the indicated XCL_DIRECT_DXIL setting and separate stdout and stderr logs from process start.

$env:XCL_DIRECT_DXIL='0'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & 'L:/XclTooling/pr2014-1c971de6/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe' 'gpu::recomp::tests::gpu_cmp_class_f16_honours_opsel1' --exact --nocapture --test-threads=1
}

$env:XCL_DIRECT_DXIL='1'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & 'L:/XclTooling/pr2014-1c971de6/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe' 'gpu::recomp::tests::gpu_cmp_class_f16_honours_opsel1' --exact --nocapture --test-threads=1
}

HLSL + DXC (0) and direct DXIL (1) each exited 0 with 1 passed, 0 failed, 0 ignored, 0 measured, 969 filtered out, and 0.19 s elapsed. Total 2 passed, 0 failed, 0 ignored, 0 skips. Neither stream contained a skip notice. The fixture selects direct DXIL without fallback for setting 1.

Both processes exercised native wave32. The earlier #2089 capability probe on this host and driver measured a wave lane range of 8–32. At this revision the fixture's gpu_waves() helper adds wave64 only when hardware supports it natively.

The synthetic program used v0=0x00003C00 (low FP16 +1.0), v1=0x01000000 (high positive-normal class mask 0x0100, low mask 0), and v2=0x3C000000 (high FP16 +1.0, low +0.0). Each backend asserted (SGPR low, high) masks of (0xFFFFFFFF, 0) for OP_SEL=2 (low SRC0, high SRC1), (0, 0) for OP_SEL=0 (both low), and (0xFFFFFFFF, 0) for OP_SEL=3 (both high).

Build and test stdout/stderr logs are in L:/XclTooling/pr1980. Both wrappers logged lock release. The final Arc mutex release was at 04:53:08 CET and the target slot L:/XclTooling/pr2014-1c971de6/target is released for reuse.

Not tested

Other fixtures or FP16 classes, native or split wave64, other adapters, release builds, the workspace suite, fuzz tests, ancestor controls, and real-title smoke tests.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the fixture in both backends, inspected its assertions and the logs, and wrote this report.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 8b5aea71 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on cbc296ab, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1623 (PresentX 1623)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14648 MB
xcl-smoke v1
commit: 8b5aea71c9e39d89b515c782b15a59e5031c69bf
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1630)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14813 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 101 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

@thehollowedone

thehollowedone commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 6089122
head: 8b5aea7
merge: clean
build: cargo build --workspace -> ok
tests: XCL_ADAPTER=nvidia cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1465 passed, 1 failed, 47 ignored; 25 SKIPPED notices. The sole failure was gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk (DXIL not compiled), also reproduced on untouched main here. The new gpu_cmp_class_f16_honours_opsel1 passed in the workspace run; XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu_cmp_class_f16_honours_opsel1 -- --nocapture --test-threads=1 separately passed 1/1 with no skip.
review: AMD's RDNA2 ISA §6.2.5 excludes VOPC instructions encoded as VOP3 from OPSEL, and LLVM's GFX1030 syntax lists v_cmp_class_f16_e64 without op_sel but v_cmp_class_f16_sdwa with src1_sel. The added test encodes V_CMP_CLASS_F16 as VOP3 with OP_SEL=2/3; both changed emitters produce its expected value by construction. It compares neither result with the original RDNA2 instruction. For documented encodings with OP_SEL=0, the class decision uses only mask bits 0–9, so the new SRC1 half extraction does not change the decision. This also affects prerequisite #1214.
performance: not measured; both paths add a mask/extract operation to this compare, whose effect on generated DXIL was not measured.
verdict: not yet: establish native evidence for this exact VOP3 encoding if the title uses a console-specific exception; otherwise replace the unsupported OP_SEL test with documented SDWA src1_sel coverage and reconsider whether either patch is needed.
hardware / tool and model: NVIDIA RTX 3080 Ti 12 GiB, driver 621.35; Ryzen 7 9800X3D; Windows 11 build 26300; rustc 1.99.1 MSVC; DXC 1.8.2502.11. Codex (GPT-6.2 Sol) ran the build and tests, checked the diff and drafted this report; Codex (GPT-6.2 Astra) independently reviewed the instruction semantics.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 8b5aea7

@throny

throny commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

merge-check
base: 6089122
head: 8b5aea7
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1466 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored
review: no defect. Both paths now read the half of SRC1 that OP_SEL[1] selects, which agrees with the spec table's 16-bit SRC1 for this instruction (hardware behaviour not verified here). The test fails without the change; it covers the direct-DXIL path only when XCL_DIRECT_DXIL=1 is set. Note: it contains #1214's commit, which is still open: merge one, close the other.
performance: one extra AND or shift per class compare. It changes both the HLSL and the direct-DXIL translator sources: every tester re-translates once.
verdict: not yet: I withdraw my safe to merge. The other check on this head points to AMD's ISA text, which excludes compare instructions in the three-operand encoding from OP_SEL; my review only compared the change with the operand-size table and did not verify the hardware behaviour, so that evidence is the stronger one. Needed: native evidence for this exact encoding, or coverage of the documented SDWA form instead. (Edited after reading that check; build and suite results above are unchanged.)
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head 8b5aea7

Stacked on #1214: the first commit is #1214 cherry-picked unchanged (emit.rs reads the class mask through half(1, &ub)), the second adds the same OP_SEL[1] rule to the direct DXIL path (lower_valu.rs half(self, 1, ub)). Neither is on main yet (main still uses ub.clone() and shifts ub).
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

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants