Direct DXIL: saturate v_pk_*_i16 CLAMP with masked select (NVIDIA) #2855

Merged
Decodere merged 1 commit from upstream-pr/2855 into main 2026-11-29 12:20:17 +00:00
Decodere commented 2026-11-26 19:02:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T19:02:10Z.


Direct DXIL lowering for packed signed 16-bit add/sub/mad with CLAMP=1 (v_pk_add_i16, v_pk_sub_i16, v_pk_mad_i16 in Lw::valu_pk, crates/xcl/src/gpu/dxil/lower_wide.rs) previously saturated each half via IMax(IMin(t, 0x7FFF), -32768) & 0xFFFF before OR-ing the low and high halves into the destination register. On NVIDIA Ampere drivers (RTX 3070 driver 616.56 and RTX 3060 driver 610.88), the driver drops the trailing & 0xFFFF mask for negative clamped low halves, leaving sign-extended 0xFFFF_xxxx to overwrite bits [31:16] of the packed destination (for example, [-1, 1] - [1, 1] returned 0xFFFF_FFFE instead of 0x0000_FFFE).

This is the packed-operation sibling to #2398 (which touches non-packed valu16 ops on disjoint lines and merges cleanly alongside this PR). Auditing all other imin/imax/& 0xFFFF sites across crates/xcl/src/gpu/dxil/ confirmed Lw::valu_pk was the only remaining IMax(IMin(t, 0x7FFF), -32768) & 0xFFFF site; v_cvt_i16_f16 (lower_wide.rs) and v_cvt_pk_i16_i32 (lower_valu.rs) use IMin(IMax(...)) and pass as controls on Ampere.

What is in it

  • Replace IMax(IMin(t, 0x7FFF), -32768) & 0xFFFF in "v_pk_add_i16" | "v_pk_sub_i16" | "v_pk_mad_i16" if clamp (crates/xcl/src/gpu/dxil/lower_wide.rs) with signed 32-bit comparisons (Pred::SGt against 0x7FFF, Pred::SLt against 0xFFFF_8000), t & 0xFFFF, and a select chain yielding 16-bit patterns (0x7FFF, 0x8000, or low), matching the masked-select form used in #2398.
  • Add i16_clamp_mask_tests::v_pk_i16_clamp_uses_masked_select_without_imin_imax: validates and disassembles Direct DXIL for V_PK_ADD_I16, V_PK_SUB_I16, and V_PK_MAD_I16 with CLAMP=1, asserting icmp sgt i32 / icmp slt i32 / select i1 and no IMax, IMin, or Int64Ops.
  • Add i16_clamp_mask_tests::gpu_i16_clamp_negative_low_half_keeps_high_half: runs V_PK_ADD_I16, V_PK_SUB_I16, and V_PK_MAD_I16 with CLAMP=1 (distinct source registers across saturation edges, negative in-range low halves, and 32-bit intermediate cancellation) alongside V_CVT_PK_I16_I32 and V_CVT_I16_F16 controls on the GPU.
  • Attribution: based on @upipibi's root-cause analysis and fix (upipibi/xcl@6fe2b3e7, RTX 3070 616.56 reproduction) and @Smokeyqdqd's independent RTX 3060 610.88 reproduction.

Tested

  • Hardware & toolchain: Windows 11 Home (build 26200), Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (Ada, 32-lane waves, driver 621.14), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5.
  • Baseline (e120925e clamp with i16_clamp_mask_tests added):
    • cargo test -p xcl --lib -- v_pk_i16_clamp_uses_masked_select_without_imin_imax --nocapture --test-threads=1: 0 passed, 1 failed (caught IMax emission on unmodified e120925e).
    • cargo test -p xcl --lib -- gpu_i16_clamp_negative_low_half_keeps_high_half --nocapture --test-threads=1 (3x Debug RTX 4060) and --release (3x Release RTX 4060): 1 passed, 0 failed in all 6 runs (0 skipped). RTX 4060 Ada driver 621.14 keeps the & 0xFFFF mask on IMax(IMin(...)), consistent with #2398 where Ada passed while Ampere drivers failed 3/3 (RTX 3070 616.56 and RTX 3060 610.88, 33 mismatched lanes).
  • Fixed (651fc050):
    • cargo clippy --all-targets -- -A clippy::approx_constant: exit 0, 0 new warnings in crates/xcl/src/gpu/dxil/lower_wide.rs.
    • Debug WARP (XCL_WARP=1): cargo test -p xcl --lib -- i16_clamp_mask_tests --nocapture --test-threads=1: 2 passed, 0 failed, 0 ignored in 3/3 runs (0 skipped); cargo test -p xcl --lib -- gpu::dxil:: --test-threads=4: 186 passed, 0 failed, 3 ignored (1 SKIPPED: dispatch_chain_native_wave64_builds_whole: no wave64).
    • Release RTX 4060: cargo test --release -p xcl --lib -- i16_clamp_mask_tests --nocapture --test-threads=1: 2 passed, 0 failed, 0 ignored in 3/3 runs (0 skipped); cargo test --release -p xcl --lib -- gpu::dxil:: --test-threads=4: 186 passed, 0 failed, 3 ignored (1 SKIPPED: dispatch_chain_native_wave64_builds_whole: no wave64).
    • cargo build --release --workspace && cargo test --release --workspace --no-fail-fast -- --test-threads=4: 1444 passed, 0 failed, 47 ignored across 38 top-level test targets (29 SKIPPED notices: 21 wave64, 3 per-lane refusals, 3 D3D12 debug layer, 1 heap-window fallback, 1 Windows driver-cache toggle).
    • Mergeability: clean git merge-tree --write-tree (exit 0) against both main (8b957bec) and #2398 (e9d7aefc).

Regression run
Paired quiet 60 s release runs (scripts/smoke.ps1 -Seconds 60, XCL_NETWORK=0, RTX 4060 8 GB, driver 621.14) on exact parent e120925e and PR head 651fc050:

Exact parent on main (e120925e, ancestor of 8b957bec):

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1629 (PresentX 1629)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14025 MB

PR (651fc050):

xcl-smoke v1
commit: 651fc0502da4efd6bbcefa9faa9aed3dafb22d40
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1590 (PresentX 1590)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14015 MB

Not tested

  • NVIDIA Ampere hardware locally (the V_PK_ADD_I16 / V_PK_SUB_I16 failure and masked-select fix were independently verified 3/3 on RTX 3070 616.56 by @upipibi and RTX 3060 610.88 by @Smokeyqdqd; V_PK_MAD_I16 shares the same clamp block and was verified here on WARP and RTX 4060 Ada).
  • AMD and Intel GPUs, native wave64 GPU tests, and D3D12 debug-layer tests (d3d12SDKLayers.dll not installed).

AI use

  • Google Antigravity (Gemini 4 Neon) audited signed-16-bit clamp sites in crates/xcl/src/gpu/dxil/, applied the masked-select fix and i16_clamp_mask_tests (extending @upipibi's 6fe2b3e7 test with V_PK_MAD_I16 and an IR contract test), ran all local builds/tests/smokes, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5515687366 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2855). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-26T19:02:10Z. --- Direct DXIL lowering for packed signed 16-bit add/sub/mad with `CLAMP=1` (`v_pk_add_i16`, `v_pk_sub_i16`, `v_pk_mad_i16` in `Lw::valu_pk`, `crates/xcl/src/gpu/dxil/lower_wide.rs`) previously saturated each half via `IMax(IMin(t, 0x7FFF), -32768) & 0xFFFF` before OR-ing the low and high halves into the destination register. On NVIDIA Ampere drivers (RTX 3070 driver 616.56 and RTX 3060 driver 610.88), the driver drops the trailing `& 0xFFFF` mask for negative clamped low halves, leaving sign-extended `0xFFFF_xxxx` to overwrite bits `[31:16]` of the packed destination (for example, `[-1, 1] - [1, 1]` returned `0xFFFF_FFFE` instead of `0x0000_FFFE`). This is the packed-operation sibling to #2398 (which touches non-packed `valu16` ops on disjoint lines and merges cleanly alongside this PR). Auditing all other `imin`/`imax`/`& 0xFFFF` sites across `crates/xcl/src/gpu/dxil/` confirmed `Lw::valu_pk` was the only remaining `IMax(IMin(t, 0x7FFF), -32768) & 0xFFFF` site; `v_cvt_i16_f16` (`lower_wide.rs`) and `v_cvt_pk_i16_i32` (`lower_valu.rs`) use `IMin(IMax(...))` and pass as controls on Ampere. **What is in it** - Replace `IMax(IMin(t, 0x7FFF), -32768) & 0xFFFF` in `"v_pk_add_i16" | "v_pk_sub_i16" | "v_pk_mad_i16" if clamp` (`crates/xcl/src/gpu/dxil/lower_wide.rs`) with signed 32-bit comparisons (`Pred::SGt` against `0x7FFF`, `Pred::SLt` against `0xFFFF_8000`), `t & 0xFFFF`, and a `select` chain yielding 16-bit patterns (`0x7FFF`, `0x8000`, or `low`), matching the masked-select form used in #2398. - Add `i16_clamp_mask_tests::v_pk_i16_clamp_uses_masked_select_without_imin_imax`: validates and disassembles Direct DXIL for `V_PK_ADD_I16`, `V_PK_SUB_I16`, and `V_PK_MAD_I16` with `CLAMP=1`, asserting `icmp sgt i32` / `icmp slt i32` / `select i1` and no `IMax`, `IMin`, or `Int64Ops`. - Add `i16_clamp_mask_tests::gpu_i16_clamp_negative_low_half_keeps_high_half`: runs `V_PK_ADD_I16`, `V_PK_SUB_I16`, and `V_PK_MAD_I16` with `CLAMP=1` (distinct source registers across saturation edges, negative in-range low halves, and 32-bit intermediate cancellation) alongside `V_CVT_PK_I16_I32` and `V_CVT_I16_F16` controls on the GPU. - Attribution: based on `@upipibi`'s root-cause analysis and fix (`upipibi/xcl@6fe2b3e7`, RTX 3070 616.56 reproduction) and `@Smokeyqdqd`'s independent RTX 3060 610.88 reproduction. **Tested** - Hardware & toolchain: Windows 11 Home (build 26200), Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (Ada, 32-lane waves, driver 621.14), Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5. - Baseline (`e120925e` clamp with `i16_clamp_mask_tests` added): - `cargo test -p xcl --lib -- v_pk_i16_clamp_uses_masked_select_without_imin_imax --nocapture --test-threads=1`: **0 passed, 1 failed** (caught `IMax` emission on unmodified `e120925e`). - `cargo test -p xcl --lib -- gpu_i16_clamp_negative_low_half_keeps_high_half --nocapture --test-threads=1` (3x Debug RTX 4060) and `--release` (3x Release RTX 4060): **1 passed, 0 failed** in all 6 runs (0 skipped). RTX 4060 Ada driver 621.14 keeps the `& 0xFFFF` mask on `IMax(IMin(...))`, consistent with #2398 where Ada passed while Ampere drivers failed 3/3 (RTX 3070 616.56 and RTX 3060 610.88, 33 mismatched lanes). - Fixed (`651fc050`): - `cargo clippy --all-targets -- -A clippy::approx_constant`: exit 0, 0 new warnings in `crates/xcl/src/gpu/dxil/lower_wide.rs`. - Debug WARP (`XCL_WARP=1`): `cargo test -p xcl --lib -- i16_clamp_mask_tests --nocapture --test-threads=1`: **2 passed, 0 failed, 0 ignored** in 3/3 runs (0 skipped); `cargo test -p xcl --lib -- gpu::dxil:: --test-threads=4`: **186 passed, 0 failed, 3 ignored** (1 `SKIPPED`: `dispatch_chain_native_wave64_builds_whole: no wave64`). - Release RTX 4060: `cargo test --release -p xcl --lib -- i16_clamp_mask_tests --nocapture --test-threads=1`: **2 passed, 0 failed, 0 ignored** in 3/3 runs (0 skipped); `cargo test --release -p xcl --lib -- gpu::dxil:: --test-threads=4`: **186 passed, 0 failed, 3 ignored** (1 `SKIPPED`: `dispatch_chain_native_wave64_builds_whole: no wave64`). - `cargo build --release --workspace && cargo test --release --workspace --no-fail-fast -- --test-threads=4`: **1444 passed, 0 failed, 47 ignored** across 38 top-level test targets (29 `SKIPPED` notices: 21 wave64, 3 per-lane refusals, 3 D3D12 debug layer, 1 heap-window fallback, 1 Windows driver-cache toggle). - Mergeability: clean `git merge-tree --write-tree` (exit 0) against both `main` (`8b957bec`) and #2398 (`e9d7aefc`). **Regression run** Paired quiet 60 s release runs (`scripts/smoke.ps1 -Seconds 60`, `XCL_NETWORK=0`, RTX 4060 8 GB, driver 621.14) on exact parent `e120925e` and PR head `651fc050`: Exact parent on `main` (`e120925e`, ancestor of `8b957bec`): ``` xcl-smoke v1 commit: e120925e3abc9956a8b9bae631969d32e8ccd43c gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1629 (PresentX 1629) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14025 MB ``` PR (`651fc050`): ``` xcl-smoke v1 commit: 651fc0502da4efd6bbcefa9faa9aed3dafb22d40 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1590 (PresentX 1590) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14015 MB ``` **Not tested** - NVIDIA Ampere hardware locally (the `V_PK_ADD_I16` / `V_PK_SUB_I16` failure and masked-select fix were independently verified 3/3 on RTX 3070 616.56 by `@upipibi` and RTX 3060 610.88 by `@Smokeyqdqd`; `V_PK_MAD_I16` shares the same clamp block and was verified here on WARP and RTX 4060 Ada). - AMD and Intel GPUs, native wave64 GPU tests, and D3D12 debug-layer tests (`d3d12SDKLayers.dll` not installed). **AI use** - Google Antigravity (Gemini 4 Neon) audited signed-16-bit clamp sites in `crates/xcl/src/gpu/dxil/`, applied the masked-select fix and `i16_clamp_mask_tests` (extending `@upipibi`'s `6fe2b3e7` test with `V_PK_MAD_I16` and an IR contract test), ran all local builds/tests/smokes, and drafted this PR description.
DarkPanda69 commented 2026-11-26 19:17:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T19:17:42Z.


AMD run (listed as untested), plus one more Ampere card: no change from main on either, and both new tests pass.

Tested: pass, head 651fc05 applied on main 8b957be, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17, card picked with XCL_ADAPTER.
XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4 --nocapture, main and this PR one after the other on each card:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010: main 708 passed, 2 failed, 6 SKIPPED; this PR 710 passed, 2 failed, 6 SKIPPED. The 2 failures are fuzz_validate_and_gpu_1 and _3, the AMD fuzz seeds in #2115, the same on main.
  • NVIDIA RTX 3060 (Ampere), driver 32.0.16.1088: main 710 passed, 0 failed, 24 SKIPPED; this PR 712 passed, 0 failed, 24 SKIPPED.

On both cards the only result changes are gpu_i16_clamp_negative_low_half_keeps_high_half and v_pk_i16_clamp_uses_masked_select_without_imin_imax, both ok. The SKIPPED sets are the same as on main.

The new GPU test uses KernelOptions { wave64: false, .. }, so it runs as wave32 on the RX 9070 XT too; this does not cover the clamp in native wave64.

Not tested: the clamp in a 64-lane wave, D3D12 debug-layer tests (no d3d12SDKLayers.dll here either), release, Intel.

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

<!-- greyfinch-sync:ivall/xcl:comment:7201420090 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2855#issuecomment-7201420090). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-26T19:17:42Z. --- AMD run (listed as untested), plus one more Ampere card: no change from `main` on either, and both new tests pass. **Tested:** pass, head `651fc05` applied on `main` `8b957be`, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17, card picked with `XCL_ADAPTER`. `XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4 --nocapture`, `main` and this PR one after the other on each card: - AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010: `main` 708 passed, 2 failed, 6 SKIPPED; this PR 710 passed, 2 failed, 6 SKIPPED. The 2 failures are `fuzz_validate_and_gpu_1` and `_3`, the AMD fuzz seeds in #2115, the same on `main`. - NVIDIA RTX 3060 (Ampere), driver 32.0.16.1088: `main` 710 passed, 0 failed, 24 SKIPPED; this PR 712 passed, 0 failed, 24 SKIPPED. On both cards the only result changes are `gpu_i16_clamp_negative_low_half_keeps_high_half` and `v_pk_i16_clamp_uses_masked_select_without_imin_imax`, both ok. The SKIPPED sets are the same as on `main`. The new GPU test uses `KernelOptions { wave64: false, .. }`, so it runs as wave32 on the RX 9070 XT too; this does not cover the clamp in native wave64. **Not tested:** the clamp in a 64-lane wave, D3D12 debug-layer tests (no `d3d12SDKLayers.dll` here either), release, Intel. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
andrewDoing commented 2026-11-26 20:25:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-26T20:25:57Z.


Independent RTX 5070 check: NVIDIA driver 616.92; Ryzen 7 5700X3D; Windows build 26300.10075; Rust 1.100.0 MSVC, debug; SDK DXC/DXIL 1.8.2502.11.

Ran cargo test --locked -p xcl --lib i16_clamp_mask_tests -- --test-threads=1 --nocapture with XCL_ADAPTER=5070, XCL_DIRECT_DXIL=1, and separate writable caches:

  • Parent e120925e3abc9956a8b9bae631969d32e8ccd43c with only the PR's test module added: GPU packed arithmetic passed; disassembly assertion failed because IMax was present.
  • Clean PR head 651fc0502da4efd6bbcefa9faa9aed3dafb22d40: both tests passed, 0 failed, 0 ignored, no reported skips.

The arithmetic fixture did not reproduce the reported Ampere wrong-result signature on this Blackwell card and driver, including on the parent. This is not a performance or retail-title test; the full suite was not run on this PR.

AI use: OpenAI Codex with GPT-6.2 Astra ran the tests and reported results; Codex coordinated and prepared this summary.

<!-- greyfinch-sync:ivall/xcl:comment:7202673045 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2855#issuecomment-7202673045). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-26T20:25:57Z. --- Independent RTX 5070 check: NVIDIA driver 616.92; Ryzen 7 5700X3D; Windows build 26300.10075; Rust 1.100.0 MSVC, debug; SDK DXC/DXIL 1.8.2502.11. Ran `cargo test --locked -p xcl --lib i16_clamp_mask_tests -- --test-threads=1 --nocapture` with `XCL_ADAPTER=5070`, `XCL_DIRECT_DXIL=1`, and separate writable caches: - Parent `e120925e3abc9956a8b9bae631969d32e8ccd43c` with only the PR's test module added: GPU packed arithmetic passed; disassembly assertion failed because `IMax` was present. - Clean PR head `651fc0502da4efd6bbcefa9faa9aed3dafb22d40`: both tests passed, 0 failed, 0 ignored, no reported skips. The arithmetic fixture did not reproduce the reported Ampere wrong-result signature on this Blackwell card and driver, including on the parent. This is not a performance or retail-title test; the full suite was not run on this PR. AI use: OpenAI Codex with GPT-6.2 Astra ran the tests and reported results; Codex coordinated and prepared this summary.
SlopTart commented 2026-11-26 21:40:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-26T21:40:55Z.


Linux (Wine) dual-lane run at head 651fc050 - no regressions on either vendor, with one counting note.

  • Rig (Ryzen 9 9900X / RX 7900 XT / Mesa 26.2.5 RADV / wine-11.0 Proton): 602/3. Counting note: your head sits on an older main (e120925e, 5 commits behind current 8b957bec), so the three present::preparation tests that landed with #2555 are absent from this tree - that is why the totals shift, not the CLAMP change itself. Reds = baseline two + the sparse::a_tile_decommitted_and_committed_again_keeps_its_video_memory load flake we documented separately today (solo 3/3 green; second suite-load appearance).
  • Boxb (i5-10600K / GTX 1070 550.163.01 / wine-10.0 + vkd3d-proton, xvfb): 602/3 = exactly the baseline three (gpu_promoted_uav_clear_values, write_buffer_immediate_on_open_existing_heap_visible_to_cpu, xma2_source_voice). No new NVIDIA reds, and none of the standing ones moved.

The masked-select saturation is exercised mainly in paths our Wine lane runs headless without real draw compare (--skip gpu::), so treat this as "does not break the suite on AMD or NVIDIA Wine" rather than a functional validation of the clamp fix itself.

Suite: cargo test --release --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 --skip gpu::.

AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7203959368 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2855#issuecomment-7203959368). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-26T21:40:55Z. --- **Linux (Wine) dual-lane run at head `651fc050`** - no regressions on either vendor, with one counting note. - Rig (Ryzen 9 9900X / RX 7900 XT / Mesa 26.2.5 RADV / wine-11.0 Proton): 602/3. Counting note: your head sits on an older main (`e120925e`, 5 commits behind current `8b957bec`), so the three `present::preparation` tests that landed with #2555 are absent from this tree - that is why the totals shift, not the CLAMP change itself. Reds = baseline two + the `sparse::a_tile_decommitted_and_committed_again_keeps_its_video_memory` load flake we documented separately today (solo 3/3 green; second suite-load appearance). - Boxb (i5-10600K / GTX 1070 550.163.01 / wine-10.0 + vkd3d-proton, xvfb): 602/3 = exactly the baseline three (`gpu_promoted_uav_clear_values`, `write_buffer_immediate_on_open_existing_heap_visible_to_cpu`, `xma2_source_voice`). No new NVIDIA reds, and none of the standing ones moved. The masked-select saturation is exercised mainly in paths our Wine lane runs headless without real draw compare (`--skip gpu::`), so treat this as "does not break the suite on AMD or NVIDIA Wine" rather than a functional validation of the clamp fix itself. Suite: `cargo test --release --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 --skip gpu::`. AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
SzczepanGrela commented 2026-11-27 02:19:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-27T02:19:39Z.


RX 9070 / RADV / Wine follow-up, including native wave64 and explicit plain/compact direct lowering. All captured GPU outputs match an independent CPU oracle on main, this head, and the head's automatic integration onto main. This is AMD non-regression coverage; the NVIDIA wrong-result case does not reproduce here.

Tested

  • Exact head 651fc0502da4efd6bbcefa9faa9aed3dafb22d40, current main 8b957bec6f82495aec940944c6bf47faa02db590, and a separate copy with the PR integrated onto that main. The head's parent is e120925e3abc9956a8b9bae631969d32e8ccd43c. Main's production lower_wide.rs is byte-identical to that parent; the integrated file matches the head. Local edits are test-only observations and the extra fixture described below.
  • RX 9070 16 GB, RADV GFX1201, Mesa 26.3.1-arch3.5; Ryzen 7 7700, CachyOS 7.3.0-5-cachyos. Windows GNU release executables under GE-Proton11-12 / Wine 11.0 Staging, native D3D12 through vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build). DXC/DXIL 1.9.2602.17, Rust 1.97.1.
  • Build each source copy: cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics.
  • Run each executable through Wine with i16_clamp_mask_tests --nocapture --test-threads=1, then --test-threads=4. Identical original assertions on all three copies; main receives the head's test module. Results for each thread count: main 1 passed, 1 failed; exact head 2 passed, 0 failed; integrated head 2 passed, 0 failed. The main failure is the expected IR-contract assertion about IMax. The original 32-lane GPU test passes in all six runs, including the negative-low-half case. Saved IR confirms IMin/IMax in main and signed compares/select without either intrinsic in the head's original IR fixture.
  • Extra owned workflow_packed_i16_matrix --nocapture --test-threads=1: three fresh process repetitions per source, 1 passed, 0 failed in every run. Each process executes 96 cases: 16 input batches, native wave32/wave64, HLSL, direct plain and explicitly selected direct compact. Compact selection is confirmed in translator logs; native WaveSize/NumThreads metadata is checked in saved DXIL.
  • The 208-byte straight-line program writes 24 packed results: ADD/SUB/MAD, CLAMP off/on, four source-half selector combinations. Two unchanged conversion controls follow: V_CVT_PK_I16_I32 and V_CVT_I16_F16. Per backend/process, native wave64 checks 1,024 input vectors and wave32 checks 512. Inputs cover signed-i16 edges, saturation, wrapping, MAD cancellation and deterministic random values. No NEG modifiers.
  • Across all 15 processes: 870 GPU dispatches, including 432 native wave64, and 1,079,232 readback u32 values, all independently recomputed from captured inputs. The Python verifier also reconstructs the extra dataset and RDNA2 instruction bytes. Captures are byte-identical across repetitions, and exact-head/integrated-head captures match. HLSL control containers match across sources. 0 ignored, 0 skipped throughout.

Runtime: inherited XCL_* variables cleared; XCL_NETWORK=0, XCL_ADAPTER=AMD Radeon RX 9070, XCL_REQUIRE_GPU=wave64, XCL_DXC_THREADS=1, XCL_DIRECT_COMPACT=0 for the original tests. The extra direct routes select plain/compact explicitly. Each process uses separate enabled XCL/vkd3d/Mesa cache directories.

Not tested

NVIDIA, native Windows, forced split wave64, other modifiers/control-flow shapes, full suite, retail workloads, scripts/smoke.ps1, performance or FPS. These synthetic results do not establish a retail regression run or reproduce the reported NVIDIA driver behavior.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) prepared the local test-only fixture, ran the tests, independently checked the raw results and drafted this report. Publication authorized by the account owner.

<!-- greyfinch-sync:ivall/xcl:comment:7208025710 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2855#issuecomment-7208025710). Originally posted by [SzczepanGrela](https://github.com/SzczepanGrela) on 2026-11-27T02:19:39Z. --- RX 9070 / RADV / Wine follow-up, including native wave64 and explicit plain/compact direct lowering. All captured GPU outputs match an independent CPU oracle on main, this head, and the head's automatic integration onto main. This is AMD non-regression coverage; the NVIDIA wrong-result case does not reproduce here. **Tested** - Exact head `651fc0502da4efd6bbcefa9faa9aed3dafb22d40`, current main `8b957bec6f82495aec940944c6bf47faa02db590`, and a separate copy with the PR integrated onto that main. The head's parent is `e120925e3abc9956a8b9bae631969d32e8ccd43c`. Main's production `lower_wide.rs` is byte-identical to that parent; the integrated file matches the head. Local edits are test-only observations and the extra fixture described below. - RX 9070 16 GB, RADV GFX1201, Mesa `26.3.1-arch3.5`; Ryzen 7 7700, CachyOS `7.3.0-5-cachyos`. Windows GNU release executables under GE-Proton11-12 / Wine 11.0 Staging, native D3D12 through vkd3d-proton `8293130ebe370b1+` (local asserts-disabled build). DXC/DXIL `1.9.2602.17`, Rust `1.97.1`. - Build each source copy: `cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics`. - Run each executable through Wine with `i16_clamp_mask_tests --nocapture --test-threads=1`, then `--test-threads=4`. Identical original assertions on all three copies; main receives the head's test module. Results for each thread count: main **1 passed, 1 failed**; exact head **2 passed, 0 failed**; integrated head **2 passed, 0 failed**. The main failure is the expected IR-contract assertion about IMax. The original 32-lane GPU test passes in all six runs, including the negative-low-half case. Saved IR confirms IMin/IMax in main and signed compares/select without either intrinsic in the head's original IR fixture. - Extra owned `workflow_packed_i16_matrix --nocapture --test-threads=1`: three fresh process repetitions per source, **1 passed, 0 failed** in every run. Each process executes 96 cases: 16 input batches, native wave32/wave64, HLSL, direct plain and explicitly selected direct compact. Compact selection is confirmed in translator logs; native WaveSize/NumThreads metadata is checked in saved DXIL. - The 208-byte straight-line program writes 24 packed results: ADD/SUB/MAD, CLAMP off/on, four source-half selector combinations. Two unchanged conversion controls follow: `V_CVT_PK_I16_I32` and `V_CVT_I16_F16`. Per backend/process, native wave64 checks 1,024 input vectors and wave32 checks 512. Inputs cover signed-i16 edges, saturation, wrapping, MAD cancellation and deterministic random values. No NEG modifiers. - Across all 15 processes: **870 GPU dispatches**, including **432 native wave64**, and **1,079,232 readback u32 values**, all independently recomputed from captured inputs. The Python verifier also reconstructs the extra dataset and RDNA2 instruction bytes. Captures are byte-identical across repetitions, and exact-head/integrated-head captures match. HLSL control containers match across sources. **0 ignored, 0 skipped** throughout. Runtime: inherited `XCL_*` variables cleared; `XCL_NETWORK=0`, `XCL_ADAPTER=AMD Radeon RX 9070`, `XCL_REQUIRE_GPU=wave64`, `XCL_DXC_THREADS=1`, `XCL_DIRECT_COMPACT=0` for the original tests. The extra direct routes select plain/compact explicitly. Each process uses separate enabled XCL/vkd3d/Mesa cache directories. **Not tested** NVIDIA, native Windows, forced split wave64, other modifiers/control-flow shapes, full suite, retail workloads, `scripts/smoke.ps1`, performance or FPS. These synthetic results do not establish a retail regression run or reproduce the reported NVIDIA driver behavior. **AI use** OpenAI Codex (GPT-6; exact serving variant not exposed) prepared the local test-only fixture, ran the tests, independently checked the raw results and drafted this report. Publication authorized by the account owner.
thehollowedone commented 2026-11-28 10:03:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T10:03:03Z.


merge-check
base: e429936c10
head: 651fc0502d
merge: clean
build: cargo build --offline --locked -j 4 --workspace -> ok
tests: cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4 -> 2,127 passed, 10 failed, 48 ignored; 25 GPU skip notices. The same ten failed on untouched main at this base: dispatch_chain_oversized_loop_matches_whole, dispatch_chain_wave32_live_loops, dispatch_chain_wave64_live_loops_and_exchange, gpu_heap_flat_reads_match_guarded_and_root_output, console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, gpu_compute_mode_dispatch_abi, gpu_float_cas_uses_ieee_equality, and the three test_title_* e2e cases. The two new i16_clamp_mask_tests passed separately on the RTX 3080 Ti (2 passed, 0 failed, 0 ignored, 0 skipped) with cargo test --offline --locked -j 4 -p xcl --lib i16_clamp_mask_tests -- --test-threads=1 --nocapture.
review: no blocker found in the full diff. For each signed packed half, the comparisons select 0x8000, 0x7FFF, or the masked in-range value before the two halves are combined. This preserves the high half when the low result is negative. Open #2398 changes a separate non-packed lowering path.
performance: reasoned only. The affected operations add two DXIL operations per half before driver optimization. There is no new allocation or memory access. I did not measure shader throughput or frame time on this machine; the PR's existing smoke pair supplies title-level evidence.
verdict: safe to merge relative to the checked main base; the workspace suite remains red for the same 10 base failures.
hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, DXC 1.8.2502.11; Codex (GPT-6.2 Sol) ran the tests and reviewed the diff. Codex (GPT-6.2 Astra) independently checked the packed arithmetic.

<!-- greyfinch-sync:ivall/xcl:comment:7237636368 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2855#issuecomment-7237636368). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-28T10:03:03Z. --- merge-check base: e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd head: 651fc0502da4efd6bbcefa9faa9aed3dafb22d40 merge: clean build: `cargo build --offline --locked -j 4 --workspace` -> ok tests: `cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4` -> 2,127 passed, 10 failed, 48 ignored; 25 GPU skip notices. The same ten failed on untouched main at this base: `dispatch_chain_oversized_loop_matches_whole`, `dispatch_chain_wave32_live_loops`, `dispatch_chain_wave64_live_loops_and_exchange`, `gpu_heap_flat_reads_match_guarded_and_root_output`, `console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk`, `gpu_compute_mode_dispatch_abi`, `gpu_float_cas_uses_ieee_equality`, and the three `test_title_*` e2e cases. The two new `i16_clamp_mask_tests` passed separately on the RTX 3080 Ti (2 passed, 0 failed, 0 ignored, 0 skipped) with `cargo test --offline --locked -j 4 -p xcl --lib i16_clamp_mask_tests -- --test-threads=1 --nocapture`. review: no blocker found in the full diff. For each signed packed half, the comparisons select `0x8000`, `0x7FFF`, or the masked in-range value before the two halves are combined. This preserves the high half when the low result is negative. Open [#2398](https://github.com/xcl-dev/xcl/pull/2398) changes a separate non-packed lowering path. performance: reasoned only. The affected operations add two DXIL operations per half before driver optimization. There is no new allocation or memory access. I did not measure shader throughput or frame time on this machine; the PR's existing smoke pair supplies title-level evidence. verdict: safe to merge relative to the checked main base; the workspace suite remains red for the same 10 base failures. hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, DXC 1.8.2502.11; Codex (GPT-6.2 Sol) ran the tests and reviewed the diff. Codex (GPT-6.2 Astra) independently checked the packed arithmetic.
throny commented 2026-11-28 13:04:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T13:04:26Z.


merge-check claim
head: 651fc0502d

<!-- greyfinch-sync:ivall/xcl:comment:7239670222 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2855#issuecomment-7239670222). Originally posted by [throny](https://github.com/throny) on 2026-11-28T13:04:26Z. --- merge-check claim head: 651fc0502da4efd6bbcefa9faa9aed3dafb22d40
throny commented 2026-11-28 13:22:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T13:22:33Z.


merge-check
base: e429936c
head: 651fc0502d
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2128 passed, 9 failed, 48 ignored: the base's 9 only (26 SKIPPED lines). The 9 failures are main's own at e429936c on this GPU (#3093); base alone: 2126 passed, 9 failed, 48 ignored.
review: none. The intermediate is the exact 32-bit result (halves sign-extended; the multiply-add stays inside 32 bits), and the new form saturates correctly in both directions, each half through the same code. Not changed and not checked here: the HLSL path's clamp. Note from the thread: an RTX 50 run did not reproduce the wrong result the PR is for; the Ampere driver behaviour rests on the PR's own description, and this RTX 40 card passes with and without it.
performance: direct DXIL only; one extra compare and select per half; a one-time re-translation there.
verdict: safe to merge
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).

<!-- greyfinch-sync:ivall/xcl:comment:7239890762 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2855#issuecomment-7239890762). Originally posted by [throny](https://github.com/throny) on 2026-11-28T13:22:33Z. --- merge-check base: e429936c head: 651fc0502da4efd6bbcefa9faa9aed3dafb22d40 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2128 passed, 9 failed, 48 ignored: the base's 9 only (26 SKIPPED lines). The 9 failures are main's own at e429936c on this GPU (#3093); base alone: 2126 passed, 9 failed, 48 ignored. review: none. The intermediate is the exact 32-bit result (halves sign-extended; the multiply-add stays inside 32 bits), and the new form saturates correctly in both directions, each half through the same code. Not changed and not checked here: the HLSL path's clamp. Note from the thread: an RTX 50 run did not reproduce the wrong result the PR is for; the Ampere driver behaviour rests on the PR's own description, and this RTX 40 card passes with and without it. performance: direct DXIL only; one extra compare and select per half; a one-time re-translation there. verdict: safe to merge 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).
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!2855
No description provided.