Recompiler: preserve odd high half and saturate ints in D16 FormatLoad #1977
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1977
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1977"
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?
@n-romanovich on GitHub · 2026-11-25 00:17 UTC · original
n-romanovich:recomp/format-load-d16-sat-odd-hi→main· +108 −18 · 3 files · 1 commits · openAddresses #1488 (
XCL-BT-020).In
BufKind::FormatLoadwithd16_format:d16_x,d16_xyz) previously overwrote the entire 32-bitvdstwith0in[31:16], clobbering packed upper-half register state instead of preserving(vdst & 0xFFFF0000u).UINTandSINTformats previously truncated via& 0xFFFFuinstead of saturating to[0, 65535]/[-32768, 32767].What is in it
crates/xcl/src/gpu/recomp/emit.rs: preservevdst[31:16]on odd trailingd16channels and saturateUINT/SINTvalues to 16-bit bounds.crates/xcl/src/gpu/recomp/tests.rs: add GPU testgpu_buffer_load_format_d16_odd_hi_and_int_sat.Tested
Hardware: Windows 11 x64, NVIDIA GeForce RTX 5060 Ti.
cargo test -p xcl --lib format_d16 -- --test-threads=4: 2 passed, 0 failed, 0 ignored (968 filtered out)cargo test --workspace -- --test-threads=4: 994 passed, 0 failed, 45 ignoredSKIPPED: 22gpu::recompwave64 / refused per-lane f16 tests (no wave64/ refused per-lane f16),shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode is required,0x887A002D),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)Regression run
Main (
5478c4a7c1ae5adba127c8d27018d7fdbf3a8725):PR (
ef4642a48ca821f982bb76139da851f1482d1933):Not tested
AI use
smoke.ps1runs.@futurepro62 on GitHub · 2026-11-25 00:32 UTC · original · edited 2026-11-25 00:45 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
b4d05e5(on its base80f4819).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::dxil::fuzz_tests: 983 passed, 0 failed, 43 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_buffer_load_format_d16_odd_hi_and_int_sat.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 993 passed, 0 failed, 45 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 main80f4819too, 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 andconst_and_null_mask_operands_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
@upipibi on GitHub · 2026-11-25 00:56 UTC · original
Here's the direct-translator half, in case it saves you time. It applies on
b4d05e5and touches onlycrates/xcl/src/gpu/dxil/lower_mem.rs:d16_inthelper that saturates a 32-bit UINT channel to0xFFFFand a SINT one to-32768..32767, as youremit.rschange does;& 0xFFFF;d16_xin the single-component path, and the last dword ofd16_xyz), instead of writing 0.RTX 3070 (Ampere, driver 616.56, Windows 11, debug) with it applied:
cargo test -p xcl --lib -- d16withXCL_DIRECT_DXIL=1and0: 4 passed each, includinggpu_buffer_load_format_d16_odd_hi_and_int_sat, which failed withleft: 4464before.gpu_tests withXCL_DIRECT_DXIL=1: 112 passed, 0 failed.dxil::units: 120 passed.It changes the direct translator's containers, so
TRANSLATOR_VERSIONneeds a bump unless #1947 lands first.patch
AI-assisted (Claude Code). Synthetic tests only.
@upipibi on GitHub · 2026-11-25 00:34 UTC · original · edited 2026-11-25 01:00 UTC
On an RTX 3070 (Ampere, driver 616.56, Windows 11, debug) at
b4d05e5, the new test fails with the direct translator:XCL_DIRECT_DXIL=0:gpu_tests 112 passed, includinggpu_buffer_load_format_d16_odd_hi_and_int_sat.XCL_DIRECT_DXIL=1: 111 passed, 1 failed:4464is0x0000_1170: 70000 truncated to 16 bits, with the high half zeroed, which is the old behaviour.The direct translator has its own copy of this packing in
crates/xcl/src/gpu/dxil/lower_mem.rs, in both D16 branches of the format load (around lines 1331 and 1357). It still doeslw.andc(s, 0xFFFF)for integers and useszfor an odd trailing high half. The same two changes are needed there for the test to pass on both paths.Two related points, in case they belong here or in a follow-up:
D16 reads of 32-bit float texels round toward zero on RDNA2 …Correction: measured since: on D3D12,f32tof16rounds to nearest.f32tof16already rounds toward zero. On the RTX 3070 (616.56) and on WARP, an R32G32B32A32_FLOAT texel read with D16 gives0x3c01for1 + 3·2⁻¹¹,0x7bfffor 70000 and0xfbfffor −70000, on both paths, with no change. That's RDNA2's result. AnyPS5's case was Vulkan'spackHalf2x16. Nothing to do here for floats.The rest of the batch matches
main:dxil::units pass (120).AI-assisted (Claude Code). Synthetic tests only.
@raylitebull on GitHub · 2026-11-25 01:08 UTC · original
Diff audit passed on the HLSL side (
emit.rs+tests.rsonb4d05e5), which passesXCL_DIRECT_DXIL=0on NVIDIA and AMD, but as @upipibi and @DarkPanda69 observed,gpu_buffer_load_format_d16_odd_hi_and_int_satfails withXCL_DIRECT_DXIL=1becausegpu/dxil/lower_mem.rsstill truncates instead of saturating and zeros the high half.Next step: fold in the
lower_mem.rscounterpart and run both backends across AMD + NVIDIA + CI.@n-romanovich on GitHub · 2026-11-25 01:19 UTC · original
@raylitebull, updated
d39aea9to apply the sameD16FormatLoadfix incrates/xcl/src/gpu/dxil/lower_mem.rs(both thesingle_compfast-path and the generald16_formatpaths). BothXCL_DIRECT_DXIL=1andXCL_DIRECT_DXIL=0passformat_d16(2 passed; 0 failed), and thexcl-smokeblock has been updated in the PR description.@raylitebull on GitHub · 2026-11-25 01:21 UTC · original
Diff audit passed on the
lower_mem.rsdirect-DXILD16FormatLoadchanges ind39aea9, and CI (Build and test+PR description) is green.Remaining before merge: one independent AMD GPU confirmation on
d39aea9(covering bothXCL_DIRECT_DXIL=0and1).@JJAutoCompare on GitHub · 2026-11-25 01:32 UTC · original
Tested
Independent Intel Arc A770 run on clean PR head
d39aea9e3ceebe66c052e1d17ac872ac447ee44d. Arc driver 32.0.101.9175, AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation 26200.9974, Rust 1.100.0x86_64-pc-windows-msvc, DXC and DXIL 1.9.2609.5. Debug test profile with debug info and incremental compilation disabled.Prebuilt with
cargo test --locked -p xcl --lib -j 2 --no-run. WithXCL_ADAPTER=A770,XCL_DXC_DIRset to the explicit DXC 1.9.2609 x64 directory, andXCL_REQUIRE_GPU=wave64to fail on a missing GPU prerequisite, ran the Cargo-built test executable under the shared Arc mutex:XCL_DIRECT_DXIL=0)XCL_DIRECT_DXIL=1, no fallback)Both runs checked that
d16_xpreserves the destination's upper half while saturating UINT and SINT, and thatd16_xypacks signed values saturated at both limits.Not tested
Full workspace suite, retail smoke, release, AMD/NVIDIA adapters,
d16_xyz, and normalized buffer or image conversions.AI use
Codex (
gpt-6.2-sol) ran the tests and wrote this report.@upipibi on GitHub · 2026-11-25 02:36 UTC · original
Re-checked
d39aea9on the RTX 3070 (driver 616.56, Windows 11, debug):gpu_buffer_load_format_d16_odd_hi_and_int_satand the otherformat_d16test now pass with bothXCL_DIRECT_DXIL=0and1. The direct-translator failure from before (left: 4464) is gone.AI-assisted (Claude Code).
@DavidM1911 on GitHub · 2026-11-25 03:19 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!
@luckyteagirl on GitHub · 2026-11-25 08:46 UTC · original
Independent native Windows RDNA2 check on exact head
4a736a0635bbbeadff102add99fe28aa3eaa80ef(base568e7db7729c8fa6c8f0f4b32d798faaf11462bb), clean detached worktree.Environment: Windows 11 build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M (native wave64), driver
30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. I setXCL_ADAPTER=6800M,XCL_REQUIRE_GPU=wave64, and the matchingXCL_DXC_DIR.cargo test --locked -p xcl --lib -j 2 gpu_buffer_load_format_d16_odd_hi_and_int_sat -- --test-threads=1 --show-outputpassed with 1 passed, 0 failed, 0 ignored, no explicit skip in each mode:XCL_DIRECT_DXIL=0(HLSL/DXC)XCL_DIRECT_DXIL=1(direct DXIL)The checked-in GPU test covers 32_UINT saturation of 70,000 to
0xffff, 32_SINT saturation of ±40,000 to0x7fff/0x8000, and retention of the odd trailing high half (0x5a5a/0xbeef). This gives the requested independent AMD confirmation on the current head, including the direct-DXIL counterpart.Scope: Focused debug test only. I did not run the full workspace suite, a main-vs-PR control, or a retail-title smoke on this branch.
AI use: OpenAI Codex inspected the regression test, ran both GPU backends, checked the no-skip logs and exact revision, and prepared this report.
@raylitebull on GitHub · 2026-11-25 11:06 UTC · original
Heads-up on
ef4642a: CI45599902031passed everything except the two currentorigin/maintest breaks (pso.rs:1360anddevice_x.rs:1376), andPR descriptionfailed because the PR body's Regression run smoke block still points at4a736a0instead ofef4642a.Updating the Regression run block to match
ef4642a(and re-confirming an AMD check onef4642aonceorigin/mainCI is green) will get this ready for merge.@DarkPanda69 on GitHub · 2026-11-25 00:46 UTC · original · edited 2026-11-25 11:08 UTC
Update for head
ef4642a: still fixed on both paths. Applied onmainf087b99,gpu_buffer_load_format_d16_odd_hi_and_int_satpasses on the RX 9070 XT and the RTX 3060 withXCL_DIRECT_DXIL=0and=1. Wholegpu::filter: RTX 3060 629 passed, 1 failed; RX 9070 XT 626 passed, 4 failed. All the failures are onmainwithout this PR:rerouted_disk_entries_follow_the_direct_translatoron both cards (reported on #2120), and on the RX 9070 XTgpu_image_get_resinfo_past_last_level(reported on #2054) plus the fuzz seeds tracked in #2115.Update for head
d39aea9: fixed on both paths.cargo test -p xcl --lib -- gpu_buffer_load_format_d16_odd_hi_and_int_satat the head itself passes on the RX 9070 XT and the RTX 3060 withXCL_DIRECT_DXIL=0and withXCL_DIRECT_DXIL=1. (This head no longer applies as a patch onmain3da2abb, so it was tested as is.)Confirming the direct-translator failure above on two more GPUs, so it is the
lower_mem.rscopy and not one card:Head
b4d05e5applied onmain6567c5f, debug, Windows 11 Pro 26200.cargo test -p xcl --lib -- gpu_buffer_load_format_d16_odd_hi_and_int_sat:XCL_DIRECT_DXIL=0XCL_DIRECT_DXIL=1left: 4464,right: 1515913215With the default path, the full
cargo test -p xcl --lib -- gpu::run with this PR is 465 passed on the RX 9070 XT (the 2 fuzz failures there are the same onmainon this card) and 467 passed, 0 failed on the RTX 3060.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@n-romanovich on GitHub · 2026-11-25 11:32 UTC · original
@raylitebull, updated the Regression run block - ready for merge.
@DavidM1911 on GitHub · 2026-11-26 06:51 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.ef4642a48cto4546bae9e5github-bot referenced this pull request2026-11-26 11:17:26 +00:00
@ClosetPie107 on GitHub · 2026-11-26 12:24 UTC · original
AMD RX 9070 (RDNA4, RADV / Linux) test report on
4546bae9Setup
experimental-11.0-20261112), DXVKv3.1.1-209, patched vkd3d-protonmaster(ec207194,dxil-spirvb540c8a2), DXC1.9.2609.5x86_64-pc-windows-gnubuildTested
xcl-<hash>.exe format_d16 --test-threads=1,XCL_ADAPTER=9070): 2 passed, 0 failed, 0 ignored, 0 skipped (peak VRAM705 MiB) — bothbuffer_format_d16_packs_and_unpacks_halvesandgpu_buffer_load_format_d16_odd_hi_and_int_satpassed.XCL_DIRECT_DXIL=1, same command): 2 passed, 0 failed, 0 ignored, 0 skipped (peak VRAM706 MiB).Not tested
4546bae9, Windows, NVIDIA, retail game run.AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.