Recompiler: decode only requested components in buffer_load_format_* #1310
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!1310
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1310"
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?
@coolpersonnn on GitHub · 2026-11-24 14:34 UTC · original
coolpersonnn:recomp/format-load-selected-components→main· +134 −6 · 2 files · 1 commits · openDecode only the format components actually selected by narrow
buffer_load_format_*andtbuffer_load_format_*instructions instead of unconditionally callingfmt_compon all four channels. On format-heavy compute shaders, this cuts emitted HLSL, DXIL binary size, and DXC compile time without altering decoded semantics.What is in it
fmt_sel(uint4 r, uint info, uint sel, bool isint)right afterdst_selinPRELUDE_MEM(crates/xcl/src/gpu/recomp/emit.rs), evaluating format decoding only for channels selected bydst_sel.BufKind::FormatLoad(crates/xcl/src/gpu/recomp/emit.rs) to emitfmt_comp(uint4 {t}_c) only whenn_comp == 4, and usefmt_selwhenevern_comp < 4(includingd16loads, binding{t}_s{c}once per component before the 16-bit pack sofmt_selis not evaluated twice insideselect).buffer_load_format_decodes_only_requested_components) and a D3D12 GPU test (gpu_buffer_load_format_swizzled_narrow_loads) covering non-identityDST_SELswizzles,SEL_0/SEL_1/missing channels on float andUINTformats,TBUFFER_LOAD_FORMAT_X,D16_{X,HI_X,XYZ}(including low-half preservation), and out-of-range loads (crates/xcl/src/gpu/recomp/tests.rs).Tested
234ec72on 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.
32.0.16.2101), AMD Radeon(TM) Graphics (driver32.0.21045.29003, targeted GPU check), AMD Ryzen 9 9950X3D 16-Core Processor, Windows 11 (NT 10.0.26300.0),rustc 1.100.0(stable-x86_64-pc-windows-msvc), DXC1.8.2502.11..\scripts\test.ps1(cargo build --workspaceandcargo test --workspace -- --test-threads=4, debug):753 passed, 0 failed, 41 ignored(709lib +44integration/e2e/oracle;SKIPPEDGPU tests on RTX 5090:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64;XCL_SAMPLE_*unset/skipped).XCL_ADAPTER=radeon:cargo test -p xcl --lib gpu_buffer_load_format_swizzled_narrow_loads(1 passed, 0 failed) andcargo test -p xcl --lib gpu_typed_buffer_loads_and_stores(1 passed, 0 failed).9 x,1 xy): DXIL157184 B->141620 B(-9.9%), DXC1.07 s->1.04 s, PSO1.32 s->1.22 s(1 made, 0 refused).25 x,2 xyz): DXIL489424 B->450520 B(-7.9%), DXC4.13 s->4.18 s, PSO9.00 s->8.80 s(1 made, 0 refused).37 x,6 xy,4 xyz): DXIL1092324 B->1030584 B(-5.7%), DXC11.16 s->10.97 s, PSO47.42 s->49.19 s(1 made, 0 refused).3,281 x): DXIL29750432 B->20197536 B(-32.1%), DXC130.59 s->94.61 s(-27.5%), PSO>60.0 sbefore />120.0 safter (killed at cap).mainbaseline smoke run had a cold shader cache, whereas the PR smoke run executed after caches were warmed.Regression run
Main
PR head
Not tested
CreateComputePipelineStateon the 88.9k-instruction compute shader still exceeded the 120 s timeout cap on RTX 5090.AI use
Antigravity via T3 Code (Gemini Pro) — inspected
crates/xcl/src/gpu/recomp/emit.rsandcrates/xcl/src/gpu/recomp/tests.rs, implementedfmt_seland the narrowBufKind::FormatLoademission path, wrote unit and GPU tests, ran the test suite, shader benchmarks, and smoke tests, and drafted the commit and PR description.Narrow buffer_load_format_* and tbuffer_load_format_* instructions previously pre-decoded all four format components into {t}_c via fmt_comp even when only 1-3 components were selected. On format-heavy compute shaders (especially wide unrolled kernels), the unused decodes inflated emitted HLSL, DXIL size, and DXC compile time. Add a branch-free fmt_sel helper right after dst_sel in PRELUDE_MEM that routes only the needed format components into dst_sel, and update BufKind::FormatLoad to use fmt_sel whenever n_comp < 4 (including d16 loads, binding {t}_s{c} once before the 16-bit pack so the format decode is not evaluated twice). Measured on 4 extracted compute shaders from a retail shader pack (split-wave64, isolated caches): - 2,809 insts (9 x, 1 xy): DXIL 157184 B -> 141620 B (-9.9%), DXC 1.07 s -> 1.04 s - 7,305 insts (25 x, 2 xyz): DXIL 489424 B -> 450520 B (-7.9%), DXC 4.13 s -> 4.18 s - 16,414 insts (37 x, 6 xy, 4 xyz): DXIL 1092324 B -> 1030584 B (-5.7%), DXC 11.16 s -> 10.97 s - 88,863 insts (3,281 x): DXIL 29750432 B -> 20197536 B (-32.1%), DXC 130.59 s -> 94.61 s (-27.5%) Tests: .\scripts\test.ps1 passed (753 passed, 0 failed, 41 ignored; 2 expected wave64 GPU skips on RTX 5090), plus targeted Radeon GPU runs for gpu_buffer_load_format_swizzled_narrow_loads and gpu_typed_buffer_loads_and_stores. Assisted-by: Antigravity via T3 Code (Gemini Pro)@Aniseto on GitHub · 2026-11-24 14:37 UTC · original
Ran the two new tests on an NVIDIA Blackwell part at
c8b5978:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
buffer_load_format_decodes_only_requested_componentsandgpu_buffer_load_format_swizzled_narrow_loadspass here. The author's run used DXC 1.8.2502.11, so this also covers the newer compiler's code generation for the narrow loads on the same tests.Not tested: native wave64, RDNA2/RDNA4 and Intel GPUs, Wine, release profile, retail titles.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified.
@DavidM1911 on GitHub · 2026-11-24 15:42 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 21 ignored. (One run aborted with 0xc0000005 under parallel scheduling; clean on rerun — same flake seen on unmodifiedmain.)Thanks!
@Rednaxeh on GitHub · 2026-11-25 00:51 UTC · original
A size measurement in favour of this direction, on the largest retail compute program (
CS_ScreenProbes_ActivateRays, record95cc13288a27a96e), HLSL path ofmain20cf130(#1321 in), 4 memory windows, native wave64, DXC 1.9.2602.17 on Windows:-O0(what XCL uses above 8 MB of HLSL; this program's HLSL is 15.0 MB)-O1-O0, withfmt_compreduced toreturn r[c & 3u](a size probe, not a correct program)So at
-O0the runtime format decode is 46 % of this program's DXIL: 1 890 typed buffer loads, each decoding its descriptor's format four times (7 561fmt_compcalls, all with a descriptor-derivedinfo, none constant), and DXC at-O0folds nothing. The AMD driver (RX 7800 XT, 32.0.32029.2010) refuses this program with E_OUTOFMEMORY after 15–33 s at its current size (#232, #1918). Decoding only the requested components, and decodinginfoonce per load rather than once per component, both act directly on this half; I can rerun the probe on this PR's head if useful.AI use: Claude Code (Claude Fable 5.1) ran DXC and counted; the export was mine.
@JJAutoCompare on GitHub · 2026-11-25 01:08 UTC · original
Tested
Clean PR head
234ec72cc5ac3b3d544b4444a26a03b6164694a4on Intel Arc A770 (driver 32.0.101.9175), AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation 25H2 build 26200.9974 x64, Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), MSVC 14.44.35207, and DXC/DXIL 1.9.2609.5. Cargo used the debug test profile.Not tested
Full workspace suite, retail title smoke runs, PR-base comparison, AMD or NVIDIA, native wave64, direct DXIL, release mode, and performance.
AI use
Codex (gpt-6.2-sol) selected and ran the existing tests and wrote this report.
@xpatfussy69x on GitHub · 2026-11-25 08:26 UTC · original
Test report for head
234ec72as pushed (not merged onto currentmain) – NVIDIA, wave32.Tested
.\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 961 passed, 0 failed, 43 ignoredDIFFERS_ON_1426list, unrelated to this PR)buffer_load_format_decodes_only_requested_componentsandgpu_buffer_load_format_swizzled_narrow_loadsran and passedXCL_SAMPLE_*data set (game-data tests not run)Not tested
mainAI use
@ClosetPie107 on GitHub · 2026-11-25 20:46 UTC · original
Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head
234ec72cc5ac3b3d544b4444a26a03b6164694a4(merged cleanly ontomain6d12f58).Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnu(debug)Unit / GPU tests (
XCL_REQUIRE_GPU=wave64,XCL_DXC_DIR,VKD3D_CONFIG=ignore_shared_fence,--test-threads=1 --nocapture)buffer_load_format: 2 passed, 0 failed, 0 ignored (0 skipped; coversbuffer_load_format_decodes_only_requested_componentsandgpu_buffer_load_format_swizzled_narrow_loadson the RX 9070)Not tested
AI use
main, ran the tests under Proton on this machine, and drafted this report.@DavidM1911 on GitHub · 2026-11-26 04:47 UTC · original
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
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.