Recompiler: preserve untouched half and honour OP_SEL[3] in v_sat_pk_u8_i16 #1138

Open
b3IKK wants to merge 1 commit from upstream-pr/1147 into main
b3IKK commented 2026-11-24 12:32:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T12:32:25Z.


v_sat_pk_u8_i16 writes a 16-bit packed result (2 x u8, VDST size: 16 in rdna2_spec.rs) into VDST[15:0] or VDST[31:16] depending on OP_SEL[3], preserving the untouched 16-bit half of VDST. The emitter overwrote all 32 bits of VDST (zeroing the upper half) and ignored OP_SEL[3].

This updates v_sat_pk_u8_i16 to match v_cvt_f16_f32's 16-bit destination placement: preserving the untouched half, honouring OP_SEL[3], and deferring to sdwa_dst for SDWA.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: preserve the untouched half and honour OP_SEL[3] in v_sat_pk_u8_i16.
  • crates/xcl/src/gpu/recomp/tests.rs: add GPU test gpu_sat_pk_u8_i16_preserves_other_half covering VOP1 low-half preservation, VOP3 OP_SEL[3]=1 high-half preservation, and signed saturation 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_sat_pk_u8_i16_preserves_other_half: 1 passed, 0 failed across wave32 and split wave64 (failed on the GPU before the fix, zeroing the upper half)

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: 551c6c804c1c80b0736d60706d00411c11cd6059
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1642 (PresentX 1642)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14581 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:5472211325 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1147). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T12:32:25Z. --- `v_sat_pk_u8_i16` writes a 16-bit packed result (`2 x u8`, `VDST` `size: 16` in `rdna2_spec.rs`) into `VDST[15:0]` or `VDST[31:16]` depending on `OP_SEL[3]`, preserving the untouched 16-bit half of `VDST`. The emitter overwrote all 32 bits of `VDST` (zeroing the upper half) and ignored `OP_SEL[3]`. This updates `v_sat_pk_u8_i16` to match `v_cvt_f16_f32`'s 16-bit destination placement: preserving the untouched half, honouring `OP_SEL[3]`, and deferring to `sdwa_dst` for SDWA. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: preserve the untouched half and honour `OP_SEL[3]` in `v_sat_pk_u8_i16`. - `crates/xcl/src/gpu/recomp/tests.rs`: add GPU test `gpu_sat_pk_u8_i16_preserves_other_half` covering VOP1 low-half preservation, VOP3 `OP_SEL[3]=1` high-half preservation, and signed saturation 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_sat_pk_u8_i16_preserves_other_half`: 1 passed, 0 failed across wave32 and split wave64 (failed on the GPU before the fix, zeroing the upper half) **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: 551c6c804c1c80b0736d60706d00411c11cd6059 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1642 (PresentX 1642) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14581 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 13:03:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T12:43:45Z.


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 sat_pk: 1 passed, 0 failed — gpu_sat_pk_u8_i16_preserves_other_half covers the untouched-half preservation and OP_SEL[3] on real hardware.

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

<!-- greyfinch-sync:ivall/xcl:comment:7131838353 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1147#issuecomment-7131838353). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T12:43:45Z. --- 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 sat_pk`: **1 passed, 0 failed** — `gpu_sat_pk_u8_i16_preserves_other_half` covers the untouched-half preservation and OP_SEL[3] on real hardware. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
bjarngard commented 2026-11-24 14:06:27 +00:00 (Migrated from github.com)

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


Test report for head 551c6c8 (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_sat_pk_u8_i16_preserves_other_half 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:7132328724 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1147#issuecomment-7132328724). Originally posted by [bjarngard](https://github.com/bjarngard) on 2026-11-24T13:05:12Z. --- Test report for head `551c6c8` (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_sat_pk_u8_i16_preserves_other_half` 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:47 +00:00 (Migrated from github.com)

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


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. 551c6c8 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_sat_pk_u8_i16_preserves_other_half: 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:7133586761 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1147#issuecomment-7133586761). Originally posted by [JoaoPauluu](https://github.com/JoaoPauluu) on 2026-11-24T13:57:03Z. --- 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`. `551c6c8` 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_sat_pk_u8_i16_preserves_other_half`: **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.
luckyteagirl commented 2026-11-25 05:08:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T04:26:58Z.


RX 6800M focused GPU report for PR #1147 at 551c6c804c1c80b0736d60706d00411c11cd6059

Setup: Windows 11 build 26200, AMD Radeon RX 6800M (driver 30.0.13002.13003), Ryzen 9 5980HX, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. Clean exact-head worktree; XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=1, XCL_DIRECT_DXIL=0.

Tested

  • cargo test --locked -p xcl --lib -j 2 gpu_sat_pk_u8_i16_preserves_other_half -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, no printed SKIPPED subcases. This covers low- and high-half placement plus untouched-half preservation for v_sat_pk_u8_i16 on the AMD GPU.
  • cargo build --locked --workspace -j 2: passed.

Not tested: Full workspace suite, paired retail-title smoke, other GPUs, or the Direct DXIL path. This verifies the focused HLSL regression on the PR head; it does not establish a green full suite or world-load behavior. No game data was used.

AI assistance: OpenAI Codex (GPT-6) ran the commands, extracted the test counts from the log, and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7152852216 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1147#issuecomment-7152852216). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-25T04:26:58Z. --- ### RX 6800M focused GPU report for PR #1147 at `551c6c804c1c80b0736d60706d00411c11cd6059` **Setup:** Windows 11 build 26200, AMD Radeon RX 6800M (driver `30.0.13002.13003`), Ryzen 9 5980HX, Rust `1.99.0` MSVC, DXC/DXIL `1.9.2609.5`. Clean exact-head worktree; `XCL_ADAPTER=6800M`, `XCL_REQUIRE_GPU=1`, `XCL_DIRECT_DXIL=0`. **Tested** - `cargo test --locked -p xcl --lib -j 2 gpu_sat_pk_u8_i16_preserves_other_half -- --test-threads=1 --show-output`: **1 passed, 0 failed, 0 ignored**, no printed `SKIPPED` subcases. This covers low- and high-half placement plus untouched-half preservation for `v_sat_pk_u8_i16` on the AMD GPU. - `cargo build --locked --workspace -j 2`: passed. **Not tested:** Full workspace suite, paired retail-title smoke, other GPUs, or the Direct DXIL path. This verifies the focused HLSL regression on the PR head; it does not establish a green full suite or world-load behavior. No game data was used. AI assistance: OpenAI Codex (GPT-6) ran the commands, extracted the test counts from the log, and drafted this report.
JJAutoCompare commented 2026-11-25 05:08:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:00:14Z.


Passed on native Windows at clean, detached commit 551c6c804c1c80b0736d60706d00411c11cd6059. The PR was open at that exact head before and after the run. PR #1147

Tested. STOR-WINLAB, Intel Arc A770 driver 32.0.101.9175, Ryzen 7 3800X, Windows 11 25H2 x64 build 26200.9974, Rust and Cargo 1.100.0 MSVC, DXC and DXIL 1.9.2609.5.

  • cargo test --locked -p xcl --lib --no-run built the debug fixture outside the Arc mutex with two jobs, incremental compilation and debuginfo disabled, and private TEMP/TMP. Cargo exited 0.
  • Ran & 'L:/XclTooling/pr2008-dc0d25fe/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe' gpu::recomp::tests::gpu_sat_pk_u8_i16_preserves_other_half --exact --nocapture --test-threads=1 under Invoke-ArcTest.ps1, with XCL_ADAPTER=A770 and HLSL/DXC. The wrapper ran in a fresh PowerShell process with process-scoped RemoteSigned.
  • 1 passed, 0 failed, 0 ignored, 0 skipped, with 719 filtered out in 2.03 s. The native executable and wrapper each exited 0. All 96 checks across 32 lanes passed: VOP1 preserved the upper half (0xDEAD0201), VOP3 with OP_SEL[3]=1 preserved the lower half (0xABCD5678), and signed inputs −5 and 300 saturated to 0 and 255 (0xCAFEFF00).

Not tested. Native or split wave64, SDWA, direct DXIL, other adapters or revisions, the full suite, and retail smoke. The checked-in fixture selected standalone wave32 on this adapter.

AI use. T3 Code / Codex (gpt-6.2-sol) ran the validation and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7153358536 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1147#issuecomment-7153358536). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T05:00:14Z. --- **Passed on native Windows** at clean, detached commit `551c6c804c1c80b0736d60706d00411c11cd6059`. The PR was open at that exact head before and after the run. [PR #1147](https://github.com/xcl-dev/xcl/pull/1147) **Tested.** STOR-WINLAB, Intel Arc A770 driver `32.0.101.9175`, Ryzen 7 3800X, Windows 11 25H2 x64 build `26200.9974`, Rust and Cargo `1.100.0` MSVC, DXC and DXIL `1.9.2609.5`. - `cargo test --locked -p xcl --lib --no-run` built the debug fixture outside the Arc mutex with two jobs, incremental compilation and debuginfo disabled, and private `TEMP`/`TMP`. Cargo exited `0`. - Ran `& 'L:/XclTooling/pr2008-dc0d25fe/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe' gpu::recomp::tests::gpu_sat_pk_u8_i16_preserves_other_half --exact --nocapture --test-threads=1` under `Invoke-ArcTest.ps1`, with `XCL_ADAPTER=A770` and HLSL/DXC. The wrapper ran in a fresh PowerShell process with process-scoped `RemoteSigned`. - **1 passed, 0 failed, 0 ignored, 0 skipped**, with 719 filtered out in 2.03 s. The native executable and wrapper each exited `0`. All 96 checks across 32 lanes passed: VOP1 preserved the upper half (`0xDEAD0201`), VOP3 with `OP_SEL[3]=1` preserved the lower half (`0xABCD5678`), and signed inputs `−5` and `300` saturated to `0` and `255` (`0xCAFEFF00`). **Not tested.** Native or split wave64, SDWA, direct DXIL, other adapters or revisions, the full suite, and retail smoke. The checked-in fixture selected standalone wave32 on this adapter. **AI use.** T3 Code / Codex (`gpt-6.2-sol`) ran the validation and wrote this report.
github-actions[bot] commented 2026-11-28 20:18:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:18:05Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7245185403 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1147#issuecomment-7245185403). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T20:18:05Z. --- 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.
Foniass commented 2026-12-01 04:55:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:55:56Z.


Triage (#1607) – head 551c6c8

Main deliberately lists v_sat_pk_u8_i16 in WIDE16 as an op with a 32-bit result. The ISA defines it as D.u = {16'b0, sat8(S0[31:16]), sat8(S0[15:0])}.
#1777 measured the VOP3 form on RDNA2 silicon (gfx1036). With OP_SEL = 0b1000 and the destination at 0xBEEF_1234 it writes 0x0000_0503: op_sel is ignored and the high half is zeroed.
This PR (emit.rs, v_sat_pk_u8_i16) keeps the old high half and writes the high half when OP_SEL[3] is set. gpu_sat_pk_u8_i16_preserves_other_half expects exactly that (0xDEAD_0201, 0xABCD_5678), so it checks the PR's own model rather than the hardware.
Recommendation: close (bad: contradicts the ISA and the silicon measurement in #1777).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301249034 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1147#issuecomment-7301249034). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:55:56Z. --- **Triage (#1607)** – head 551c6c8 Main deliberately lists `v_sat_pk_u8_i16` in `WIDE16` as an op with a 32-bit result. The ISA defines it as `D.u = {16'b0, sat8(S0[31:16]), sat8(S0[15:0])}`. #1777 measured the VOP3 form on RDNA2 silicon (gfx1036). With OP_SEL = 0b1000 and the destination at 0xBEEF_1234 it writes 0x0000_0503: op_sel is ignored and the high half is zeroed. This PR (`emit.rs`, `v_sat_pk_u8_i16`) keeps the old high half and writes the high half when OP_SEL[3] is set. `gpu_sat_pk_u8_i16_preserves_other_half` expects exactly that (0xDEAD_0201, 0xABCD_5678), so it checks the PR's own model rather than the hardware. Recommendation: close (bad: contradicts the ISA and the silicon measurement in #1777). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1147:upstream-pr/1147'
git switch 'upstream-pr/1147'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1147'
git switch 'upstream-pr/1147'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1147'
git switch 'upstream-pr/1147'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1147'
git switch 'main'
git merge --squash 'upstream-pr/1147'
git switch 'main'
git merge --ff-only 'upstream-pr/1147'
git switch 'main'
git merge 'upstream-pr/1147'
git push origin 'main'
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!1138
No description provided.