Recompiler: simplify typed buffer component decoding #1637
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1647"
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 coolpersonnn on 2026-11-24T18:39:49Z.
Part of #1269. Simplify the HLSL inlined for each dynamic typed-buffer component on the default translation path and the fallback from #1426. Each supported component fits in one dword, so the decoder can extract it directly, share signed and unsigned normalization, and expand the small packed floats without exponentiation.
What is in it
crates/xcl/src/gpu/recomp/emit.rsemits the smaller component decoder.crates/xcl/src/gpu/recomp/tests.rschecks the format table and verifies decoded values from unaligned buffers on the GPU at-O0and-O3.Tested
f860750on Ryzen 9 9950X3D, RTX 5090 (621.01), Windows 11 build 26300, rustc 1.100.0 and DXC 1.8.2502.11..\scripts\test.ps1withXCL_ADAPTER=nvidiareported 961 passed, 0 failed and 43 ignored. The harness reported 23 GPU skips.XCL_SAMPLE_*fixtures were unset for the rebased suite.GPU coverage skips on the rebased head
The original measurements below were taken before this rebase.
.\scripts\test.ps1withXCL_ADAPTER=nvidiaandXCL_SAMPLE_RPFset reported 860 passed, 0 failed, 42 ignored. GPU skips weregpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).9e3831e. Ranxcl shaders <dir> --precompile --only cs --windows 4 --split 1, then--pipelinesagainst the populated DXIL cache with XCL's PSO disk cache off. One format-heavy sample went from 427,204 to 386,108 DXIL bytes and from 17.04 to 13.30 s in the cold pipeline pass (median of two cold runs per build, one cached pair excluded). The giant-O0sample went from 29,750,432 to 26,752,196 bytes and from 129.72 to 118.35 s for translation plus DXC. Both driver passes exceeded 90 s.Regression run
Main
PR head
Not tested
AI use
Codex (GPT-6 family, exact model variant unavailable) profiled the workload, wrote the code and tests, ran the checks, and prepared this description.
T3 Code / Antigravity resolved the current rebase. Codex (GPT-6 family, exact model variant unavailable) verified the resolution, reran the checks, and updated this description.
Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-24T18:47:28Z.
Independent AMD check at
a632fbbd10dbd1a7e0cc03f5dc48670beee32ec0.Tested
XCL_ADAPTER='AMD Radeon'.cargo build --workspace --lockedpassed.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 860 passed, 0 failed, 42 ignored. One GPU skip is included in that pass count (heap_window_out_of_memory_falls_back_to_the_switch_form, heap windows off). The bundled title test passed.XCL_REQUIRE_GPU=wave64,mesh,cargo test --locked -p xcl --lib -- buffer_format gpu_typed_buffer_loads_and_stores --test-threads=1 --show-outputgave 5 passed, 0 failed, 0 ignored, 0 skips.c160d86ef2efe3a07e4dfb473e4fa72eafb413c0:cargo test --locked -p xcl --test typed_buffer_probe -- --exact typed_buffer_formats_across_wave_sizes_and_byte_alignments --nocapture --test-threads=1. It ran the 11 fixtures fromgpu_buffer_format_component_decode(including the invalid descriptor) at starting byte offsets 0, 1, 2 and 3, on wave32 and native wave64, at DXC-O0and-O3. Both runs passed with 0 skips. Each build matched all 33,792 expected component values bit for bit across 176 dispatches.The generated DXIL for that one synthetic dynamic-format shader was smaller in all four builds:
-O0-O3-O0-O3Not tested
Heap-window mode, retail shader packs and title smoke, compile or pipeline timings.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) adapted the temporary probe, ran the tests, and drafted this report.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T21:06:55Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by throny on 2026-11-25T09:20:34Z.
Test report for exact head
f860750.Tested
cargo build --workspace && cargo test --workspace -- --test-threads=4onf860750as it is (its own base): 961 passed, 0 failed, 43 ignored.SKIPPED: 23 lines (no wave64 on this adapter, and the like).scripts/smoke.ps1, the retail title, 60 s, release builds,main568e7dbfirst, then this head:main:
PR:
Not tested: AMD, the head merged onto current
main, a world load.AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built.
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-26T05:41:00Z.
NVIDIA and AMD full-suite run, to go with the reports above by throny, since none of them covers AMD. Tested exact head
f860750d(on its basec4d37be).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: 956 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.buffer_format_components_fit_in_one_dword,gpu_buffer_format_component_decode.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 961 passed, 0 failed, 43 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 mainb49be183too, 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 DavidM1911 on 2026-11-26T05:58:11Z.
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 Pipodi on 2026-11-30T14:38:02Z.
merge-check claim
head:
f860750d52Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T14:52:30Z.
merge-check claim
head:
f860750d52Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T14:59:05Z.
merge-check
base:
9dfbe3ea66head:
f860750d52merge: clean (trial merge 7020c6c8bcde3742d3d5ccc31b924d4d0c7981f0; git diff --check clean; +71/-17 in crates/xcl/src/gpu/recomp/emit.rs and tests.rs)
build: cargo build --workspace -> ok (39 pre-existing warnings, none from the PR's files)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2887 passed, 1 failed, 51 ignored; SKIPPED: 27 (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, pre-existing on this machine (fails identically on base
9dfbe3ea, same "2D D16 resinfo clobbered v2/v3" assertion). Both new tests pass: buffer_format_components_fit_in_one_dword (table invariant) and gpu_buffer_format_component_decode (11 format cases from an unaligned buffer at -O0 and -O3, all 32 lanes).review: read the whole diff. Behaviour-preserving simplification of the inlined HLSL component decoder: (1) fmt_comp extracts each component from the single dword that contains it instead of the cross-dword bits_at helper — sound because buf_format_info packs x first as least-significant and the new pure test pins every BUF_FORMATS component to one dword; (2) signed and unsigned normalisation share one divide, max endpoint derived from the same mask; (3) uf_small expands 10/11-bit packed floats by bit assembly ((112+e)<<23 | m<<(23-mb)) instead of exp2 — exact. Verified the test vectors by hand against the table (10_11_11_FLOAT packs x=11/y=11/z=10 LSB-first; its input word decodes to 2^-20, +INF, 1.0). Key evidence: the PR's two new tests copied verbatim into the base worktree pass there too, so the expected values match the shipped behaviour and the refactor is bit-exact on this GPU. No unsafe, no new dependencies. #1310 (same author) is a distinct change (decode only requested components) and will need a rebase against this one or vice versa.
performance: author measured smaller generated DXIL (427,204 -> 386,108 bytes on a format-heavy sample) and faster cold pipeline compilation (17.04 -> 13.30 s); smoke pair 1082 -> 1100 frames.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-30T15:30:55Z.
merge-check
base:
9dfbe3ea66head:
f860750d52merge: clean (git merge --no-ff)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2887 passed, 1 failed, 51 ignored; the lib harness aborted once (0xc0000409, known flake), so the lib binary was rerun alone (2739 passed, 1 failed, 31 ignored) and added to the other binaries (148 passed). The failure is gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 (fails on main too, fixed by #3513). 25 SKIPPED (24 "no wave64"-style GPU skips in the lib, plus heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows). Both new tests, buffer_format_components_fit_in_one_dword and gpu_buffer_format_component_decode, pass.
new tests vs the change: with emit.rs reverted to main (uncommitted) both new tests still pass (4 passed in the
buffer_formatfilter). That is expected for a refactor that must not change results: they pin the behaviour (they would catch a wrong decode, they do not fail on the old code).review: read both files (emit.rs, tests.rs). It does have a per-instruction GPU test against expected values (gpu_buffer_format_component_decode, BUFFER_LOAD_FORMAT_XYZW over 11 formats at -O0 and -O3, with an unaligned byte-1 base), as CONTRIBUTING asks, plus a table test that every component of every BUF_FORMATS entry fits inside one dword, which is the premise of dropping bits_at. Checked by hand: uf_small rebuilds the f32 from the 5-bit exponent (112+e, mantissa shifted by 23-mb; subnormal m*2^(-14-mb)), same values as before; the shared UNORM/SNORM divide keeps the exact 0 and 1 endpoints and the 32-bit maxima round to the same floats as the old constants. Nit: no case for a 24-bit or 5_6_5-type format, and none for signed 32-bit SNORM; the table test covers the one-dword premise for them.
performance: fewer ALU ops per decoded component (no two-dword funnel shift, one divide instead of two); not measured.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4090, driver 621.40; i9-13900K; Windows 11 Pro 10.0.26300; rustc 1.100.0; debug. AI use: Claude Code, Claude Opus 5.5
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:23:10Z.
Triage (#1607) – head
f860750No open or merged PR makes the same change. #1840, #1310, #1901 and #2210 also edit
fmt_compingpu/recomp/emit.rs(rounding, requested components, outlining), so they will conflict with this one, but none dropsbits_ator rewritesuf_smallthis way.Checked the rewrite: the exponent rebase (112 + e, subnormal 2^(-14-mb)) and the shared UNORM/SNORM divisor (2^w-1 / 2^(w-1)-1 via
sh + sign) match the old code; droppingbits_atrelies on every BUF_FORMATS component fitting in one dword, which the newbuffer_format_components_fit_in_one_dwordtest pins.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.