Direct DXIL: reject directed f32 rounding on ENC_VINTRP interpolation #2814

Open
github-bot wants to merge 1 commit from github-bot/gh-2814 into main AGit
Owner

@⁠safesearch77 on GitHub · 2026-11-26 14:07 UTC · original
safesearch77:fix/dxil-vintrp-f32-round → main · +101 −3 · 3 files · 1 commits · draft

Reject 32-bit ENC_VINTRP encodings of V_INTERP_P1_F32 and V_INTERP_P2_F32 when a shader directs MODE[1:0] single-precision rounding in the Direct DXIL backend, matching the existing 64-bit ENC_VOP3 path.

lower_round::f32_round_unsupported (crates/xcl/src/gpu/dxil/lower_round.rs:481-483) lists "v_interp_p1_f32" | "v_interp_p2_f32" so pixel shaders that direct f32 rounding fail Direct DXIL translation ("directed f32 rounding of this instruction") rather than silently emitting nearest-even rasteriser interpolation. Previously, that check lived at the top of Lw::valu (lower_valu.rs:336), which is only reached by ENC_VOP* / VOP* encodings (lower.rs:975); standard 32-bit ENC_VINTRP encodings dispatched directly from Lw::inst (lower.rs:972) to Lw::interp_gfx and bypassed the guard.

Part of #1269

What is in it

  • crates/xcl/src/gpu/dxil/lower.rs, crates/xcl/src/gpu/dxil/lower_valu.rs: hoist the self.f32_rm && super::lower_round::f32_round_unsupported(&name) check into Lw::inst right before encoding dispatch and remove the redundant check from Lw::valu (+3 / -3).
  • crates/xcl/src/gpu/dxil/round_tests.rs: direct_f32_round_mode_vintrp_p1_p2_rejected, checking S_ROUND_MODE (1, 2, 3), S_SETREG_IMM32_B32 (0x0801), and S_SETREG_B32 (0x0801) against V_INTERP_P1_F32 and V_INTERP_P2_F32 in both ENC_VINTRP and ENC_VOP3 across wave64: false and wave64: true, plus positive controls (S_ROUND_MODE 0, S_ROUND_MODE 0xC f16/f64 RTZ with default f32 RNE, and V_INTERP_MOV_F32 under directed S_ROUND_MODE 1).

Tested

  • Linux x86_64 host, Rust stable (repo toolchain), cross-checked for x86_64-pc-windows-gnu: cargo check --offline --workspace --tests gave 0 errors (and only the 3 baseline warnings already on b49be183, none in gpu/dxil/).
  • Linux x86_64 host native rustc --edition 2021 --test harness over gpu::dxil::round_tests (built from git archive with Windows/GPU/DXC validator plumbing stubbed; no test or lowering code modified):
    • With lower.rs and lower_valu.rs from b49be183: direct_f32_round_mode_vintrp_p1_p2_rejected fails (8 passed; 1 failed, ("S_ROUND_MODE", "V_INTERP_P1_F32", "ENC_VINTRP", false)).
    • With this commit: 9 passed; 0 failed across gpu::dxil::round_tests.

Regression run

  • None yet. Direct DXIL pixel shaders require XCL_DIRECT_DXIL=all. The xcl-smoke pair (b49be183 and this head) must be added from a Windows retail run before marking ready for review.

Not tested

  • Windows cargo test --workspace -- --test-threads=4 GPU suite (including DXC dxcompiler.dll validation) and paired Windows scripts/smoke.ps1 retail runs. Prepared on a Linux CPU host without a Windows GPU or retail title.

AI use

  • Antigravity (Gemini 4 Carbon): implemented the Lw::inst hoist, wrote direct_f32_round_mode_vintrp_p1_p2_rejected and the Linux host rustc --test RED-to-GREEN harness, and wrote this description (bug isolated during upstream triage with Claude Opus 5.5).
**@⁠safesearch77** on GitHub · 2026-11-26 14:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2814) `safesearch77:fix/dxil-vintrp-f32-round` → `main` · +101 −3 · 3 files · 1 commits · draft Reject 32-bit `ENC_VINTRP` encodings of `V_INTERP_P1_F32` and `V_INTERP_P2_F32` when a shader directs `MODE[1:0]` single-precision rounding in the Direct DXIL backend, matching the existing 64-bit `ENC_VOP3` path. `lower_round::f32_round_unsupported` (`crates/xcl/src/gpu/dxil/lower_round.rs:481-483`) lists `"v_interp_p1_f32" | "v_interp_p2_f32"` so pixel shaders that direct f32 rounding fail Direct DXIL translation (`"directed f32 rounding of this instruction"`) rather than silently emitting nearest-even rasteriser interpolation. Previously, that check lived at the top of `Lw::valu` (`lower_valu.rs:336`), which is only reached by `ENC_VOP*` / `VOP*` encodings (`lower.rs:975`); standard 32-bit `ENC_VINTRP` encodings dispatched directly from `Lw::inst` (`lower.rs:972`) to `Lw::interp_gfx` and bypassed the guard. Part of #1269 **What is in it** - `crates/xcl/src/gpu/dxil/lower.rs`, `crates/xcl/src/gpu/dxil/lower_valu.rs`: hoist the `self.f32_rm && super::lower_round::f32_round_unsupported(&name)` check into `Lw::inst` right before encoding dispatch and remove the redundant check from `Lw::valu` (+3 / -3). - `crates/xcl/src/gpu/dxil/round_tests.rs`: `direct_f32_round_mode_vintrp_p1_p2_rejected`, checking `S_ROUND_MODE` (`1`, `2`, `3`), `S_SETREG_IMM32_B32` (`0x0801`), and `S_SETREG_B32` (`0x0801`) against `V_INTERP_P1_F32` and `V_INTERP_P2_F32` in both `ENC_VINTRP` and `ENC_VOP3` across `wave64: false` and `wave64: true`, plus positive controls (`S_ROUND_MODE 0`, `S_ROUND_MODE 0xC` f16/f64 RTZ with default f32 RNE, and `V_INTERP_MOV_F32` under directed `S_ROUND_MODE 1`). **Tested** - Linux x86_64 host, Rust stable (repo toolchain), cross-checked for `x86_64-pc-windows-gnu`: `cargo check --offline --workspace --tests` gave 0 errors (and only the 3 baseline warnings already on `b49be183`, none in `gpu/dxil/`). - Linux x86_64 host native `rustc --edition 2021 --test` harness over `gpu::dxil::round_tests` (built from `git archive` with Windows/GPU/DXC validator plumbing stubbed; no test or lowering code modified): - With `lower.rs` and `lower_valu.rs` from `b49be183`: `direct_f32_round_mode_vintrp_p1_p2_rejected` fails (`8 passed; 1 failed`, `("S_ROUND_MODE", "V_INTERP_P1_F32", "ENC_VINTRP", false)`). - With this commit: `9 passed; 0 failed` across `gpu::dxil::round_tests`. **Regression run** - None yet. Direct DXIL pixel shaders require `XCL_DIRECT_DXIL=all`. The `xcl-smoke` pair (`b49be183` and this head) must be added from a Windows retail run before marking ready for review. **Not tested** - Windows `cargo test --workspace -- --test-threads=4` GPU suite (including DXC `dxcompiler.dll` validation) and paired Windows `scripts/smoke.ps1` retail runs. Prepared on a Linux CPU host without a Windows GPU or retail title. **AI use** - Antigravity (Gemini 4 Carbon): implemented the `Lw::inst` hoist, wrote `direct_f32_round_mode_vintrp_p1_p2_rejected` and the Linux host `rustc --test` RED-to-GREEN harness, and wrote this description (bug isolated during upstream triage with Claude Opus 5.5).
lower_round::f32_round_unsupported lists v_interp_p1_f32 and
v_interp_p2_f32 so pixel shaders that direct MODE[1:0] fail translation
rather than silently emitting nearest-even interpolation. That guard
lived at the top of Lw::valu, which only 64-bit ENC_VOP3 encodings
reached; standard 32-bit ENC_VINTRP encodings dispatched straight from
Lw::inst to Lw::interp_gfx and bypassed it.

Hoist the f32_round_unsupported check into Lw::inst before encoding
dispatch and drop the redundant check in Lw::valu.

Assisted-by: Antigravity (Gemini 4 Carbon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:11:22 +00:00
Author
Owner

@⁠ettehn on GitHub · 2026-11-26 14:23 UTC · original

Native Windows A/B on 15e88d74df3ae653a6cda85fa0538acbe2554731 (clean) vs b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 (the new regression test copied over, no production edits). Windows 11 build 26200, Ryzen 9 8945HX, RTX 5070 Ti Laptop (12 GB, driver 621.24), Rust 1.97.1 MSVC debug, DXC/DXIL 1.8.2502.11. XCL_ADAPTER=NVIDIA XCL_REQUIRE_GPU=wave64.

  • Main reproduced the defect: the test failed with expected error for ("S_ROUND_MODE", "V_INTERP_P1_F32", "ENC_VINTRP", false). This arm ran only the new test.
  • cargo test --locked --offline -p xcl --lib -j 2 -- gpu::dxil::round_tests:: --test-threads=1 --nocapture on PR head: 9 passed, 0 failed, 0 ignored, with no reported skips. The new pixel translation rejection and positive controls passed. All five existing GPU arithmetic tests in the module ran on the laptop, including the dynamic/denormal cases.

The new pixel cases check translation; the GPU runs cover existing arithmetic cases. Full workspace testing and a retail title were outside this run.

OpenAI Codex assisted with the Windows verification.

**@⁠ettehn** on GitHub · 2026-11-26 14:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/2814#issuecomment-7194743287) Native Windows A/B on `15e88d74df3ae653a6cda85fa0538acbe2554731` (clean) vs `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7` (the new regression test copied over, no production edits). Windows 11 build 26200, Ryzen 9 8945HX, RTX 5070 Ti Laptop (12 GB, driver 621.24), Rust 1.97.1 MSVC debug, DXC/DXIL 1.8.2502.11. `XCL_ADAPTER=NVIDIA XCL_REQUIRE_GPU=wave64`. - Main reproduced the defect: the test failed with `expected error for ("S_ROUND_MODE", "V_INTERP_P1_F32", "ENC_VINTRP", false)`. This arm ran only the new test. - `cargo test --locked --offline -p xcl --lib -j 2 -- gpu::dxil::round_tests:: --test-threads=1 --nocapture` on PR head: **9 passed, 0 failed, 0 ignored**, with no reported skips. The new pixel translation rejection and positive controls passed. All five existing GPU arithmetic tests in the module ran on the laptop, including the dynamic/denormal cases. The new pixel cases check translation; the GPU runs cover existing arithmetic cases. Full workspace testing and a retail title were outside this run. OpenAI Codex assisted with the Windows verification.
Author
Owner

@⁠retrope13 on GitHub · 2026-11-26 14:24 UTC · original

Independent Windows/MSVC + NVIDIA GPU (RTX 4060 Laptop 8 GB, DXC 1.9.2602.17) verification and diff review of #2814 (15e88d74) against main (b49be183): full debug workspace suite + release round_tests green, 0 failures. No title was run.

Tested

  • Hardware / Env: NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, Ada Lovelace, driver 32.0.16.2140, wave32), Intel Core i5-14500HX (14C/20T), 24 GB RAM, Windows 11 26H2 (build 26300.9818), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100.0 DXC 1.9.2602.17, XCL_ADAPTER=NVIDIA.
  • Targeted gpu::dxil::round_tests:
    • Debug (cargo test --locked -p xcl --lib -- gpu::dxil::round_tests --test-threads=4 --nocapture): 9 passed, 0 failed, 0 ignored, 0 skipped (0.49 s; all 5 GPU rounding tests + direct_f32_round_mode_vintrp_p1_p2_rejected ran and passed).
    • Release (cargo test --release --locked -p xcl --lib -- gpu::dxil::round_tests --test-threads=4 --nocapture): 9 passed, 0 failed, 0 ignored, 0 skipped (0.65 s).
  • Full workspace (debug): cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4:
    • Clean main (b49be183): 1435 passed, 0 failed, 47 ignored
    • PR #2814 (15e88d74): 1436 passed, 0 failed, 47 ignored (+1 new test, 0 failures)

Diff Check (b49be183..15e88d74)

  • Verified lw.f32_rm is computed upfront over the whole program (kernel.rs:266), so hoisting self.f32_rm && lower_round::f32_round_unsupported(&name) into Lw::inst (lower.rs:965) closes the ENC_VINTRP → interp_gfx bypass regardless of block lowering order.
  • Verified f32_round_unsupported only matches v_fma_mix_f32, v_dot2_f32_f16, v_dot2c_f32_f16, v_interp_p1_f32, and v_interp_p2_f32, so hoisting out of Lw::valu introduces no false positives on non-VALU encodings while keeping V_INTERP_MOV_F32 and MODE[1:0] == 0 controls unaffected.

Not Tested

  • Live retail title scripts/smoke.ps1 runs, AMD / Intel GPUs, native wave64 hardware, and the 47 #[ignore] / SKIPPED tests.

AI disclosure: Antigravity (Gemini 4 Neon, XHigh) ran the builds/tests, checked the diff, and drafted this report.

**@⁠retrope13** on GitHub · 2026-11-26 14:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2814#issuecomment-7194765736) **Independent Windows/MSVC + NVIDIA GPU (RTX 4060 Laptop 8 GB, DXC `1.9.2602.17`) verification and diff review of `#2814` (`15e88d74`) against `main` (`b49be183`): full debug workspace suite + release `round_tests` green, 0 failures.** No title was run. ### Tested - **Hardware / Env:** NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, Ada Lovelace, driver `32.0.16.2140`, wave32), Intel Core i5-14500HX (14C/20T), 24 GB RAM, Windows 11 26H2 (build `26300.9818`), `rustc 1.100.0` (`stable-x86_64-pc-windows-msvc`), Windows SDK `10.0.26100.0` DXC `1.9.2602.17`, `XCL_ADAPTER=NVIDIA`. - **Targeted `gpu::dxil::round_tests`:** - Debug (`cargo test --locked -p xcl --lib -- gpu::dxil::round_tests --test-threads=4 --nocapture`): **9 passed, 0 failed, 0 ignored, 0 skipped** (`0.49 s`; all 5 GPU rounding tests + `direct_f32_round_mode_vintrp_p1_p2_rejected` ran and passed). - Release (`cargo test --release --locked -p xcl --lib -- gpu::dxil::round_tests --test-threads=4 --nocapture`): **9 passed, 0 failed, 0 ignored, 0 skipped** (`0.65 s`). - **Full workspace (debug):** `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4`: - Clean `main` (`b49be183`): **1435 passed, 0 failed, 47 ignored** - PR `#2814` (`15e88d74`): **1436 passed, 0 failed, 47 ignored** (+1 new test, 0 failures) ### Diff Check (`b49be183..15e88d74`) - Verified `lw.f32_rm` is computed upfront over the whole program (`kernel.rs:266`), so hoisting `self.f32_rm && lower_round::f32_round_unsupported(&name)` into `Lw::inst` (`lower.rs:965`) closes the `ENC_VINTRP` → `interp_gfx` bypass regardless of block lowering order. - Verified `f32_round_unsupported` only matches `v_fma_mix_f32`, `v_dot2_f32_f16`, `v_dot2c_f32_f16`, `v_interp_p1_f32`, and `v_interp_p2_f32`, so hoisting out of `Lw::valu` introduces no false positives on non-VALU encodings while keeping `V_INTERP_MOV_F32` and `MODE[1:0] == 0` controls unaffected. ### Not Tested - Live retail title `scripts/smoke.ps1` runs, AMD / Intel GPUs, native wave64 hardware, and the 47 `#[ignore]` / `SKIPPED` tests. *AI disclosure: Antigravity (Gemini 4 Neon, XHigh) ran the builds/tests, checked the diff, and drafted this report.*
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2814/head:github-bot/gh-2814'
git switch 'github-bot/gh-2814'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2814'
git switch 'github-bot/gh-2814'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2814'
git switch 'github-bot/gh-2814'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2814'
git switch 'main'
git merge --squash 'github-bot/gh-2814'
git switch 'main'
git merge --ff-only 'github-bot/gh-2814'
git switch 'main'
git merge 'github-bot/gh-2814'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.