Recompiler: v_pack_b32_f16 applies the abs and neg half modifiers #1720
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!1720
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1720"
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?
@b3IKK on GitHub · 2026-11-24 19:52 UTC · original
b3IKK:recomp/v-pack-b32-f16-modifiers→main· +89 −5 · 4 files · 1 commits · openAddresses
XCL-BT-038from #1488.v_pack_b32_f16built the packed dword fromOP_SEL's halves and ignored the VOP3abs/negsource modifiers, which the rest of the 16-bit paths (hbinvalu16, and thev_cvt_pknorm_*_f16pair) apply to the picked half's sign bit. A console shader that packs-|x|or-von one half therefore got the source's own value, and the instruction had no test at all.This applies both modifiers to the selected half, exactly as the pknorm conversions do, in both translators: the HLSL path (
Em::valu) and the direct DXIL one (dxil::lower_valu), which lowers the instruction on its own.Since the review (@ddaikodaiko found the direct-DXIL gap, @nnonno91 measured it on AMD and NVIDIA): the first version fixed the HLSL path only, so with
XCL_DIRECT_DXIL=1the modifiers were still dropped (-|2.0|packed0x38004000, not0x3800C000). The same two sign-bit operations are now inlower_valu.rs, and the GPU test runs the program through both translators whateverXCL_DIRECT_DXILsays. The change inlower_valu.rswas written here from the description of the gap, not taken from the fork commit linked in the review.What is in it
crates/xcl/src/gpu/recomp/emit.rs:v_pack_b32_f16appliesabs(& 0x7FFF) andneg(^ 0x8000) to the halfop_selpicks.crates/xcl/src/gpu/dxil/lower_valu.rs: the same in the direct DXIL translator.crates/xcl/src/gpu/dxil/kernel.rs:TRANSLATOR_VERSION9 → 10 (the direct translator's output for these programs changes, and its sources are not inbuild.rs's hash). Other open direct-DXIL PRs bump the same line, so this will conflict with whichever merges first.crates/xcl/src/gpu/recomp/tests.rs:pack_b32_f16_applies_the_half_modifiers(emitted HLSL; fails onmain— the& 0x7FFF/^ 0x8000are absent) and GPU testgpu_pack_b32_f16_half_modifiers(pack,-|2.0|,op_selhigh halves with|-4.0|and-(16.0),|-6.0|, through the default path and through the direct DXIL translator).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 1156 passed, 0 failed, 46 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses,no heap windows, andcannot disable the driver cache (Windows Developer Mode is required))cargo test -p xcl --lib -- pack_b32_f16: 2 passed, 0 failed, withXCL_DIRECT_DXILunset and withXCL_DIRECT_DXIL=1lower_valu.rschange taken out: 1 passed, 1 failed —direct DXIL, lane 0: -|2.0| packs -2.0,left: 939540480, right: 939573248(0x38004000/0x3800C000, the values in the review)Regression run
main (
568e7db, clean tree, no local changes):PR (
94ecdd5, clean tree, no local changes):Not tested
XCL_DIRECT_DXIL=1(only the twopack_b32_f16tests ran with it)AI use
XCL-BT-038against the code and the existing pknorm paths, wrote the fix in both translators and the tests (and confirmed each fails without it), rebased onto689f2db, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.@ddaikodaiko on GitHub · 2026-11-24 19:58 UTC · original
One gap for this fix: the direct DXIL translator has the same bug in a second place.
crates/xcl/src/gpu/dxil/lower_valu.rs, the"v_pack_b32_f16"arm, builds the halves fromSRC0/SRC1andOP_SELbut ignoresMods::abs/Mods::neg:so with
XCL_DIRECT_DXIL=1(or=all) the modifiers are still dropped. The same two sign-bit operations on each selected half fix it there:abs→andc(h, 0x7FFF),neg→xor(h, 0x8000), with indices 0/1 ofm.abs/m.negfor the low/high half.I have that as a fork commit (
ddaikodaiko/xclcontrib/valupack-abs-neg319a384, on top of6c89285) and the existing GPU testgpu_v_pack_b32_f16_honors_abs_negshould pin it withXCL_DIRECT_DXIL=1; I could not build or run it here, so it is unverified. The0xC0003C00/0x4000BC00pair from the description is what both paths should produce.This also applies to #1207 if it is kept separately. AI use: written with OpenCode (DeepSeek V4.1 Flash); the person submitting any code from this is responsible for running it.
@b3IKK on GitHub · 2026-11-24 21:49 UTC · original
Rebased onto
1d027e5and re-ran both with the current scripts/smoke.ps1 (#677's hashed itle: line): 961 passed, 0 failed, 43 ignored.@DavidM1911 on GitHub · 2026-11-24 22:28 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.Thanks!
@b3IKK on GitHub · 2026-11-24 23:25 UTC · original
@ddaikodaiko @nnonno91 thank you both: the direct DXIL translator had the same gap, and the measurement (
0x38004000instead of0x3800C000at lane 0) is exactly what I get here without the change.Pushed
3edf769(rebased onto689f2db):dxil/lower_valu.rs:abs(& 0x7FFF) andneg(^ 0x8000) on the halfop_selpicks, indices 0 / 1 for the low / high half, as in the HLSL path. I wrote this from the description of the gap rather than taking the fork commit, which its author said was not built or run.gpu_pack_b32_f16_half_modifiersnow runs the program through the default path and through the direct translator in the same test, so it does not depend onXCL_DIRECT_DXILbeing set. With thelower_valu.rschange taken out it fails atdirect DXIL, lane 0: -|2.0| packs -2.0(left: 939540480, right: 939573248).TRANSLATOR_VERSIONgoes 7 → 8, askernel.rsasks for a change in the direct translator's output. Other open direct-DXIL PRs bump the same line, so one of us will have a one-line conflict.Suite: 977 passed, 0 failed, 45 ignored. The two
pack_b32_f16tests pass withXCL_DIRECT_DXILunset and with=1. Not run: the whole suite withXCL_DIRECT_DXIL=1, and AMD on this head.On #1207: I have not looked at it.
AI use: OpenCode, Claude Fable 5.2 made the change, ran the tests and wrote this comment.
@b3IKK on GitHub · 2026-11-24 23:45 UTC · original
A correction to my comment above. I wrote "On #1207: I have not looked at it." That was wrong: #1207 is this account's own earlier PR for the same change (#1607, group D49, "one author: the same change"). I had not checked whose it was before answering.
The two do the same thing in
emit.rs. This PR now also fixes the direct DXIL translator and tests both paths, so it is the one to keep. I am closing #1207 in its favour. What #1207 had that this one does not: its GPU test ran both wave sizes with a NaN payload. If a reviewer wants that case here, say so and I will add it.AI use: OpenCode, Claude Fable 5.2 wrote this comment.
@raylitebull on GitHub · 2026-11-25 02:01 UTC · original
CIworkflow approved for3edf769.Diff looks clean (
emit.rsanddxil/lower_valu.rsapplyabs/negto the selectedop_selhalf). Remaining before merge: rebase onto currentmain(dropping thekernel.rsmanualTRANSLATOR_VERSIONbump since merged#1947auto-hashesgpu/dxil/*viaXCL_DIRECT_DXIL_SOURCE_ID), and obtain an AMD GPU verification pass on the rebased head.@JJAutoCompare on GitHub · 2026-11-25 04:39 UTC · original
Tested
Independent Arc A770 verification of open PR #1720 at
3edf769e5a841ce271cd8f4ab99941f26d1ac704. The reused checkout was clean and detached at that SHA before and after.STOR-WINLAB, Windows 11 Enterprise Evaluation 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust and Cargo 1.100.0 x86_64-pc-windows-msvc, DXC/DXIL 1.9.2609.5. The unoptimized build used two Cargo jobs with incremental compilation and debug info disabled.
The build and CPU fixture ran outside the mutex. The CPU fixture confirmed HLSL uses
& 0x7FFFfor ABS and^ 0x8000for NEG. The GPU fixture dispatched HLSL/DXC and direct DXIL, with 512 output assertions across both backends. All 64 logical lanes matched the expected four dwords0x38004000,0x3800C000,0xCC004400, and0x4600C000. The cases covered unmodified low halves, ABS/NEG, high-half selection, and source-one ABS. The wrapper logged mutex release.2 passed, 0 failed, 0 ignored, 0 skipped. Each fixture exited 0 and filtered out 952 tests. CPU took 0.02 s and GPU 0.68 s.
Not tested
Partial or zero EXEC masks, other adapters, the workspace suite, and retail smoke.
AI use
T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixtures and wrote the test report.
@b3IKK on GitHub · 2026-11-25 10:48 UTC · original
Rebased onto
568e7db; the only conflict wasTRANSLATOR_VERSION, whichmainhad already taken to 9, so this head is 10. Head94ecdd5: 1156 passed, 0 failed, 46 ignored, and the smoke pair in the description is568e7db/94ecdd5run one after the other (both 1640 frames, 0 crashes, 0 device removals). AI use: OpenCode, Claude Fable 5.2.@zhouzhidong3-hash on GitHub · 2026-11-25 11:06 UTC · original
Independent RTX 5070 focused check of clean head
94ecdd55d5f2a761ff498c1787c2ce4d46512f74.Windows 10 x64, i7-12700KF, RTX 5070 driver 591.86, Rust 1.100.0 MSVC debug, DXC/DXIL 1.8.2502.11, local D3D12 Agility SDK;
XCL_ADAPTER=5070.cargo test --locked -p xcl --lib pack_b32_f16 -- --test-threads=1 --nocaptureXCL_DIRECT_DXIL=0: 2 passed, 0 failed, 0 ignored, 1124 filtered out, 6.99 s.XCL_DIRECT_DXIL=all: 2 passed, 0 failed, 0 ignored, 1124 filtered out, 0.26 s.Additional reproduction, separate from the clean-head run: copied this PR's test-only hunk onto older
7a1f5a2with no runtime changes. The GPU test failed in both modes at-|2.0|, actual packed word 939540480 versus expected 939573248. Applying this PR's two runtime emitter hunks there (leaving that older tree's cache-version constant alone) made the two focused tests pass in both modes, without skips. This is a ported before/after control, not a parent-commit control for the rebased head.Not tested: full workspace, Release, native wave64, AMD/Intel, retail smoke, or gameplay impact. Durations are single runs and are not a performance comparison.
Logs: nvidia-pr1720-head-0.log, nvidia-pr1720-head-all.log, nvidia-pack-before-{0,all}.log, nvidia-pack-after-{0,all}.log under I:\neospace\work\xcl-1994-5070.
AI assistance: OpenAI Codex ran the unchanged upstream tests, prepared and restored the older-tree control, checked the logs and drafted this report.
@nnonno91 on GitHub · 2026-11-24 20:05 UTC · original · edited 2026-11-25 14:32 UTC
Retest on
94ecdd55d5f2a761ff498c1787c2ce4d46512f74@b3IKK The rebased head passed on my native-wave64 Radeon and RTX 5090. This resolves the direct-DXIL failure I reported below.
Tested
cargo test --locked -p xcl --lib pack_b32_f16 -- --nocapture --test-threads=1withXCL_ADAPTER=AMD Radeon(XCL_REQUIRE_GPU=wave64) andXCL_ADAPTER=NVIDIA GeForce RTX 5090in separate processes. Each gave 2 passed, 0 failed, 0 ignored and no skips. The fixtures covered four packed results across 64 lanes with each translation path on both GPUs.Not tested
A retail title, the full workspace suite and partial EXEC masks in this retest.
AI use
OpenAI Codex (GPT-6.2 Sol) ran the retest and updated this report.
Independent GPU test of
ca4c7df9a28c4f0079a5ee3b836b8d87fb76548d. The PR's HLSL path passes on AMD and NVIDIA. The same fixture reproduces the direct-DXIL sign-modifier gap reported above on both GPUs.Tested
XCL_ADAPTER.cargo build --workspace --lockedpassed. On AMD with the default shader settings,cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 860 passed, 0 failed, 42 ignored. One pass logged an explicit skip,heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_pack_b32_f16_half_modifiers -- --exact --nocaptureproduced the same result on both adapters in each configuration below. All targeted invocations reported 0 ignored and no skips.XCL_DIRECT_DXIL=0XCL_DIRECT_DXIL=1XCL_DIRECT_DXIL=1In the direct failure the
-|2.0|case stopped at lane 0, producing0x38004000instead of0x3800C000. For the last row I temporarily applied only thelower_valu.rsdiff from ddaikodaiko's fork commit319a384to the PR head. The fixture passed all four packed-word checks across 64 lanes on each GPU. I restored the worktree afterward.Not tested
Retail-title output, a full workspace run with the local direct-DXIL diff, or the full workspace on NVIDIA.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) ran and checked the tests and wrote this report.
github-bot referenced this pull request2026-11-26 06:18:31 +00:00
@DavidM1911 on GitHub · 2026-11-26 06:17 UTC · original
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
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.