Recompiler: apply ABS and NEG input modifiers in v_pack_b32_f16 #1198

Closed
b3IKK wants to merge 1 commit from upstream-pr/1207 into main
b3IKK commented 2026-11-24 13:14:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T13:14:30Z.


v_pack_b32_f16 supports VOP3 ABS and NEG input modifiers on both SRC0 and SRC1 (operating on bit 15 of each selected 16-bit half before packing, ABS before NEG). The emitter applied OP_SEL but ignored m.abs[0..2] and m.neg[0..2].

This applies bitwise ABS (& 0x7FFFu) and NEG (^ 0x8000u) to each selected half when set, leaving unmodified instructions unchanged.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: apply m.abs[0..2] and m.neg[0..2] in v_pack_b32_f16.
  • crates/xcl/src/gpu/recomp/tests.rs: add GPU test gpu_pack_b32_f16_abs_and_neg covering NEG, ABS, ABS + NEG, OP_SEL, and NaN payload preservation across wave32 and split wave64 (verified failing before the fix).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (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): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib gpu_pack_b32_f16_abs_and_neg: 1 passed, 0 failed across wave32 and split wave64 (failed on the GPU before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: a1b0edf41eb796d7ede59000f4786d26e6ac3eab
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14600 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited emit.rs, wrote the fix and GPU test, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:6582609909 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1207). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T13:14:30Z. --- `v_pack_b32_f16` supports VOP3 `ABS` and `NEG` input modifiers on both `SRC0` and `SRC1` (operating on bit 15 of each selected 16-bit half before packing, `ABS` before `NEG`). The emitter applied `OP_SEL` but ignored `m.abs[0..2]` and `m.neg[0..2]`. This applies bitwise `ABS` (`& 0x7FFFu`) and `NEG` (`^ 0x8000u`) to each selected half when set, leaving unmodified instructions unchanged. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: apply `m.abs[0..2]` and `m.neg[0..2]` in `v_pack_b32_f16`. - `crates/xcl/src/gpu/recomp/tests.rs`: add GPU test `gpu_pack_b32_f16_abs_and_neg` covering `NEG`, `ABS`, `ABS + NEG`, `OP_SEL`, and NaN payload preservation across wave32 and split wave64 (verified failing before the fix). **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`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`): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 `no wave64` — `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`) - `cargo test -p xcl --lib gpu_pack_b32_f16_abs_and_neg`: 1 passed, 0 failed across wave32 and split wave64 (failed on the GPU before the fix) **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1226 (PresentX 1226) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15341 MB ``` PR: ``` xcl-smoke v1 commit: a1b0edf41eb796d7ede59000f4786d26e6ac3eab gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1648 (PresentX 1648) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14600 MB ``` **Not tested** - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: audited `emit.rs`, wrote the fix and GPU test, ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
DavidM1911 commented 2026-11-24 14:06:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T13:16:21Z.


Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11.

  • cargo test -p xcl --lib pack_b32_f16: 1 passed, 0 failed — gpu_pack_b32_f16_abs_and_neg covers the ABS/NEG input modifiers on real hardware.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

<!-- greyfinch-sync:ivall/xcl:comment:7132592843 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1207#issuecomment-7132592843). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T13:16:21Z. --- Independent verification on current `main` `384f7f7` (branch already contains it — clean). **Machine:** Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11. - `cargo test -p xcl --lib pack_b32_f16`: **1 passed, 0 failed** — `gpu_pack_b32_f16_abs_and_neg` covers the ABS/NEG input modifiers on real hardware. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
bjarngard commented 2026-11-24 14:06:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bjarngard on 2026-11-24T13:47:56Z.


Test report for head a1b0edf (AMD, native wave64)

Tested

  • AMD Radeon(TM) Graphics (Ryzen 9 9950X iGPU, RDNA2, native wave64), driver 32.0.21043.5001; Windows 11 build 26300; Rust 1.99.1 MSVC; DXC 1.9.2602.17; debug
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored, no SKIPPED
  • With XCL_REQUIRE_GPU=wave64: gpu_pack_b32_f16_abs_and_neg passed

Not tested: retail titles, RDNA3/RDNA4.

AI use: the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.

<!-- greyfinch-sync:ivall/xcl:comment:7133352987 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1207#issuecomment-7133352987). Originally posted by [bjarngard](https://github.com/bjarngard) on 2026-11-24T13:47:56Z. --- Test report for head `a1b0edf` (AMD, native wave64) **Tested** - AMD Radeon(TM) Graphics (Ryzen 9 9950X iGPU, RDNA2, native wave64), driver 32.0.21043.5001; Windows 11 build 26300; Rust 1.99.1 MSVC; DXC 1.9.2602.17; debug - `XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4`: 742 passed, 0 failed, 41 ignored, no SKIPPED - With `XCL_REQUIRE_GPU=wave64`: `gpu_pack_b32_f16_abs_and_neg` passed **Not tested:** retail titles, RDNA3/RDNA4. **AI use:** the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.
JoaoPauluu commented 2026-11-24 14:06:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-24T13:57:16Z.


A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. a1b0edf as it is (based on 47efa2e), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).
  • gpu::recomp::tests::gpu_pack_b32_f16_abs_and_neg: ok, no SKIPPED.

Not tested

  • whether the new test fails without the fix on this stack; the rest of the suite on this head; native Windows; AMD / native wave64.

AI use

  • Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
<!-- greyfinch-sync:ivall/xcl:comment:7133592363 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1207#issuecomment-7133592363). Originally posted by [JoaoPauluu](https://github.com/JoaoPauluu) on 2026-11-24T13:57:16Z. --- A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler. **Tested** - RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for `x86_64-pc-windows-gnu`. `a1b0edf` as it is (based on `47efa2e`), no uncommitted changes. The lib test binary runs under Wine, one test per process (`--exact`). - `gpu::recomp::tests::gpu_pack_b32_f16_abs_and_neg`: **ok**, no SKIPPED. **Not tested** - whether the new test fails without the fix on this stack; the rest of the suite on this head; native Windows; AMD / native wave64. **AI use** - Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
upstream-sync closed this pull request 2026-11-25 00:07:15 +00:00
b3IKK commented 2026-11-25 00:09:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T23:45:54Z.


Closing as a duplicate of #1720, which is this account's later PR for the same change (#1607, group D49). #1720 now fixes the direct DXIL translator as well and tests both paths. AI use: OpenCode, Claude Fable 5.2.

<!-- greyfinch-sync:ivall/xcl:comment:7147768709 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1207#issuecomment-7147768709). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T23:45:54Z. --- Closing as a duplicate of #1720, which is this account's later PR for the same change (#1607, group D49). #1720 now fixes the direct DXIL translator as well and tests both paths. AI use: OpenCode, Claude Fable 5.2.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1198
No description provided.