Skip to content

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

Open
emirduran707 wants to merge 1 commit into
xcl-dev:mainfrom
emirduran707:dxil-image-store-d16-sint
Open

emirduran707 wants to merge 1 commit into
xcl-dev:mainfrom
emirduran707:dxil-image-store-d16-sint

Conversation

@emirduran707

@emirduran707 emirduran707 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.

@towiice towiice left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Windows 11 (NVIDIA GeForce GTX 1650 SUPER, 4 GB Turing TU116, wave32, driver 610.88, DXC 1.9.2609.5):

  • \cargo test -p xcl --lib gpu_direct_image_store_d16_sint_sign_extends: 1 passed; 0 failed (0.58s; DXIL translation and \dxil.dll\ validation succeeded, GPU execution skipped with
    o wave64\ on Turing)

Sign-extending \hp\ via \self.sx16(hp)\ when \cls == 2\ (SINT) in \Lw::image_store\ matches the \D16\ \�uffer_store_format_*\ handling in \lower_mem.rs.

@towiice towiice left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Windows 11 (NVIDIA GeForce GTX 1650 SUPER, 4 GB Turing TU116, 32-lane waves, driver 610.88, DXC 1.9.2609.5, Rust 1.100.0 gnullvm, debug):

  • cargo test -p xcl --lib gpu_direct_image_store_d16_sint_sign_extends: 1 passed, 0 failed (0.58 s). No SKIPPED line was printed, so the GPU part ran here as well as the translation and validation.

Not tested: the test on main without the fix (to see it fail), the rest of the suite, AMD/Intel.

AI use: an AI assistant (Antigravity) ran the test and drafted this; the result is from that run.

@raylitebull

Copy link
Copy Markdown
Member

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.

@emirduran707
emirduran707 force-pushed the dxil-image-store-d16-sint branch from c56f06d to 5f0e965 Compare November 25, 2026 01:27
@raylitebull

Copy link
Copy Markdown
Member

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.

`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)
@DavidM1911

Copy link
Copy Markdown
Contributor

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.

@JJAutoCompare

Copy link
Copy Markdown

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.

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
# Conflicts:
#	crates/xcl/src/gpu/dxil/core_tests.rs
@DavidM1911

Copy link
Copy Markdown
Contributor

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

@futurepro62

Copy link
Copy Markdown

NVIDIA and AMD full-suite run, to go with the reports above by JJAutoCompare, since none of them names a GPU. Tested exact head a1e0ee89 (on its base 2aa2d1a).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1126 passed, 0 failed, 44 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: gpu_direct_image_store_d16_sint_sign_extends.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1137 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 8b957bec too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants