Recompiler: saturate UINT/SINT and use RTZ in direct DXIL fmt_encode #2043

Manually merged
github merged 1 commit from gh-pr/2043/head into gh-pr/2043/base 2026-11-26 05:16:23 +00:00
Owner

@⁠Decodere on GitHub · 2026-11-25 01:47 UTC · original
Decodere:fix-1488-dxil-fmt-encode → main · +101 −8 · 2 files · 1 commits · merged 2026-11-25 01:56 UTC

Brings direct DXIL Lw::fmt_encode (crates/xcl/src/gpu/dxil/lower_mem.rs) into parity with RDNA2 hardware and merged PR #1929 (recomp/emit.rs HLSL fmt_encode) for buffer format stores (BUFFER_STORE_FORMAT_* / TBUFFER_STORE_FORMAT_*). Part of #1269, Part of #1488 (XCL-BT-026).

Merged PR #1929 fixed XCL-BT-026 in the HLSL emitter only, leaving direct DXIL Lw::fmt_encode returning raw unclamped integers for UINT (ty == 4) and SINT (ty == 5) when w < 32 and rounding 16-, 11-, and 10-bit FLOAT values with round-to-nearest-even (f32_to_f16) instead of round-toward-zero (f16_rtz).

What is in it

  • crates/xcl/src/gpu/dxil/lower_mem.rs:
    • In Lw::fmt_encode, saturate ty == 4 (UINT) to [0, mu] via umin(x, mu) and ty == 5 (SINT) to [!ms, ms] via imin(imax(x, !ms), ms) when w < 32, preserving passthrough for w >= 32.
    • Replace self.s.f32_to_f16(f) with self.f16_rtz(f) for 16-, 11-, and 10-bit FLOAT stores so finite values above 65504.0 saturate to max finite (0x7BFF/0xFBFF, 0x7BF/0x3DF) and normal/subnormal intermediates round toward zero while preserving true ±Inf and NaN.
  • crates/xcl/src/gpu/recomp/tests.rs:
    • Add gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz, compiling and running both HLSL and direct DXIL unconditionally on the GPU across 16_16_UINT, 16_16_SINT, 8_8_8_8_UINT, 8_8_8_8_SINT, 2_10_10_10_SINT, 32_UINT/32_SINT passthrough, 16_16_FLOAT (finite overflow, normal RTZ, ±Inf, subnormal RTZ, -0.0), and 11_11_10_FLOAT (finite overflow, +Inf, NaN, negative, RTZ boundary).

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 4060 (8 GB, 32-lane waves, driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 Home build 26200, Rust 1.100.0 (0ef1bc386), DXC 1.9.2609.5 (01b62ad4), release build.
  • Pre-fix reproduction: confirmed gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz fails before the fix on RTX 4060 (hlsl passed all 13 cases while direct_dxil wrapped 16_16_UINT: got 0xFFFF_1170 instead of 0xFFFF_FFFF).
  • Targeted post-fix runs (0 failures, 0 skipped):
    • cargo test --release -p xcl --lib gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz -- --nocapture: 1 passed, 0 failed, 0 ignored (both HLSL and direct DXIL executed on RTX 4060).
    • XCL_DIRECT_DXIL=1 on gpu_fmt_encode_int_sat_and_f16_rtz and gpu_pknorm_i16_f32_nan_and_fmt_encode_snorm_ufloat: both passed, 0 failed.
  • cargo build --release --workspace + cargo test --release --workspace -- --test-threads=4: 1103 passed, 0 failed, 46 ignored across 20 test binaries.
  • SKIPPED GPU/runtime tests on this adapter (24 lines):
    • 19 no wave64 subcases across gpu::recomp::lower::tests (4), gpu::recomp::lower_dxil::tests (13), and gpu::recomp::tests (2)
    • 3 intentional per-lane #1426 refusals (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32) in gpu::recomp::lower_dxil::tests
    • shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required)
    • heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows

Regression run
scripts/smoke.ps1 on main (8f5fca5bb9ad6e695093d75294ad2cec023bba60) and on this PR's head commit (6c9f9473e5cbe38cf0d01ec890eced284a9bb711):

xcl-smoke v1
commit: 8f5fca5bb9ad6e695093d75294ad2cec023bba60
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1574 (PresentX 1574)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14665 MB
xcl-smoke v1
commit: 6c9f9473e5cbe38cf0d01ec890eced284a9bb711
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1583 (PresentX 1583)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14696 MB

Not tested

  • AMD and Intel GPUs, native wave64 hardware, and heap-window GPU execution (skipped above).
  • D16 buffer format loads (lower_mem.rs lines 1291/1336/1364) and image format stores (lower_image.rs), which are outside Lw::fmt_encode.
  • Debug-profile full workspace test run (the full suite ran in --release).

AI use

  • Google Antigravity (Gemini 4 Neon) — audited direct DXIL Lw::fmt_encode against HLSL fmt_encode (#1929), implemented the saturation and RTZ fix, HLSL/direct DXIL GPU regression test, and PR description; all tests and paired 60s smoke runs were verified locally on RTX 4060 hardware.
**@⁠Decodere** on GitHub · 2026-11-25 01:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/2043) `Decodere:fix-1488-dxil-fmt-encode` → `main` · +101 −8 · 2 files · 1 commits · merged 2026-11-25 01:56 UTC Brings direct DXIL `Lw::fmt_encode` (`crates/xcl/src/gpu/dxil/lower_mem.rs`) into parity with RDNA2 hardware and merged PR #1929 (`recomp/emit.rs` HLSL `fmt_encode`) for buffer format stores (`BUFFER_STORE_FORMAT_*` / `TBUFFER_STORE_FORMAT_*`). Part of #1269, Part of #1488 (`XCL-BT-026`). Merged PR #1929 fixed `XCL-BT-026` in the HLSL emitter only, leaving direct DXIL `Lw::fmt_encode` returning raw unclamped integers for `UINT` (`ty == 4`) and `SINT` (`ty == 5`) when `w < 32` and rounding 16-, 11-, and 10-bit `FLOAT` values with round-to-nearest-even (`f32_to_f16`) instead of round-toward-zero (`f16_rtz`). **What is in it** - `crates/xcl/src/gpu/dxil/lower_mem.rs`: - In `Lw::fmt_encode`, saturate `ty == 4` (`UINT`) to `[0, mu]` via `umin(x, mu)` and `ty == 5` (`SINT`) to `[!ms, ms]` via `imin(imax(x, !ms), ms)` when `w < 32`, preserving passthrough for `w >= 32`. - Replace `self.s.f32_to_f16(f)` with `self.f16_rtz(f)` for 16-, 11-, and 10-bit `FLOAT` stores so finite values above `65504.0` saturate to max finite (`0x7BFF`/`0xFBFF`, `0x7BF`/`0x3DF`) and normal/subnormal intermediates round toward zero while preserving true `±Inf` and `NaN`. - `crates/xcl/src/gpu/recomp/tests.rs`: - Add `gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz`, compiling and running both HLSL and direct DXIL unconditionally on the GPU across `16_16_UINT`, `16_16_SINT`, `8_8_8_8_UINT`, `8_8_8_8_SINT`, `2_10_10_10_SINT`, `32_UINT`/`32_SINT` passthrough, `16_16_FLOAT` (finite overflow, normal RTZ, `±Inf`, subnormal RTZ, `-0.0`), and `11_11_10_FLOAT` (finite overflow, `+Inf`, `NaN`, negative, RTZ boundary). **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 4060 (8 GB, 32-lane waves, driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 Home build 26200, Rust 1.100.0 (`0ef1bc386`), DXC 1.9.2609.5 (`01b62ad4`), release build. - Pre-fix reproduction: confirmed `gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz` fails before the fix on RTX 4060 (`hlsl` passed all 13 cases while `direct_dxil` wrapped `16_16_UINT`: got `0xFFFF_1170` instead of `0xFFFF_FFFF`). - Targeted post-fix runs (0 failures, 0 skipped): - `cargo test --release -p xcl --lib gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz -- --nocapture`: 1 passed, 0 failed, 0 ignored (both HLSL and direct DXIL executed on RTX 4060). - `XCL_DIRECT_DXIL=1` on `gpu_fmt_encode_int_sat_and_f16_rtz` and `gpu_pknorm_i16_f32_nan_and_fmt_encode_snorm_ufloat`: both passed, 0 failed. - `cargo build --release --workspace` + `cargo test --release --workspace -- --test-threads=4`: 1103 passed, 0 failed, 46 ignored across 20 test binaries. - `SKIPPED` GPU/runtime tests on this adapter (24 lines): - 19 `no wave64` subcases across `gpu::recomp::lower::tests` (4), `gpu::recomp::lower_dxil::tests` (13), and `gpu::recomp::tests` (2) - 3 intentional per-lane `#1426` refusals (`V_MUL_F16`, `V_PK_MUL_F16`, `V_CVT_F16_F32`) in `gpu::recomp::lower_dxil::tests` - `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required)` - `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows` **Regression run** `scripts/smoke.ps1` on `main` (`8f5fca5bb9ad6e695093d75294ad2cec023bba60`) and on this PR's head commit (`6c9f9473e5cbe38cf0d01ec890eced284a9bb711`): ``` xcl-smoke v1 commit: 8f5fca5bb9ad6e695093d75294ad2cec023bba60 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1574 (PresentX 1574) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14665 MB ``` ``` xcl-smoke v1 commit: 6c9f9473e5cbe38cf0d01ec890eced284a9bb711 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1583 (PresentX 1583) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14696 MB ``` **Not tested** - AMD and Intel GPUs, native wave64 hardware, and heap-window GPU execution (skipped above). - `D16` buffer format loads (`lower_mem.rs` lines 1291/1336/1364) and image format stores (`lower_image.rs`), which are outside `Lw::fmt_encode`. - Debug-profile full workspace test run (the full suite ran in `--release`). **AI use** - Google Antigravity (Gemini 4 Neon) — audited direct DXIL `Lw::fmt_encode` against HLSL `fmt_encode` (#1929), implemented the saturation and RTZ fix, HLSL/direct DXIL GPU regression test, and PR description; all tests and paired 60s smoke runs were verified locally on RTX 4060 hardware.
Merged PR #1929 fixed `XCL-BT-026` in the HLSL emitter (`recomp/emit.rs`),
leaving direct DXIL's `Lw::fmt_encode` (`dxil/lower_mem.rs`) returning raw
unclamped integers for `UINT` (`ty == 4`) and `SINT` (`ty == 5`) and using
round-to-nearest-even (`f32_to_f16`) for 16-, 11-, and 10-bit `FLOAT`
buffer format stores.

Bring `Lw::fmt_encode` into parity with RDNA2 and HLSL `fmt_encode`:
- Saturate `UINT` to `[0, (1 << w) - 1]` and `SINT` to `[-(1 << (w - 1)), (1 << (w - 1)) - 1]`
  when `w < 32`, preserving `w >= 32` passthrough.
- Use `Lw::f16_rtz` for `w == 16`, `w == 11`, and `w == 10` float stores
  so finite values above 65504 saturate to max finite while preserving
  true `+-Inf` and `NaN`.

Add `gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz` covering both HLSL
and direct DXIL across 16/8/10/2/32-bit UINT/SINT and 16-bit/11_11_10
FLOAT edge cases.

Part of #1269
Part of #1488

Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:16:21 +00:00
github manually merged commit 6c9f9473e5 into gh-pr/2043/base 2026-11-26 05:16:23 +00:00
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:51 UTC · original

Diff audit passed on 6c9f947 (Lw::fmt_encode saturating ty == 4 UINT to [0, mu] and ty == 5 SINT to [!ms, ms] for w < 32, and using f16_rtz(f) for float formats matching HLSL fmt_encode, plus gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz). PR description is green and RTX 4060 passed (1103 workspace + paired smoke).

Remaining before merge: Build and test (Windows, no GPU) completion plus one independent AMD GPU verification pass on 6c9f947.

**@⁠raylitebull** on GitHub · 2026-11-25 01:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/2043#issuecomment-7150030305) Diff audit passed on `6c9f947` (`Lw::fmt_encode` saturating `ty == 4` UINT to `[0, mu]` and `ty == 5` SINT to `[!ms, ms]` for `w < 32`, and using `f16_rtz(f)` for float formats matching HLSL `fmt_encode`, plus `gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz`). `PR description` is green and RTX 4060 passed (`1103` workspace + paired smoke). **Remaining before merge:** `Build and test (Windows, no GPU)` completion plus one independent **AMD** GPU verification pass on `6c9f947`.
Author
Owner

@⁠WebIdentity1 on GitHub · 2026-11-25 01:52 UTC · original · edited 2026-11-25 01:54 UTC

Independent AMD verification of 6c9f9473e5cbe38cf0d01ec890eced284a9bb711: integer saturation is fixed; the fixture's float outputs already matched RTZ on the parent on this GPU, consistent with @⁠upipibi's NVIDIA observation.

Tested

Windows 10 Home 19045, Ryzen 7 7800X3D, AMD Radeon(TM) Graphics iGPU driver 32.0.21030.2001, native wave64; Rust/Cargo 1.98.1 x64 MSVC, DXC/DXIL 1.8.2502.11, unoptimized debug test profile. XCL_ADAPTER=AMD; adapter/native64 printed by the fixture.

Compared parent 8f5fca5bb9ad6e695093d75294ad2cec023bba60 with the same added regression versus PR head. The only head overlay is two diagnostic println! lines: adapter and all 13 packed outputs before assertions. No runtime or expected-value changes. Both 317-file source manifests matched before/after and the local snapshots; XCL recompiled both.

  • cargo test --locked -p xcl --lib -- gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz --test-threads=1 --show-output: parent 0 passed / 1 failed / 0 ignored, head 1 / 0 / 0, zero skips both. Each fixture explicitly compiles and dispatches HLSL and Direct DXIL. Parent HLSL passes; parent Direct DXIL fails first at 16_16_UINT (ffff1170 instead of ffffffff). Outputs logged before that assertion establish five integer mismatches and zero float mismatches.
  • Head, XCL_DIRECT_DXIL=1:
    cargo test --locked -p xcl --lib -- gpu_fmt_encode_int_sat_and_f16_rtz gpu_pknorm_i16_f32_nan_and_fmt_encode_snorm_ufloat --test-threads=1 --show-output: 2 / 0 / 0, zero skips.
Output group Parent Direct DXIL vs expected Head Direct DXIL vs expected
Five narrow UINT/SINT packed outputs 5 mismatches 0
Two 32-bit integer passthrough outputs 0 0
Six float packed outputs 0 0

All 13 head words match HLSL and the fixture's CPU constants. Parent and head float words are identical: fbff7bff bc003c00 fc007c00 80000000 f7ff03df 780003f0 (finite overflow, normal RTZ, infinities, subnormal/-0, and 11/11/10 cases). This verifies the selected float cases; it is not exhaustive proof of conversion equivalence or a native RDNA2 instruction oracle. The fixture uses uniform lane values and checks packed memory outputs, not distinct per-lane addresses.

Not tested

Full workspace, retail smoke/gameplay, NVIDIA/Intel in this pass, exhaustive float inputs/NaN payloads, image stores/D16 loads, release profile, or compilation/runtime performance and memory cost. The floating-point replacement makes the implementation explicit; this experiment does not show changed float results or a speed benefit. Required full-suite/retail gates remain separate.

AI use — Codex (GPT-6) inspected the source, added the two diagnostic lines, transferred/ran/verified the native comparison and controls, and drafted this report. The fix and regression remain the PR author's work.

Two-line diagnostic overlay on PR head
diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 5bc15a7..d5f74ce 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -8058,6 +8058,7 @@ fn gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz() {
     if !gpu_ready() {
         return;
     }
+    println!("FMT adapter={} native64={:?}", runner::adapter().unwrap(), runner::wave64_supported());
     let ident = 4 | 5 << 3 | 6 << 6 | 7 << 9;
     let vs = |base: u32, fmt: u32| [base, 0, 0x100, ident | fmt << 12];
     let p = prog(&[
@@ -8125,6 +8126,7 @@ fn gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz() {
     let direct_dxil = runner::direct_kernel_full(&p, true).unwrap().dxil;
     for (backend, dxil) in [("hlsl", hlsl_dxil), ("direct_dxil", direct_dxil)] {
         let r = runner::run_with_statics(&dxil, &st, &mem, &[], &[], &[]).unwrap_or_else(|e| panic!("{backend}: {e}"));
+        println!("FMT backend={backend} words={:08x?}", &r.mem[0x200 / 4..=0x230 / 4]);
         assert_eq!(r.mem[0x200 / 4], 0xFFFF_FFFF, "{backend}: 16_16_UINT");
         assert_eq!(r.mem[0x204 / 4], 0x8000_7FFF, "{backend}: 16_16_SINT");
         assert_eq!(r.mem[0x208 / 4], 0xFF00_FFFF, "{backend}: 8_8_8_8_UINT");
**@⁠WebIdentity1** on GitHub · 2026-11-25 01:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/2043#issuecomment-7150060175) · edited 2026-11-25 01:54 UTC Independent AMD verification of `6c9f9473e5cbe38cf0d01ec890eced284a9bb711`: integer saturation is fixed; the fixture's float outputs already matched RTZ on the parent on this GPU, consistent with @⁠upipibi's NVIDIA observation. **Tested** Windows 10 Home 19045, Ryzen 7 7800X3D, AMD Radeon(TM) Graphics iGPU driver `32.0.21030.2001`, native wave64; Rust/Cargo 1.98.1 x64 MSVC, DXC/DXIL 1.8.2502.11, unoptimized debug test profile. `XCL_ADAPTER=AMD`; adapter/native64 printed by the fixture. Compared parent `8f5fca5bb9ad6e695093d75294ad2cec023bba60` with the same added regression versus PR head. The only head overlay is two diagnostic `println!` lines: adapter and all 13 packed outputs before assertions. No runtime or expected-value changes. Both 317-file source manifests matched before/after and the local snapshots; XCL recompiled both. - `cargo test --locked -p xcl --lib -- gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz --test-threads=1 --show-output`: parent **0 passed / 1 failed / 0 ignored**, head **1 / 0 / 0**, zero skips both. Each fixture explicitly compiles and dispatches HLSL and Direct DXIL. Parent HLSL passes; parent Direct DXIL fails first at `16_16_UINT` (`ffff1170` instead of `ffffffff`). Outputs logged before that assertion establish five integer mismatches and zero float mismatches. - Head, `XCL_DIRECT_DXIL=1`: `cargo test --locked -p xcl --lib -- gpu_fmt_encode_int_sat_and_f16_rtz gpu_pknorm_i16_f32_nan_and_fmt_encode_snorm_ufloat --test-threads=1 --show-output`: **2 / 0 / 0**, zero skips. | Output group | Parent Direct DXIL vs expected | Head Direct DXIL vs expected | |---|---:|---:| | Five narrow UINT/SINT packed outputs | 5 mismatches | 0 | | Two 32-bit integer passthrough outputs | 0 | 0 | | Six float packed outputs | 0 | 0 | All 13 head words match HLSL and the fixture's CPU constants. Parent and head float words are identical: `fbff7bff bc003c00 fc007c00 80000000 f7ff03df 780003f0` (finite overflow, normal RTZ, infinities, subnormal/-0, and 11/11/10 cases). This verifies the selected float cases; it is not exhaustive proof of conversion equivalence or a native RDNA2 instruction oracle. The fixture uses uniform lane values and checks packed memory outputs, not distinct per-lane addresses. **Not tested** Full workspace, retail smoke/gameplay, NVIDIA/Intel in this pass, exhaustive float inputs/NaN payloads, image stores/D16 loads, release profile, or compilation/runtime performance and memory cost. The floating-point replacement makes the implementation explicit; this experiment does not show changed float results or a speed benefit. Required full-suite/retail gates remain separate. **AI use** — Codex (GPT-6) inspected the source, added the two diagnostic lines, transferred/ran/verified the native comparison and controls, and drafted this report. The fix and regression remain the PR author's work. <details><summary>Two-line diagnostic overlay on PR head</summary> ```diff diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 5bc15a7..d5f74ce 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -8058,6 +8058,7 @@ fn gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz() { if !gpu_ready() { return; } + println!("FMT adapter={} native64={:?}", runner::adapter().unwrap(), runner::wave64_supported()); let ident = 4 | 5 << 3 | 6 << 6 | 7 << 9; let vs = |base: u32, fmt: u32| [base, 0, 0x100, ident | fmt << 12]; let p = prog(&[ @@ -8125,6 +8126,7 @@ fn gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz() { let direct_dxil = runner::direct_kernel_full(&p, true).unwrap().dxil; for (backend, dxil) in [("hlsl", hlsl_dxil), ("direct_dxil", direct_dxil)] { let r = runner::run_with_statics(&dxil, &st, &mem, &[], &[], &[]).unwrap_or_else(|e| panic!("{backend}: {e}")); + println!("FMT backend={backend} words={:08x?}", &r.mem[0x200 / 4..=0x230 / 4]); assert_eq!(r.mem[0x200 / 4], 0xFFFF_FFFF, "{backend}: 16_16_UINT"); assert_eq!(r.mem[0x204 / 4], 0x8000_7FFF, "{backend}: 16_16_SINT"); assert_eq!(r.mem[0x208 / 4], 0xFF00_FFFF, "{backend}: 8_8_8_8_UINT"); ``` </details>
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-25 01:54 UTC · original

I checked the immediate-format stores (TBUFFER_STORE_FORMAT_*, MTBUF) on the Radeon. These take the storage format from the instruction. The regression test in this PR uses descriptor-format stores (BUFFER_STORE_FORMAT_*, MUBUF).

Tested

  • Head 6c9f9473e5cbe38cf0d01ec890eced284a9bb711 and its parent 8f5fca5bb9ad6e695093d75294ad2cec023bba60. AMD Radeon(TM) Graphics, driver 32.0.21042.62, Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.8.2502.11, unoptimized test profile. The runner reported the Radeon and native wave64 support.
  • For the MTBUF check I reused the PR's 13 inputs and expected packed words. I put each format in the instruction and set every buffer descriptor to 32_UINT. Both shader translation paths ran. Command on both revisions was cargo test --locked -p xcl --lib gpu::recomp::tests::local_mtbuf_format_stores -- --exact --nocapture --test-threads=1 with XCL_ADAPTER=AMD Radeon and XCL_REQUIRE_GPU=wave64. This was a temporary local test. I printed all 13 readbacks before the first assertion.
  • On the parent, HLSL matched all 13. Direct DXIL differed on all five narrow integer words (16-bit unsigned/signed, 8-bit unsigned/signed and packed 2/10/10/10 signed). For example, unsigned 70,000 stored as 4,464. Both 32-bit words and all six float words already matched. Test result was 0 passed, 1 failed.
  • On the head, HLSL and direct DXIL each matched all 13, including unsigned 70,000 storing as 65,535. Test result was 1 passed, 0 failed. The PR's original gpu::recomp::tests::gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz also passed on the head with the same command and its exact test name. All three runs had 0 ignored and no skips.

Not tested

Retail gameplay, the full workspace suite, and other adapters in this check.

AI use

OpenAI Codex (GPT-6) adapted the test, ran the comparisons and wrote this report.

**@⁠nnonno91** on GitHub · 2026-11-25 01:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/2043#issuecomment-7150104013) I checked the immediate-format stores (`TBUFFER_STORE_FORMAT_*`, MTBUF) on the Radeon. These take the storage format from the instruction. The regression test in this PR uses descriptor-format stores (`BUFFER_STORE_FORMAT_*`, MUBUF). **Tested** - Head `6c9f9473e5cbe38cf0d01ec890eced284a9bb711` and its parent `8f5fca5bb9ad6e695093d75294ad2cec023bba60`. AMD Radeon(TM) Graphics, driver 32.0.21042.62, Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.8.2502.11, unoptimized test profile. The runner reported the Radeon and native wave64 support. - For the MTBUF check I reused the PR's 13 inputs and expected packed words. I put each format in the instruction and set every buffer descriptor to `32_UINT`. Both shader translation paths ran. Command on both revisions was `cargo test --locked -p xcl --lib gpu::recomp::tests::local_mtbuf_format_stores -- --exact --nocapture --test-threads=1` with `XCL_ADAPTER=AMD Radeon` and `XCL_REQUIRE_GPU=wave64`. This was a temporary local test. I printed all 13 readbacks before the first assertion. - On the parent, HLSL matched all 13. Direct DXIL differed on all five narrow integer words (16-bit unsigned/signed, 8-bit unsigned/signed and packed 2/10/10/10 signed). For example, unsigned 70,000 stored as 4,464. Both 32-bit words and all six float words already matched. Test result was 0 passed, 1 failed. - On the head, HLSL and direct DXIL each matched all 13, including unsigned 70,000 storing as 65,535. Test result was 1 passed, 0 failed. The PR's original `gpu::recomp::tests::gpu_fmt_encode_direct_dxil_int_sat_and_f16_rtz` also passed on the head with the same command and its exact test name. All three runs had 0 ignored and no skips. **Not tested** Retail gameplay, the full workspace suite, and other adapters in this check. **AI use** OpenAI Codex (GPT-6) adapted the test, ran the comparisons and wrote this report.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 01:51 UTC · original · edited 2026-11-25 01:58 UTC

A data point on the float half, from measuring on an RTX 3070 (616.56) and WARP, not on this branch. self.s.f32_to_f16 is DXIL's legacyF32ToF16 (dxil/ops.rs:442), and on D3D12 it already rounds toward zero. 1 + 3·2⁻¹¹ gives 0x3c01, 70000 gives 0x7bff and −70000 gives 0xfbff, the same as f16_rtz. So switching fmt_encode's FLOAT stores to f16_rtz doesn't change the bits on those devices. It makes the rounding explicit rather than driver-defined, which is still worth having. The UINT/SINT saturation is the part that changes results. The details are in #2026, where the same truncation shows up on the D16 read side.

Evidence for the integer half, measured on main c00f3fc (RTX 3070): gpu_fmt_encode_int_sat_and_f16_rtz fails with XCL_DIRECT_DXIL=1 (16_16_UINT saturates 70000 -> 65535, left 0xffff1170), so this PR is what makes that test pass on the direct path.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 01:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/2043#issuecomment-7150038866) · edited 2026-11-25 01:58 UTC A data point on the float half, from measuring on an RTX 3070 (616.56) and WARP, not on this branch. `self.s.f32_to_f16` is DXIL's `legacyF32ToF16` (`dxil/ops.rs:442`), and on D3D12 it already rounds toward zero. `1 + 3·2⁻¹¹` gives `0x3c01`, 70000 gives `0x7bff` and −70000 gives `0xfbff`, the same as `f16_rtz`. So switching `fmt_encode`'s FLOAT stores to `f16_rtz` doesn't change the bits on those devices. It makes the rounding explicit rather than driver-defined, which is still worth having. The UINT/SINT saturation is the part that changes results. The details are in #2026, where the same truncation shows up on the D16 read side. Evidence for the integer half, measured on `main` `c00f3fc` (RTX 3070): `gpu_fmt_encode_int_sat_and_f16_rtz` fails with `XCL_DIRECT_DXIL=1` (`16_16_UINT saturates 70000 -> 65535`, left `0xffff1170`), so this PR is what makes that test pass on the direct path. AI-assisted (Claude Code).
This discussion has been locked. Commenting is limited to contributors.
No description provided.