Recompiler: XCL_DECLARED_LDS=1 sizes direct compute LDS from the header (~11 ms less GPU per frame) #2937
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2937"
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-27T01:16:04Z.
The direct DXIL translator gives every compute program that uses LDS the whole 8,192-dword groupshared block D3D12 allows, with the split form's exchange words at its top. That caps how many groups run at once on a GPU whose LDS per SM is shared by resident groups. With
XCL_DECLARED_LDS=1it declares what the program's header asks for: the static workgroup LDS fromCOMPUTE_PGM_RSRC2, plus the split form's exchange words and counters (or the arrival counter of a native 2-D/3-D group) placed after it. A header with no size, or one too large to leave room for those, keeps the 8,192-dword layout. LDS addresses are clamped to the declared top. Off by default.How this differs from #2158 (#1607 group D149)
XCL_DECLARED_LDS=1(off by default, with separate disk-cache andComputePolicyKeyidentities), so default translations stay byte-identical; #2158 (stacked on #2146) enables smaller LDS by default across both HLSL and direct DXIL.declared + controldwords (no rounding up to the next power of two) and clamps out-of-range guest LDS indices tolds_top(umin) in both wave32 and split-wave64; #2158 rounds up to a power of two and wraps wave32 accesses with a bitmask.Title shader corpus audit (per @bmjask)
Across all 26,555 blobs in the title's
shaders.rpf+XboxBvhBuilder.dll(2,734 unique compute programs, plus 7 duplicates), 497 use LDS (real_lds_access):COMPUTE_PGM_RSRC2.LDS_SIZE == 0.<= 512: 248,513..=1024: 104,1025..=2048: 60,2049..=4096: 45,4097..8192: 34 on wave32-hw).control = 0, exact 8,192-dword fit).[1024, 1, 1](slot = 1,control = 97in split-wave64 on wave32-hw ->8,289 > 8,192), so 4 programs take the conservative 8,192-dword fallback on wave32-hw (NVIDIA) and 0 fall back on native wave64-hw (AMD, wherecontrol = 0):vfx_proj_decal_hit_detection:CS_ComputeHitDetectionResults_7b0d06e8_Wrappedvfx_proj_decal_hit_detection:CS_ComputeHitDetectionSkinnedResults_7b0d06e8_Wrappedvfx_triangleClip:CS_CollectTriangles_cb481f38_Wrappedvfx_triangleClip:CS_CollectTriangles_Meshlets_cb481f38_WrappedWhat is in it
CsInterface::lds_dwordsfromCOMPUTE_PGM_RSRC2(recomp/mod.rs).setup_storagesizesxcl_ldsfrom it and places the exchange words and counters after the guest LDS;lds_indexclamps to the declared top (dxil/lanes.rs,dxil/kernel.rs,dxil/lower_mem.rs); testCsInterfaceliterals follow the new field.ComputePolicyKeykey the switch apart (recomp/pso.rs,real/compute_build_key.rs).compute_lds_reservation_matches_descriptor_and_lane_storage(declared size and lane storage per mode,dxil/core_tests.rs),declared_lds_disk_cache_separates_both_direct_routes(disk cache keys,recomp/pso.rs), andevery_compute_build_input_splits_the_key(ComputePolicyKey,real/compute_build_key.rs).Tested
5003116eonmain227d2cb3(NVIDIA GeForce RTX 5070 Ti, driver 610.74, Windows 11 Pro 26200, DXC 1.9.2609.5, debug):cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 2,597 passed, 0 failed, 49 ignored across all 41 test binaries, 26SKIPPED:no wave64(RTX 5070 Ti is wave32 hardware:gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole, 4recomp::lowerwave64 tests, 14recomp::lower_dxilwave64 tests,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware)#1426semantics (f16_programs_on_the_gpuarithmetic/packed,f32_programs_on_the_gpuconversions)no heap windows (opt-in: XCL_HEAP_WINDOWS=1)(two_pass_binds_set_the_shared_view_heap,heap_window_out_of_memory_falls_back_to_the_switch_form)XCL_DECLARED_LDS=1(RTX 5070 Ti, DXC 1.9.2609.5):cargo test -p xcl --lib -- --test-threads=4 --nocapture lds: 58 passed, 0 failed, 0 ignored (1SKIPPED:gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64).cargo test -p xcl --lib -- --test-threads=4 --nocapture gpu_compute_mode_dispatch_abi: 1 passed, 0 failed, 0 skipped.c4f2a7f3:c4f2a7f3in comments below from ettehn (RTX 5070 Ti Laptop), andrewDoing (RTX 5070), SzczepanGrela (RX 9070 native wave64, 360 dispatches), and LocranKing (RTX 3060 Ti paired 180 s smoke).Regression run
Paired 150 s retail smoke runs on RTX 5070 Ti (warm
PC-SBMcache, defaultXCL_DECLARED_LDSunset,XCL_UMA_WINDOWS=16,XCL_HEAP_WINDOWS=1,XCL_DRED=1,XCL_DIRECT_DXIL=all,XCL_DIRECT_SPLIT_INSTRUCTIONS=0, DXC 1.9.2609.5,XCL_PSO_JOURNAL=0).mainexited0x0with a 0 B minidump (crashes: 1); head5003116eexited0x0with 0 crashes and 0 device removals (second run after warming5003116e's newComputePolicyKeydriver PSO blobs; the first cold-PSO run also exited0x0with 2,110 frames, 0 crashes, 0 device removals).main(227d2cb3):PR head (
5003116e):Not tested
XCL_DECLARED_LDS=1on rebased head5003116e(smoke above ran with defaultXCL_DECLARED_LDSunset; unit/GPU tests above coveredXCL_DECLARED_LDS=1).5003116e; Intel; Wine; opt-inXCL_HEAP_WINDOWS=1unit tests; titles other than this one.AI use
main(c4f2a7f3).main(227d2cb3->5003116e), addeddeclared_ldstoComputePolicyKey, updated workspaceCsInterfaceliterals, ran the offline title corpus LDS audit, ran the full workspace test suite +XCL_DECLARED_LDS=1tests + paired 150 s retail smoke, and updated this description.Imported from ivall/xcl. Originally posted by ettehn on 2026-11-27T01:25:59Z.
Independent Windows GPU readback on
c4f2a7f: RTX 5070 Ti Laptop (12 GB), NVIDIA 621.24, native D3D12. I usedconsole_wave64_compute_through_the_pso_hook_dispatch_and_read_back, with one local fixture change:rsrc2 |= 1 << 15to declare the 128 LDS dwords the synthetic program writes before reading its partner lane. Runtime code was unchanged.With
XCL_DIRECT_DXIL=1and fresh XCL caches per run, all four combinations ofXCL_PER_LANE=0/1andXCL_DECLARED_LDS=0/1completed the dispatch and passed readback. SDKdxc -dumpbinshows@xcl_ldsat 8,192 dwords with the switch off and 141 with it on (128 guest + 13 helper) on both lowering routes. This covers real PSO creation and execution for the split-wave LDS case. No retail timings or smoke results from this machine for this test.OpenAI Codex (6.2sol) assisted with verification.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T02:01:11Z.
Independent synthetic readback on PR head
c4f2a7f313db2c85ffd5becadafebc58dee85799plus a test-only fixture, on an RTX 5070. The guest shader declared 128 dwords of LDS and used 16×8×1 workgroups over 2×3 groups. The test compared each thread's own and mirrored lane coordinates through LDS for 768 threads per run.Four fresh-process tests passed without reported skips or failures: native wave32 and split guest wave64, each with the new allocation behavior off and on. Disassembly showed 8,192 dwords allocated with the behavior off in both modes; with it on, wave32 allocated 129 dwords including the arrival counter, and split wave64 allocated 141 including exchange/counters. All 6,144 expected output words matched across the four runs.
The fixture and header change were test-only; GTA VI execution, retail timing and performance were not tested. AI use: OpenAI Codex with GPT-6.2 Astra wrote and ran the fixture; Codex coordinated and prepared this report.
Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-27T02:03:42Z.
RX 9070 / RADV native-wave64 verification of
c4f2a7f313db2c85ffd5becadafebc58dee85799againstmain8b957bec6f82495aec940944c6bf47faa02db590.Tested
8293130ebe370b1+with local assertions disabled, DXC/DXIL 1.9.2602.17.XCL_ADAPTER='AMD Radeon RX 9070' XCL_REQUIRE_GPU=wave64 XCL_NETWORK=0 XCL_DXC_THREADS=1 XCL_DIRECT_COMPACT=0, private enabled caches. Production files match each pinned revision; only identical local tests were appended.The two new upstream tests passed on the head at
--test-threads=1and4: 2 passed, 0 failed, 0 ignored per top-level run. Each also ran its ten successful child harnesses. The cache test covers its synthetic marker-based cache-key separation.Additional local probes, run through Wine:
Separate processes for
XCL_DECLARED_LDS=0/1, both revisions, three repetitions per configuration:gpu_compute_mode_dispatch_abiprogram: write own coordinates to LDS, synchronize, read the reversed partner, then export both. Prefix and suffix canaries surround the output.For these 2-D GPU cases, the head with the switch on declares 129 / 257 / 385 dwords for 128 / 256 / 384 guest dwords, including the native arrival counter. Unspecified and oversized cases retain 8,192 dwords. HLSL retains 8,192. The layout-only probe also verified the split exchange/counter reservations and fallback cases.
All GPU payloads and guards matched independently computed values: 360 dispatches, including 180 native wave64, 552,960 payload words and 28,800 guard words. Containers have the expected WaveSize and thread-group metadata. Captures repeat byte-for-byte across the three repetitions. Default-off containers match main byte-for-byte in both probes; HLSL and fallback controls remain unchanged with the switch on.
The head reports 2 passed / 0 failed in every configuration. Main with the switch off also passes both probes; with it on, the GPU probe passes and the layout probe fails as expected on 72 size assertions per process, since main retains the old allocation.
Not tested
Retail/smoke, frame-time or occupancy gains, runtime PSO-hook integration, real driver-blob cache reuse, the full suite, or forced-split GPU execution. Split-form coverage here is translation/validation only.
AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, prepared local test-only probes, ran the comparisons, independently checked layout arithmetic and raw GPU output, and drafted this report. Publication authorized by the account owner.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T10:00:29Z.
Tested PR #2937 (
c4f2a7f3) againstmain(8b957bec) on Windows 11 (26300), Ryzen 5 5500 (6C/12T), RTX 3060 Ti 8 GiB (driver621.40),rustc 1.100.0, DXC1.9.2602.17.Unit Test (
cargo test --locked -p xcl)gpu::recomp::pso::shader_cache_tests::declared_lds_disk_cache_separates_both_direct_routes: passed (1 passed, 0 failedin lib and all invoked subprocess modes).Paired 180 s Retail Smoke (
9cc6a39e, Series Slockhart,XCL_HEAP_WINDOWS=1,XCL_DIRECT_DXIL=all,XCL_DIRECT_SPLIT_INSTRUCTIONS=0,XCL_PSO_WAIT_MS=50)Note:
XCL_DECLARED_LDS=1changes the direct-DXIL translator key as designed, so PR #2937 ran from a pre-warmedXCL_DECLARED_LDS=1DXIL snapshot and entered the world at231.3 s(109.4 sguest entry,58.1 sin-world) vsmain's188.4 s(67.2 sentry,58.9 sin-world).~58 sworld)2swindows)main(8b957bec)124014(28windows)29,411 MB14,281 / 2,241 MB9,178draws,34,068dispatches (88skipped)0 / 0(exit: 0x0)c4f2a7f3,XCL_DECLARED_LDS=1)117322(28windows)30,010 MB14,522 / 2,851 MB12,394draws,65,536dispatches (2,578skipped)0 / 0(exit: 0x0)Both runs stayed clean (
0crashes,0device removals,exit: 0x0). In the matched28two-second world windows, PR #2937 logged more presents (22vs14) and roughly 2x dispatches (65,536vs34,068).Not tested: Per-dispatch GPU timestamp breakdown (
XCL_LOOK_STATS), or longer steady-state runs past PSO build-out on 8 GiB VRAM.Imported from ivall/xcl. Originally posted by throny on 2026-11-27T14:42:13Z.
Two contributors checked independently and found that #2158 solves the same problem in a different way: #1607, group D149. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T15:38:04Z.
Triage note (from https://github.com/xcl-dev/xcl/issues/1607#issuecomment-7222291116, a check from the outside against CONTRIBUTING.md, not a code review):
PR descriptionis red because the twoxcl-smokeblocks (a commit ofmain, and this head) are missing; the body says they are queued. #2158 addresses the same thing another way (group D149 on #1607), so a line on how the two differ would help whoever merges.AI use: Claude Code (Claude Fable 5.2).
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-28T22:04:24Z.
Review: COMMENTED
The occupancy result is promising and the implementation is opt-in, but this draft is not review-ready yet: it conflicts, the description still says full tests and smoke runs are queued, and the smoke evidence predates the current review state.
Please resolve the conflict as a focused LDS-sizing change, run the full exact-head suite, and attach required main/head smoke blocks. Include the count of programs that retain the conservative 8,192-dword layout and all GPU-test skips.
Reviewed at
c4f2a7f313with Codex (GPT-5).Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-28T23:34:10Z.
Rebased onto
main(227d2cb3->5003116e) as a focused LDS-sizing change, includingdeclared_ldsinmain'sComputePolicyKey(pso.rs/compute_build_key.rs) and updating all newCsInterfacetest literals.Also added a short comparison against #2158 (#1607 D149) to the description per @throny's note (opt-in
XCL_DECLARED_LDS=1with exactdeclared + controlsizing anduminclamping in both wave32 and split-wave64 vs #2158's default-on power-of-two sizing across HLSL + direct DXIL).Targeted tests run on
5003116e(RTX 5070 Ti, debug, Windows SDK DXC 1.7.2308):cargo test --workspace --no-run: okcompute_lds_reservation_matches_descriptor_and_lane_storage,declared_lds_disk_cache_separates_both_direct_routes,every_compute_build_input_splits_the_key: 3 passed, 0 failed, 0 skippedgpu_compute_mode_dispatch_abi: 1 passed, 0 failed, 0 skippedldsfilter: 58 passed, 0 failed, 0 ignored (2SKIPPEDlines ondispatch_chain_native_wave64_builds_whole: DXC 1.7 < 1.8 and no wave64)Still pending before ready for final review per @bmjask: exact-head full workspace suite, paired
main/5003116excl-smokeblocks, and the count of programs retaining the conservative 8,192-dword layout.AI use: Antigravity (Gemini 4 Neon) rebased the branch, ran the targeted tests, updated the PR body, and posted this comment.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T00:30:14Z.
Updated PR description with the offline title corpus LDS audit (per @bmjask), full workspace test suite, and paired exact-head 150 s retail smoke on
5003116e:Title shader corpus LDS fallback count (
shaders.rpf+XboxBvhBuilder.dll, 2,734 unique compute shaders, 497 using LDS):COMPUTE_PGM_RSRC2.LDS_SIZE == 0.<= 512: 248,513..=1024: 104,1025..=2048: 60,2049..=4096: 45,4097..8192: 34 on wave32-hw).control = 0, exact 8,192 fit).[1024, 1, 1](slot = 1,control = 97in split-wave64 ->8,289 > 8,192) and retain the conservative 8,192-dword fallback on wave32-hw (NVIDIA), 0 fall back on native wave64-hw (AMD):vfx_proj_decal_hit_detection:CS_ComputeHitDetectionResults_7b0d06e8_Wrapped,vfx_proj_decal_hit_detection:CS_ComputeHitDetectionSkinnedResults_7b0d06e8_Wrapped,vfx_triangleClip:CS_CollectTriangles_cb481f38_Wrapped,vfx_triangleClip:CS_CollectTriangles_Meshlets_cb481f38_Wrapped.Tests & paired 150 s smoke on
5003116e(RTX 5070 Ti, DXC 1.9.2609.5):cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 2,597 passed, 0 failed, 49 ignored, 26SKIPPED(21no wave64, 3#1426per-lane refusals, 2no heap windows).XCL_DECLARED_LDS=1:ldsfilter 58 passed, 0 failed (1SKIPPED:no wave64);gpu_compute_mode_dispatch_abi1 passed, 0 failed, 0 skipped.ea3b5e4d, defaultXCL_DECLARED_LDSunset):main227d2cb3= 2,914 frames / 32,755 MB peak commit vs head5003116e= 3,284 frames / 32,485 MB peak commit, 0 crashes, 0 device removals.scripts/pr_check.py --local:description ok.AI use: Antigravity (Gemini 4 Neon) ran the corpus audit, full workspace test suite,
XCL_DECLARED_LDS=1tests, and paired smoke, updated the PR body, and posted this comment.Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T00:36:08Z.
I measured warm GPU dispatch time for a synthetic direct-DXIL compute shader at
5003116e91c039be335a8544f807bfe5ff9a559fon an RTX 5070 (driver 616.92). The shader writes a coordinate into LDS, synchronizes one 16×2 wave32 workgroup, reads its mirrored lane, and stores both values. All output DWORDs were checked against a CPU oracle for both translations.Values are the median of four within-block medians per setting. The same guest program declared 128 dwords of static LDS; disassembly showed 8,192 dwords off and 129 on, including the 2-D arrival word. I generated the two DXIL blobs in separate processes and timed both in one process. The block order was off/on/on/off/on/off/off/on, 25 dispatches per block, dropping the first five. Each measured interval is bracketed by native D3D12 GPU timestamps and excludes PSO creation, upload and CPU waiting. On the larger workload, off block medians ranged from 38.080–38.192 µs and on from 11.168–11.296 µs.
This measures the complete switch-generated shader, including address-lowering differences. I did not collect hardware occupancy counters. A prior 16×8 multiwave mirror fixture now reaches the direct translator's multiwave barrier refusal, so I used the supported single-wave configuration for these numbers. The timings describe only this synthetic dispatch; they do not reproduce the title frame-time measurement.
AI use: OpenAI Codex adapted the mirror fixture, ran the paired timestamps and output checks, and drafted this report.
Imported from ivall/xcl. Originally posted by iggyvilla on 2026-11-29T08:13:01Z.
Tested (RDNA2 data point on a retail world-load run; the thread has NVIDIA and RDNA4/RADV reports so far)
lockhart),XCL_NETWORK=0.c4f2a7f3(+122/-29) by hand onto a local fork ofamd-dev(7c795f5eplus local VRAM work), so this says nothing about the rebase to5003116e. The CS pipelines were re-precompiled once because the DXIL keys change (136 new pipelines, 0 refused, 48 s).XCL_DECLARED_LDS=1; the builds differ only by the port commit): each is a single run, not paired or repeated, so run-to-run noise is unmeasured.XCL_DECLARED_LDS=1The run with the switch on was also the first to get past frame 2,700. I did not isolate how much of the VRAM and commit drop comes from smaller LDS allocations and how much from the run reaching different content, so treat the VRAM/commit rows as an observation, not a measured effect. On this card the 8 GB budget makes a lower LDS reservation matter more than on the 12-16 GB cards above.
AI use: Claude Code (Claude Sonnet 5.5, effort high) ported the diff, built and ran both runs, and wrote this comment. The account owner did not write it and approved posting it without reading it.
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-30T00:00:06Z.
For coordination: #3478 combines this PR with raylitebull's amd-dev version of it (
5e488781, on by default there). It is rebased on main, after the safe multi-wave barrier (#3264) and on #3468's LDS clamp, and credits you as co-author. It keeps yourlds_dwords, layout,ComputePolicyKeyfield and clamp condition. It adds amd-dev's safe-barrier placement, makes the default on, and tests native wave64 on an AMD RDNA2 iGPU. Your 89 → 78 ms measurement is quoted there. If you'd rather carry it here, say so and I'll close #3478.(Claude Code, Claude Opus 5.5, for Foniass)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:01:58Z.
Review (head
5003116e, diff read, not a merge-check; it conflicts with main, so not built or run):lds_indexclamp change is already on main (ada50ec5, #3497), and open #3478 carries the rest rebased onto current main (on by default, crediting this PR, with a GPU test).setup_storage(lanes.rs~25-47) now keeps words 8189-8190 for the safe barrier's counters and lowers the program's top to 8188. This PR's layout leaves no room for them, so with a smallerxcl_ldsthose counters would land past the end of the array. #3478 already handles this.xwatwords-1).Fine: LDS_SIZE decoding (x128 dwords), the fallback to 8,192 for no size or one too large, off by default, and the disk cache and
ComputePolicyKeykept apart. Recommendation: close in favour of #3478.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T15:59:07Z.
Closing as superseded: the same change is in #3478 (open, mergeable, required checks green). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will.
AI use: Claude Code (Claude Opus 5.5).
Pull request closed