Direct DXIL: sign-extend D16 image_store halves for SINT textures #1920

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

@⁠emirduran707 on GitHub · 2026-11-24 23:10 UTC · original
emirduran707:dxil-image-store-d16-sint → main · +38 −1 · 2 files · 1 commits · open

In the Direct DXIL translator, image_store with D16=1 unpacked each 16-bit half with & 0xFFFF and passed it unchanged to the RWTexture<int4> store for SINT formats. A negative half such as -1 (0xFFFF) became 65535, and the R16 SINT store clamped it to 32767. The D16 buffer_store_format_* path in lower_mem.rs already sign-extends SINT halves with sx16; image_store now does the same when the T# format class is SINT. (#1194 makes the same change in the HLSL recompiler, recomp/emit.rs; this is the Direct DXIL path.)

What is in it

  • crates/xcl/src/gpu/dxil/lower_image.rs: in the D16 store arm, select sx16(half) when the format class is SINT (2).
  • crates/xcl/src/gpu/dxil/core_tests.rs: GPU test gpu_direct_image_store_d16_sint_sign_extends: lane 0 stores the halves (-1, -100, 42, -32768) to a 16_16_16_16_SINT texture with D16 and the test checks the texture contents.

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on a1e0ee8 (rebased onto main 2aa2d1a): 1136 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record)
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3) fail identically on unmodified main 2aa2d1a on this GPU (seeds 722 and 1599).
  • gpu_direct_image_store_d16_sint_sign_extends before the change failed (left: [32767, 32767, 42, 32767], right: [-1, -100, 42, -32768]); passes after

Regression run

main:

xcl-smoke v1
commit: 2aa2d1a54396885bb5bfce8edef4285cf24803c2
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1540 (PresentX 1540)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20525 MB

this PR:

xcl-smoke v1
commit: a1e0ee891c99b353c1d9ffabcdc8d6fa196e711f
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1537 (PresentX 1537)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20110 MB

Not tested

  • NVIDIA and Intel GPUs.
  • The smoke title's run is a regression check only.

AI use

  • Antigravity with Gemini 4 Neon and Claude Opus 5.5: found the bug, wrote the fix, GPU test and this description, and ran the test suite and smoke runs above.
  • Claude Code with Claude Opus 5.5: rebased the change onto main 2aa2d1a (a conflict in crates/xcl/src/gpu/dxil/core_tests.rs; both tests kept, this PR's now beside ps_get_lod_with_a_static_sampler) and reran the suite and smoke runs above.
**@⁠emirduran707** on GitHub · 2026-11-24 23:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/1920) `emirduran707:dxil-image-store-d16-sint` → `main` · +38 −1 · 2 files · 1 commits · open In the Direct DXIL translator, `image_store` with `D16=1` unpacked each 16-bit half with `& 0xFFFF` and passed it unchanged to the `RWTexture<int4>` store for SINT formats. A negative half such as -1 (`0xFFFF`) became 65535, and the R16 SINT store clamped it to 32767. The D16 `buffer_store_format_*` path in `lower_mem.rs` already sign-extends SINT halves with `sx16`; `image_store` now does the same when the T# format class is SINT. (#1194 makes the same change in the HLSL recompiler, `recomp/emit.rs`; this is the Direct DXIL path.) **What is in it** - `crates/xcl/src/gpu/dxil/lower_image.rs`: in the D16 `store` arm, select `sx16(half)` when the format class is SINT (2). - `crates/xcl/src/gpu/dxil/core_tests.rs`: GPU test `gpu_direct_image_store_d16_sint_sign_extends`: lane 0 stores the halves (-1, -100, 42, -32768) to a 16_16_16_16_SINT texture with D16 and the test checks the texture contents. **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4` on a1e0ee8 (rebased onto `main` `2aa2d1a`): 1136 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu`; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`) - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1`, `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3`) fail identically on unmodified `main` `2aa2d1a` on this GPU (seeds 722 and 1599). - `gpu_direct_image_store_d16_sint_sign_extends` before the change failed (`left: [32767, 32767, 42, 32767]`, `right: [-1, -100, 42, -32768]`); passes after **Regression run** main: ``` xcl-smoke v1 commit: 2aa2d1a54396885bb5bfce8edef4285cf24803c2 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1540 (PresentX 1540) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 20525 MB ``` this PR: ``` xcl-smoke v1 commit: a1e0ee891c99b353c1d9ffabcdc8d6fa196e711f gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1537 (PresentX 1537) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 20110 MB ``` **Not tested** - NVIDIA and Intel GPUs. - The smoke title's run is a regression check only. **AI use** - Antigravity with Gemini 4 Neon and Claude Opus 5.5: found the bug, wrote the fix, GPU test and this description, and ran the test suite and smoke runs above. - Claude Code with Claude Opus 5.5: rebased the change onto `main` `2aa2d1a` (a conflict in `crates/xcl/src/gpu/dxil/core_tests.rs`; both tests kept, this PR's now beside `ps_get_lod_with_a_static_sampler`) and reran the suite and smoke runs above.
`image_store` with D16 unpacked each 16-bit half with `& 0xFFFF` and passed
it unchanged to the `RWTexture<int4>` store for SINT formats, so a negative
half such as -1 (0xFFFF) became 65535 and the R16 SINT store clamped it to
32767. Sign-extend the half when the T# format class is SINT, as the D16
`buffer_store_format_*` path in `lower_mem.rs` already does.

Assisted-by: Antigravity (Gemini 4 Neon, Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:41 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 23:15 UTC · original

NVIDIA counterpart to the Radeon run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, c56f06d on main 689f2db. gpu_direct_image_store_d16_sint_sign_extends and the other tests matching d16: 4 passed, 0 failed, with and without XCL_DIRECT_DXIL=1.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 23:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1920#issuecomment-7147192980) NVIDIA counterpart to the Radeon run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `c56f06d` on `main` `689f2db`. `gpu_direct_image_store_d16_sint_sign_extends` and the other tests matching `d16`: 4 passed, 0 failed, with and without `XCL_DIRECT_DXIL=1`. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

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

Both AMD and NVIDIA verification look good on c56f06d. This is currently DIRTY with merge conflicts against main — please rebase onto main and let Build and test (Windows, no GPU) run cleanly so we can merge.

**@⁠raylitebull** on GitHub · 2026-11-25 01:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1920#issuecomment-7149238999) Both AMD and NVIDIA verification look good on `c56f06d`. This is currently `DIRTY` with merge conflicts against `main` — please rebase onto `main` and let `Build and test (Windows, no GPU)` run cleanly so we can merge.
Author
Owner

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

Build and test (Windows, no GPU) and PR description both passed on 5f0e965, and #1922 just landed on main touching the same spot at the end of crates/xcl/src/gpu/dxil/core_tests.rs. Please rebase onto main to clear the DIRTY conflict so we can merge.

**@⁠raylitebull** on GitHub · 2026-11-25 01:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/1920#issuecomment-7149737581) `Build and test (Windows, no GPU)` and `PR description` both passed on `5f0e965`, and `#1922` just landed on `main` touching the same spot at the end of `crates/xcl/src/gpu/dxil/core_tests.rs`. Please rebase onto `main` to clear the `DIRTY` conflict so we can merge.
Author
Owner

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

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (crates/xcl/src/gpu/dxil/core_tests.rs) — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 02:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/1920#issuecomment-7150715356) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** (`crates/xcl/src/gpu/dxil/core_tests.rs`) — needs a rebase before it can be tested.
Author
Owner

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

Tested

I ran gpu_direct_image_store_d16_sint_sign_extends on Intel Arc A770 at clean PR head a1e0ee891c99b353c1d9ffabcdc8d6fa196e711f. The test builds the kernel with direct_kernel_full, validates its DXIL, dispatches that same DXIL on D3D12, and reads the signed texture back. The GPU readback assertion matched all four channels of texel (0, 0), RGBA [-1, -100, 42, -32768] in R16G16B16A16_SINT. The other 15 texels read back as zero. This exercises ordinary signed D16 store conversion on the direct DXIL backend. PR #1920

Intel Arc A770 driver 32.0.101.9175, AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation 25H2 build 26200.9974, Rust 1.100.0 (x86_64-pc-windows-msvc), DXC and DXIL 1.9.2609.5. Cargo test profile with debug info and incremental compilation disabled.

$env:RUSTUP_TOOLCHAIN = 'stable-x86_64-pc-windows-msvc'
$env:CARGO_BUILD_JOBS = '2'
$env:CARGO_INCREMENTAL = '0'
$env:CARGO_PROFILE_DEV_DEBUG = '0'
$env:CARGO_PROFILE_TEST_DEBUG = '0'
$env:CARGO_TARGET_DIR = 'L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target'
$env:TEMP = 'L:/XclTooling/pr1920/temp'
$env:TMP = $env:TEMP
$env:XCL_ADAPTER = 'A770'
$env:XCL_DXC_DIR = 'C:/Users/ljensen/AppData/Local/XclTooling/dxc-1.9.2609/bin/x64'
cargo test -p xcl --lib --no-run --locked -j 2 --message-format=json-render-diagnostics
$env:XCL_PR1920_TEST_EXE = 'L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe'
$env:XCL_REQUIRE_GPU = 'wave64'
$child = @'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -WaitMinutes 30 -Test { & $env:XCL_PR1920_TEST_EXE 'gpu::dxil::core_tests::gpu_direct_image_store_d16_sint_sign_extends' --exact --nocapture --test-threads=1 }
exit $LASTEXITCODE
'@
& "$PSHOME/powershell.exe" -NoProfile -ExecutionPolicy RemoteSigned -Command $child

The prebuild exited 0 outside the Arc lock. The GPU invocation acquired and released the lock and exited 0 in 1.88 s of test execution with 1 passed, 0 failed, 0 ignored, 0 skipped and 1,114 filtered out. The exact shader backend and values are verified by the fixture and its passing readback assertions. The PR was still open at the same head after the run. Seven visible comment blocks contained no comparable Arc A770 result.

Not tested

HLSL #1194, normalized texture loads, other signed formats and masks, a pre-fix baseline, the workspace suite, retail smoke, and other GPU vendors.

AI use

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

**@⁠JJAutoCompare** on GitHub · 2026-11-25 03:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1920#issuecomment-7151679956) ## Tested I ran `gpu_direct_image_store_d16_sint_sign_extends` on Intel Arc A770 at clean PR head `a1e0ee891c99b353c1d9ffabcdc8d6fa196e711f`. The test builds the kernel with `direct_kernel_full`, validates its DXIL, dispatches that same DXIL on D3D12, and reads the signed texture back. The GPU readback assertion matched all four channels of texel (0, 0), RGBA `[-1, -100, 42, -32768]` in `R16G16B16A16_SINT`. The other 15 texels read back as zero. This exercises ordinary signed D16 store conversion on the direct DXIL backend. [PR #1920](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1920) Intel Arc A770 driver `32.0.101.9175`, AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation 25H2 build `26200.9974`, Rust `1.100.0` (`x86_64-pc-windows-msvc`), DXC and DXIL `1.9.2609.5`. Cargo test profile with debug info and incremental compilation disabled. ```powershell $env:RUSTUP_TOOLCHAIN = 'stable-x86_64-pc-windows-msvc' $env:CARGO_BUILD_JOBS = '2' $env:CARGO_INCREMENTAL = '0' $env:CARGO_PROFILE_DEV_DEBUG = '0' $env:CARGO_PROFILE_TEST_DEBUG = '0' $env:CARGO_TARGET_DIR = 'L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target' $env:TEMP = 'L:/XclTooling/pr1920/temp' $env:TMP = $env:TEMP $env:XCL_ADAPTER = 'A770' $env:XCL_DXC_DIR = 'C:/Users/ljensen/AppData/Local/XclTooling/dxc-1.9.2609/bin/x64' cargo test -p xcl --lib --no-run --locked -j 2 --message-format=json-render-diagnostics $env:XCL_PR1920_TEST_EXE = 'L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe' $env:XCL_REQUIRE_GPU = 'wave64' $child = @' & 'L:/XclTooling/Invoke-ArcTest.ps1' -WaitMinutes 30 -Test { & $env:XCL_PR1920_TEST_EXE 'gpu::dxil::core_tests::gpu_direct_image_store_d16_sint_sign_extends' --exact --nocapture --test-threads=1 } exit $LASTEXITCODE '@ & "$PSHOME/powershell.exe" -NoProfile -ExecutionPolicy RemoteSigned -Command $child ``` The prebuild exited 0 outside the Arc lock. The GPU invocation acquired and released the lock and exited 0 in **1.88 s of test execution** with **1 passed, 0 failed, 0 ignored, 0 skipped** and 1,114 filtered out. The exact shader backend and values are verified by the fixture and its passing readback assertions. The PR was still open at the same head after the run. Seven visible comment blocks contained no comparable Arc A770 result. ## Not tested HLSL #1194, normalized texture loads, other signed formats and masks, a pre-fix baseline, the workspace suite, retail smoke, and other GPU vendors. ## AI use T3 Code / Codex (`gpt-6.2-sol`) ran the test and wrote this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 00:42 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 00:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/1920#issuecomment-7179038175) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
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/1920/head:github-bot/gh-1920'
git switch 'github-bot/gh-1920'

Merge

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