Recompiler: sign-extend 16-bit SINT lanes in D16 image_store #3279
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3279"
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 Kalmarv on 2026-11-29T03:27:00Z.
What is in it
IMAGE_STOREwithD16 = 1unpacks two 16-bit lanes per VGPR, but both Direct DXIL (crates/xcl/src/gpu/dxil/lower_image.rs) and HLSL (crates/xcl/src/gpu/recomp/emit.rs) only distinguished float (cls == 0,f16_to_f32) from non-float (zero-extended 16-bit lane). For signed integer formats (SINT,cls == 2, such asR16G16B16A16_SINTorR8G8B8A8_SINT), negative 16-bit signed values were zero-extended to positive 32-bit integers (e.g.,-1as0x0000FFFF=+65535) and clamped to+32767/+127bytextureStore.crates/xcl/src/gpu/dxil/lower_image.rs): Sign-extend the 16-bit lane withsx16(hp)whencls == 2, matchingbuffer_store_format_d16inlower_mem.rs.crates/xcl/src/gpu/recomp/emit.rs): Sign-extend the 16-bit lane with(uint)(((int)(hpart << 16)) >> 16)whencls == 2.crates/xcl/src/gpu/recomp/tests.rs): Addedgpu_image_store_d16_sign_extends_sintverifying both Direct DXIL and HLSL onR16G16B16A16_SINT,R8G8B8A8_SINT,R16G16B16A16_UINT, andR16G16B16A16_FLOAT.Tested
Hardware and toolchain: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (Build 26200),
rustc 1.99.0 (b940084d7), DXC 1.9 (dxcompiler 1.9.2609.5,dxil 1.9.2609.5), debug + release builds.cargo test -p xcl --lib -- gpu_image_store_d16_sign_extends_sint gpu_image_load_reads_a_store_of_the_same_dispatch mimg_view_and_sampler_heap_indices_are_guarded --test-threads=1 --nocapture: 3 passed, 0 failed (verified all 64 texels across all 4 formats on RTX 5070 Ti for both Direct DXIL and HLSL).cargo test --workspace -- --test-threads=4: 2609 passed, 0 failed, 49 ignored (26 GPU tests reportedSKIPPED: 21no wave64, 3#1426f16 compiler refusals, 2no heap windows).Regression run
Baseline (
origin/mainancestorf0e8fdd5, 150 s on RTX 5070 Ti):This PR (
1ff6d7c2, 150 s on RTX 5070 Ti):Not tested
image_store_mip(currently unsupported in both translators).AI use
Antigravity (Gemini) assisted with auditing the D16 image-store lowering, implementing the sign-extension fix and GPU test, and formatting this PR description. All code was reviewed, built, and verified locally on RTX 5070 Ti with DXC 1.9, the full workspace test suite, and a 150 s smoke run.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:55:35Z.
Closing in favor of existing open PRs #1194 (HLSL) and #1920 (Direct DXIL), which already cover D16 SINT sign-extension for
image_store.Pull request closed