Direct DXIL: convert integer PS inputs to float in v_interp_p2_* #2112

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

@⁠Decodere on GitHub · 2026-11-25 04:52 UTC · original
Decodere:fix-1269-dxil-interp-ct → main · +185 −12 · 1 files · 1 commits · open

What is in it
Matches the HLSL recompiler (recomp/emit.rs) for integer pixel-shader inputs in the direct DXIL translator's Lw::interp_gfx() (crates/xcl/src/gpu/dxil/lower_gfx.rs):

  • Changes GfxCtx::ps_in from Vec<(Sig, bool)> to Vec<(Sig, u32)> to preserve each PS input's DXBC component_type (matching GfxCtx::targets).
  • In Lw::interp_gfx():
    • For v_interp_p2_f32 and v_interp_p2_f16, converts UINT (component_type == 1) via CastOp::UIToFP and SINT (component_type == 2) via CastOp::SIToFP to f32 before bitcasting to i32 (v_interp_p2_f32) or converting via self.to_f16 (v_interp_p2_f16). Previously, interp_gfx ignored the input type and returned raw integer bits (asuint(i) instead of asuint((float)i) for p2_f32, and bitcast integer bits as float before to_f16 for p2_f16).
    • Keeps raw bitcast (no int-to-float cast) for v_interp_mov_f32, preserving raw integer selector bits as in #249.
  • Adds 2 tests in gpu::dxil::lower_gfx::tests:
    • ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits: CPU test validating DXIL and checking disassembled IR across UINT (1), SINT (2), and F32 (3) inputs for v_interp_p2_f32, v_interp_p2_f16 (both lo and hi OP_SEL[3]), and v_interp_mov_f32.
    • gpu_ps_interp_int_component_types_match_hlsl: GPU draw test (guarded by graphics::tests::draw_ready()) verifying direct DXIL matches HLSL and exact expected pixel values ([5.0, -3.0, 1.0, -2.5] for p2_f32 + mov_f32, [7.0, -4.0, 7.0, -4.0] for p2_f16 lo + hi).

Part of #1269

Tested
Environment: Windows 11 Home 26200, Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14, wave32), Rust 1.100.0, DXC 1.9.2609.5 (01b62ad4).

  • Failing-first pre-fix check (cargo test -j 4 -p xcl --lib gpu::dxil::lower_gfx::tests::ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits -- --nocapture): 0 passed, 1 failed (p2_f32 uint emitted raw bitcast i32 to float without uitofp i32).
  • Post-fix targeted tests on RTX 4060 (cargo test --release -p xcl --lib gpu::dxil::lower_gfx::tests -- --nocapture): 2 passed, 0 failed (dxil 1.9.2609.5 validation + IR checks + GPU draw parity vs HLSL).
  • Post-fix targeted tests on WARP (XCL_ADAPTER="Microsoft Basic Render Driver"): 2 passed, 0 failed (ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits ran and passed; gpu_ps_interp_int_component_types_match_hlsl cleanly skipped via draw_ready() with SKIPPED ...: no GPU).
  • Full release workspace build & test (cargo build --release --workspace and cargo test --release --workspace -- --test-threads=4 --nocapture): 1,156 passed, 0 failed, 46 ignored across 21 test binaries (1100 in xcl lib, 56 across the remaining 20 binaries), with 27 SKIPPED lines on this RTX 4060:
    • 20 no wave64 (RTX 4060 is wave32-only)
    • 3 per-lane form: refused (wave32 f16 arithmetic, f16 packed, f32 conversions)
    • 2 no d3d12SDKLayers.dll / no D3D12 debug layer
    • 1 cannot disable the driver cache (Windows Developer Mode not enabled)
    • 1 no heap windows

Regression run
Paired 60 s runs via scripts/smoke.ps1 on clean origin/main (6987e496) and clean PR head (36e1c899):

Main (6987e496c35653f9ccc9dbdc1f1d342734306811):

xcl-smoke v1
commit: 6987e496c35653f9ccc9dbdc1f1d342734306811
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: 14479 MB

PR (36e1c89959d237dc7ea753a42d6c6edaebc1471b):

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

Not tested

  • Native wave64 GPU execution (20 no wave64 skips on RTX 4060), D3D12 debug layer tests (2 skips without d3d12SDKLayers.dll), driver cache disable toggle (1 skip without Windows Developer Mode), and heap-window OOM fallback (1 skip without XCL_HEAP_WINDOWS).
  • Retail titles other than title: 29640639, and direct DXIL graphics mode (XCL_DIRECT_DXIL=all) on a retail title shader using v_interp_p2_* on integer ISG1 attributes.

AI use
Google Antigravity (Gemini 4 Neon) wrote the interp_gfx fix, regression tests, and this PR description. All pre-fix/post-fix CPU and GPU tests, WARP skip checks, full release workspace tests, paired 60 s smoke runs, and scripts/pr_check.py --local validation were run locally on this machine.

**@⁠Decodere** on GitHub · 2026-11-25 04:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/2112) `Decodere:fix-1269-dxil-interp-ct` → `main` · +185 −12 · 1 files · 1 commits · open **What is in it** Matches the HLSL recompiler (`recomp/emit.rs`) for integer pixel-shader inputs in the direct DXIL translator's `Lw::interp_gfx()` (`crates/xcl/src/gpu/dxil/lower_gfx.rs`): - Changes `GfxCtx::ps_in` from `Vec<(Sig, bool)>` to `Vec<(Sig, u32)>` to preserve each PS input's DXBC `component_type` (matching `GfxCtx::targets`). - In `Lw::interp_gfx()`: - For `v_interp_p2_f32` and `v_interp_p2_f16`, converts `UINT` (`component_type == 1`) via `CastOp::UIToFP` and `SINT` (`component_type == 2`) via `CastOp::SIToFP` to `f32` before bitcasting to `i32` (`v_interp_p2_f32`) or converting via `self.to_f16` (`v_interp_p2_f16`). Previously, `interp_gfx` ignored the input type and returned raw integer bits (`asuint(i)` instead of `asuint((float)i)` for `p2_f32`, and bitcast integer bits as float before `to_f16` for `p2_f16`). - Keeps raw `bitcast` (no int-to-float cast) for `v_interp_mov_f32`, preserving raw integer selector bits as in `#249`. - Adds 2 tests in `gpu::dxil::lower_gfx::tests`: - `ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits`: CPU test validating DXIL and checking disassembled IR across `UINT` (`1`), `SINT` (`2`), and `F32` (`3`) inputs for `v_interp_p2_f32`, `v_interp_p2_f16` (both lo and hi `OP_SEL[3]`), and `v_interp_mov_f32`. - `gpu_ps_interp_int_component_types_match_hlsl`: GPU draw test (guarded by `graphics::tests::draw_ready()`) verifying direct DXIL matches HLSL and exact expected pixel values (`[5.0, -3.0, 1.0, -2.5]` for `p2_f32` + `mov_f32`, `[7.0, -4.0, 7.0, -4.0]` for `p2_f16` lo + hi). Part of #1269 **Tested** Environment: Windows 11 Home 26200, Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14, wave32), Rust 1.100.0, DXC `1.9.2609.5` (`01b62ad4`). - Failing-first pre-fix check (`cargo test -j 4 -p xcl --lib gpu::dxil::lower_gfx::tests::ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits -- --nocapture`): 0 passed, 1 failed (`p2_f32 uint` emitted raw `bitcast i32 to float` without `uitofp i32`). - Post-fix targeted tests on RTX 4060 (`cargo test --release -p xcl --lib gpu::dxil::lower_gfx::tests -- --nocapture`): 2 passed, 0 failed (`dxil 1.9.2609.5` validation + IR checks + GPU draw parity vs HLSL). - Post-fix targeted tests on WARP (`XCL_ADAPTER="Microsoft Basic Render Driver"`): 2 passed, 0 failed (`ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits` ran and passed; `gpu_ps_interp_int_component_types_match_hlsl` cleanly skipped via `draw_ready()` with `SKIPPED ...: no GPU`). - Full release workspace build & test (`cargo build --release --workspace` and `cargo test --release --workspace -- --test-threads=4 --nocapture`): 1,156 passed, 0 failed, 46 ignored across 21 test binaries (`1100` in `xcl` lib, `56` across the remaining 20 binaries), with 27 `SKIPPED` lines on this RTX 4060: - 20 `no wave64` (RTX 4060 is wave32-only) - 3 `per-lane form: refused` (wave32 f16 arithmetic, f16 packed, f32 conversions) - 2 `no d3d12SDKLayers.dll` / `no D3D12 debug layer` - 1 `cannot disable the driver cache` (Windows Developer Mode not enabled) - 1 `no heap windows` **Regression run** Paired 60 s runs via `scripts/smoke.ps1` on clean `origin/main` (`6987e496`) and clean PR head (`36e1c899`): Main (`6987e496c35653f9ccc9dbdc1f1d342734306811`): ``` xcl-smoke v1 commit: 6987e496c35653f9ccc9dbdc1f1d342734306811 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: 14479 MB ``` PR (`36e1c89959d237dc7ea753a42d6c6edaebc1471b`): ``` xcl-smoke v1 commit: 36e1c89959d237dc7ea753a42d6c6edaebc1471b gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1565 (PresentX 1565) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14508 MB ``` **Not tested** - Native wave64 GPU execution (20 `no wave64` skips on RTX 4060), D3D12 debug layer tests (2 skips without `d3d12SDKLayers.dll`), driver cache disable toggle (1 skip without Windows Developer Mode), and heap-window OOM fallback (1 skip without `XCL_HEAP_WINDOWS`). - Retail titles other than `title: 29640639`, and direct DXIL graphics mode (`XCL_DIRECT_DXIL=all`) on a retail title shader using `v_interp_p2_*` on integer ISG1 attributes. **AI use** Google Antigravity (Gemini 4 Neon) wrote the `interp_gfx` fix, regression tests, and this PR description. All pre-fix/post-fix CPU and GPU tests, WARP skip checks, full release workspace tests, paired 60 s smoke runs, and `scripts/pr_check.py --local` validation were run locally on this machine.
Match the HLSL recompiler (recomp/emit.rs) in Lw::interp_gfx:
- Store each PS input's DXBC component_type (u32) in GfxCtx::ps_in
  instead of a bool.
- Convert UINT (1) with CastOp::UIToFP and SINT (2) with
  CastOp::SIToFP to f32 for v_interp_p2_f32 and v_interp_p2_f16
  before bitcasting/converting to f16, instead of returning raw
  integer bits.
- Keep raw bitcast for v_interp_mov_f32 (preserving integer selector
  bits as in #249).

Part of #1269

Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:19:12 +00:00
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:00 UTC · original

Tested

Both focused fixtures passed on STOR-WINLAB at 36e1c89959d237dc7ea753a42d6c6edaebc1471b. PR #2112 was open at that SHA before and after the run. The checkout was clean and detached both times. xcl-dev/xcl #2112

  • CPU/DXC — All 11 cases ran and passed DXIL validation and IR checks. They covered p2_f32 for UINT, SINT, and F32, p2_f16 low and high halves for UINT and SINT plus the low half for F32, and mov_f32 for UINT, SINT, and F32.
  • Arc A770 — Both draw cases ran. HLSL pixel 0 matched the exact expected RGBA values, and the full 4×4 direct DXIL output matched HLSL in each case. p2_f32 plus raw-bit mov_f32 produced [5.0, -3.0, 1.0, -2.5]. p2_f16 with UINT in the low half and SINT in the high half produced [7.0, -4.0, 7.0, -4.0].
  • Totals — 2 passed, 0 failed, 0 ignored, 0 skipped. Each invocation filtered 1,125 out (CPU 0.06 s, GPU 0.88 s). Build, CPU fixture, GPU fixture, and Arc wrapper all exited 0.

Intel Arc A770 driver 32.0.101.9175, Ryzen 7 3800X, Windows 11 Enterprise Evaluation x64 build 26200.9974, Rust and Cargo 1.100.0 (x86_64-pc-windows-msvc), DXC/DXIL 1.9.2609.5. The unoptimized build used two jobs, with incremental compilation and debug info disabled.

cargo test --locked -p xcl --lib --no-run

$exe = 'L:/XclTooling/pr2011-990b9d4-t3-76a0502d/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe'
$env:XCL_DXC_DIR = "$env:LOCALAPPDATA/XclTooling/dxc-1.9.2609/bin/x64"
& $exe 'gpu::dxil::lower_gfx::tests::ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits' --exact --nocapture --test-threads=1

# GPU invocation ran in a fresh PowerShell process with -ExecutionPolicy RemoteSigned.
$env:XCL_ADAPTER = 'A770'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & $exe 'gpu::dxil::lower_gfx::tests::gpu_ps_interp_int_component_types_match_hlsl' --exact --nocapture --test-threads=1
}

Not tested — Full workspace suite, retail-title smoke runs, other adapters, or native wave64 execution.

AI use — T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixtures and prepared this report.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/2112#issuecomment-7153358693) **Tested** Both focused fixtures passed on STOR-WINLAB at `36e1c89959d237dc7ea753a42d6c6edaebc1471b`. PR #2112 was open at that SHA before and after the run. The checkout was clean and detached both times. [xcl-dev/xcl #2112](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2112) - **CPU/DXC** — All 11 cases ran and passed DXIL validation and IR checks. They covered `p2_f32` for UINT, SINT, and F32, `p2_f16` low and high halves for UINT and SINT plus the low half for F32, and `mov_f32` for UINT, SINT, and F32. - **Arc A770** — Both draw cases ran. HLSL pixel 0 matched the exact expected RGBA values, and the full 4×4 direct DXIL output matched HLSL in each case. `p2_f32` plus raw-bit `mov_f32` produced `[5.0, -3.0, 1.0, -2.5]`. `p2_f16` with UINT in the low half and SINT in the high half produced `[7.0, -4.0, 7.0, -4.0]`. - **Totals** — 2 passed, 0 failed, 0 ignored, 0 skipped. Each invocation filtered 1,125 out (CPU 0.06 s, GPU 0.88 s). Build, CPU fixture, GPU fixture, and Arc wrapper all exited `0`. Intel Arc A770 driver `32.0.101.9175`, Ryzen 7 3800X, Windows 11 Enterprise Evaluation x64 build `26200.9974`, Rust and Cargo `1.100.0` (`x86_64-pc-windows-msvc`), DXC/DXIL `1.9.2609.5`. The unoptimized build used two jobs, with incremental compilation and debug info disabled. ```powershell cargo test --locked -p xcl --lib --no-run $exe = 'L:/XclTooling/pr2011-990b9d4-t3-76a0502d/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe' $env:XCL_DXC_DIR = "$env:LOCALAPPDATA/XclTooling/dxc-1.9.2609/bin/x64" & $exe 'gpu::dxil::lower_gfx::tests::ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits' --exact --nocapture --test-threads=1 # GPU invocation ran in a fresh PowerShell process with -ExecutionPolicy RemoteSigned. $env:XCL_ADAPTER = 'A770' & 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { & $exe 'gpu::dxil::lower_gfx::tests::gpu_ps_interp_int_component_types_match_hlsl' --exact --nocapture --test-threads=1 } ``` **Not tested** — Full workspace suite, retail-title smoke runs, other adapters, or native wave64 execution. **AI use** — T3 Code / Codex (`gpt-6.2-sol`) ran the checked-in fixtures and prepared this report.
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 05:24 UTC · original

Tested: gpu_ps_interp_int_component_types_match_hlsl passes on an AMD D3D12 driver and on an RTX 3060 (adds to the Arc A770 run above).

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010): ok. Whole gpu:: filter: 586 passed, 2 failed, 22 ignored. The 2 failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way on main.
  • RTX 3060 (driver 32.0.16.1088): ok. 588 passed, 0 failed, 22 ignored.

Head 36e1c89 applied on main 6020a33, cargo test -p xcl --lib -- gpu:: --test-threads=4 with XCL_ADAPTER set to each card.
Not tested: native wave64 pixel shaders (the new test does not ask for them), retail runs.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-25 05:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2112#issuecomment-7153743512) Tested: `gpu_ps_interp_int_component_types_match_hlsl` passes on an AMD D3D12 driver and on an RTX 3060 (adds to the Arc A770 run above). - RX 9070 XT (RDNA4, driver 32.0.32029.2010): ok. Whole `gpu::` filter: 586 passed, 2 failed, 22 ignored. The 2 failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way on `main`. - RTX 3060 (driver 32.0.16.1088): ok. 588 passed, 0 failed, 22 ignored. Head `36e1c89` applied on `main` `6020a33`, `cargo test -p xcl --lib -- gpu:: --test-threads=4` with `XCL_ADAPTER` set to each card. Not tested: native wave64 pixel shaders (the new test does not ask for them), retail runs. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 06:02 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 06:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/2112#issuecomment-7154385905) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠JoaoPauluu on GitHub · 2026-11-25 06:12 UTC · original

A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, not the native-Windows path: this PR's 2 new tests pass, none skipped.

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, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. 36e1c89 as it is (merge base with main 6987e49), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • gpu_ps_interp_int_component_types_match_hlsl: ok
    • ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits: ok

Not tested

  • the whole suite on this head, a retail title, native Windows, AMD.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
**@⁠JoaoPauluu** on GitHub · 2026-11-25 06:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/2112#issuecomment-7154545104) A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, not the native-Windows path: this PR's 2 new tests pass, none skipped. **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, DXC 1.9.2609.5. Release, cross-built for `x86_64-pc-windows-gnu`. `36e1c89` as it is (merge base with `main` `6987e49`), no uncommitted changes. The lib test binary runs under Wine, one test per process. - `gpu_ps_interp_int_component_types_match_hlsl`: ok - `ps_interp_p2_converts_int_inputs_and_mov_keeps_raw_bits`: ok **Not tested** - the whole suite on this head, a retail title, native Windows, AMD. **AI use** - Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2112/head:github-bot/gh-2112'
git switch 'github-bot/gh-2112'

Merge

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