Direct DXIL: sign-extend D16 image_store halves for SINT textures #1910
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1920"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-24T23:10:46Z.
In the Direct DXIL translator,
image_storewithD16=1unpacked each 16-bit half with& 0xFFFFand passed it unchanged to theRWTexture<int4>store for SINT formats. A negative half such as -1 (0xFFFF) became 65535, and the R16 SINT store clamped it to 32767. The D16buffer_store_format_*path inlower_mem.rsalready sign-extends SINT halves withsx16;image_storenow 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 D16storearm, selectsx16(half)when the format class is SINT (2).crates/xcl/src/gpu/dxil/core_tests.rs: GPU testgpu_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
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4ona1e0ee8(rebased ontomain2aa2d1a): 1136 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_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)gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3) fail identically on unmodifiedmain2aa2d1aon this GPU (seeds 722 and 1599).gpu_direct_image_store_d16_sint_sign_extendsbefore the change failed (left: [32767, 32767, 42, 32767],right: [-1, -100, 42, -32768]); passes afterRegression run
main:
this PR:
Not tested
AI use
main2aa2d1a(a conflict incrates/xcl/src/gpu/dxil/core_tests.rs; both tests kept, this PR's now besideps_get_lod_with_a_static_sampler) and reran the suite and smoke runs above.Imported from ivall/xcl. Originally posted by towiice on 2026-11-24T23:55:06Z.
Review: COMMENTED
Verified on Windows 11 (NVIDIA GeForce GTX 1650 SUPER, 4 GB Turing TU116, wave32, driver 610.88, DXC 1.9.2609.5):
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.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T23:15:25Z.
NVIDIA counterpart to the Radeon run: RTX 3070 8 GB, driver 616.56, Windows 11, debug,
c56f06donmain689f2db.gpu_direct_image_store_d16_sint_sign_extendsand the other tests matchingd16: 4 passed, 0 failed, with and withoutXCL_DIRECT_DXIL=1.AI-assisted (Claude Code). Synthetic tests only.
Imported from ivall/xcl. Originally posted by towiice on 2026-11-25T00:37:04Z.
Review: COMMENTED
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). NoSKIPPEDline was printed, so the GPU part ran here as well as the translation and validation.Not tested: the test on
mainwithout 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.
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:08:01Z.
Both AMD and NVIDIA verification look good on
c56f06d. This is currentlyDIRTYwith merge conflicts againstmain— please rebase ontomainand letBuild and test (Windows, no GPU)run cleanly so we can merge.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:36:10Z.
Build and test (Windows, no GPU)andPR descriptionboth passed on5f0e965, and#1922just landed onmaintouching the same spot at the end ofcrates/xcl/src/gpu/dxil/core_tests.rs. Please rebase ontomainto clear theDIRTYconflict so we can merge.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:26:06Z.
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.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T03:11:35Z.
Tested
I ran
gpu_direct_image_store_d16_sint_sign_extendson Intel Arc A770 at clean PR heada1e0ee891c99b353c1d9ffabcdc8d6fa196e711f. The test builds the kernel withdirect_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]inR16G16B16A16_SINT. The other 15 texels read back as zero. This exercises ordinary signed D16 store conversion on the direct DXIL backend. PR #1920Intel Arc A770 driver
32.0.101.9175, AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation 25H2 build26200.9974, Rust1.100.0(x86_64-pc-windows-msvc), DXC and DXIL1.9.2609.5. Cargo test profile with debug info and incremental compilation disabled.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.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:42:44Z.
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
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-26T17:22:44Z.
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 base2aa2d1a).Tested
cargo build --workspace, thenXCL_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.gpu_direct_image_store_d16_sint_sign_extends.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 #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #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 #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 #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 #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 #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main8b957bectoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T21:07:43Z.
merge-check claim
head:
a1e0ee891cImported from ivall/xcl. Originally posted by throny on 2026-11-28T21:36:57Z.
merge-check
base:
beeb81behead:
a1e0ee891cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2595 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at
beeb81be(main after the merge of nvidia-dev): 2594 passed, 0 failed, 49 ignored. The PR's GPU test needs native wave64 and is among the SKIPPED lines on this card (32-lane NVIDIA), so its assertion did not run here.review: no blocking finding; all hunks read. The class it tests is the signed-integer one in the store loop, and the sign-extension helper it calls is public in its module. Nothing open in the thread.
performance: none. It changes a direct-DXIL source only: users of XCL_DIRECT_DXIL (and the large compute programs routed there by default) re-translate once; the HLSL path is untouched.
verdict: safe to merge (code and merge result; the new GPU assertion itself still needs an AMD run if the thread has none on this head)
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by iggyvilla on 2026-11-29T06:16:42Z.
merge-check
base:
fa204595a4head:
a1e0ee891cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2606 passed, 3 failed, 49 ignored; failing: the same three as on the base: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, test_title_runs_and_game_folder_is_untouched (e2e), two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (re-run on the base, same signatures). The 4th
FAILEDresult line is the two-pass child's own summary.review: narrow, correct fix: in the D16 image_store arm only the float class rebuilt the half via f16_to_f32; SINT halves fell through as zero-extended u16, so -1 stored as 65535 and clamped to 32767 by the R16 SINT store. Selecting sx16(half) when img_cls == 2 matches the D16 buffer_store path in lower_mem.rs and the HLSL recompiler fix in #1194; UINT (cls 1) still passes the masked half, float (cls 0) still the converted bits, and the per-component guarded stores (U32/I32/F32 keyed on the same cls) are untouched. The new GPU test asserts exact texel contents [-1, -100, 42, -32768] plus neighbouring-texel isolation, and it RAN and passed here (not skipped). Not verified: NVIDIA/Intel GPUs and Wine/vkd3d (author tested AMD only); the load-side arm just above still zero-extends SINT halves (sel(fl, h, lo)) with no cls==2 sign extension, so a symmetric D16 load bug for SINT textures may remain — out of scope but worth a follow-up check.
performance: none by default. Compile-time only: two extra selects (sx16/cmpc/sel) in the D16 store arm of re-translated shaders; users of XCL_DIRECT_DXIL re-translate once. HLSL path untouched.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6650 XT, Windows 10.0.26300; Muse Spark 1.3 (via pi) ran the build and tests in a prepared trial-merge worktree and drafted the review/performance lines; Claude Sonnet 5.5 (Claude Code) prepared the merge worktrees, read every hunk of the diff, checked the test counts and that the PR's own tests ran and passed in the logs, edited this text and posted it.
AI use: the two models above did all of this; the account owner did not read the diff or write this text. Claude Sonnet 5.5 read the whole diff; Muse Spark 1.3 only ran the commands and drafted lines. What was not done: no game run, NVIDIA or Intel GPU, or Linux.
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-29T06:42:24Z.
Test report on Wine, both real-GPU vendors, on the now-default direct path.
Test:
gpu::dxil::core_tests::gpu_direct_image_store_d16_sint_sign_extends(this PR's new parity test), run solo (--test-threads=2default env, filter on the test name), 3 repeats per state.Tested
a1e0ee89as-is: 3/3 ok, 0.10-0.13 smainfa204595(merge18f456e5): 3/3 ok, 0.10-0.11 sa1e0ee89as-is: 3/3 ok, 0.27-0.50 sfa204595(merge597dc727): 3/3 ok, 0.28-0.30 sNote the branch base is older (
2aa2d1a5by merge-base), so the merged-onto-fa204595runs are the ones that reflect how this lands on today's direct-DXIL default; both merged without conflicts and the test stayed green on both GPUs.Not tested: native Windows, whether the test goes red without the
lower_image.rshunk (assumed by design), other D3D_FEATURE_LEVELs.AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.