Repository navigation
Recompiler: XCL_DECLARED_LDS=1 sizes direct compute LDS from the header (~11 ms less GPU per frame) - #2937
Recompiler: XCL_DECLARED_LDS=1 sizes direct compute LDS from the header (~11 ms less GPU per frame)#2937Kalmarv wants to merge 1 commit into
Conversation
|
Independent Windows GPU readback on With OpenAI Codex (6.2sol) assisted with verification. |
|
Independent synthetic readback on PR head 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. |
|
RX 9070 / RADV native-wave64 verification of Tested
The two new upstream tests passed on the head at Additional local probes, run through Wine: Separate processes for
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. |
…mp hunks verbatim) Live head c4f2a7f still OPEN. Single commit on upstream/main 8b957be: CsInterface gains lds_dwords parsed from COMPUTE_PGM_RSRC2, setup_storage takes (slot, declared, native_counter), LDS block sized to declared+control under XCL_DECLARED_LDS=1 (off = byte- identical layout, verified by analysis + green suite), pso cache identity forks declared-lds for both direct routes, upstream tests in Windows-only core_tests/pso stay reference-only per ground rule 9. Tree adaptations: ..Default::default() on our local-only CsInterface literals (dxil/robustness_tests 1, dxil/lower_valu 3) that upstream does not have. Linux pin: declared_lds_descriptor_ parses_static_workgroup_lds (robustness_tests) — fails pre-fix (E0609 no field), green post-fix.
Follows f1a3ec3, whose tree already carries the test in the working-tree gates (787/0/1) but not in the commit: this lands it. declared_lds_descriptor_parses_static_workgroup_lds guards the shared CsInterface::from_descriptor parse on Linux (upstream test is Windows-only core_tests). Failing-first shown pre-fix (E0609), green post-fix.
|
Tested PR #2937 ( Unit Test (
|
| Build | Frames shown (~58 s world) |
World presents (2s windows) |
Peak commit | Peak local / non-local VRAM | Console stats | Crashes / Removals |
|---|---|---|---|---|---|---|
main (8b957bec) |
1240 |
14 (28 windows) |
29,411 MB |
14,281 / 2,241 MB |
9,178 draws, 34,068 dispatches (88 skipped) |
0 / 0 (exit: 0x0) |
PR #2937 (c4f2a7f3, XCL_DECLARED_LDS=1) |
1173 |
22 (28 windows) |
30,010 MB |
14,522 / 2,851 MB |
12,394 draws, 65,536 dispatches (2,578 skipped) |
0 / 0 (exit: 0x0) |
Both runs stayed clean (0 crashes, 0 device removals, exit: 0x0). In the matched 28 two-second world windows, PR #2937 logged more presents (22 vs 14) and roughly 2x dispatches (65,536 vs 34,068).
Not tested: Per-dispatch GPU timestamp breakdown (XCL_LOOK_STATS), or longer steady-state runs past PSO build-out on 8 GiB VRAM.
|
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. |
|
Triage note (from #1607 (comment), a check from the outside against CONTRIBUTING.md, not a code review):
AI use: Claude Code (Claude Fable 5.2). |
bmjask
left a comment
There was a problem hiding this comment.
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 c4f2a7f with Codex (GPT-5).
The direct DXIL translator gave 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. With XCL_DECLARED_LDS=1 it declares what the program's header asks for instead: the static workgroup LDS from COMPUTE_PGM_RSRC2 (CsInterface::lds_dwords), plus the exchange words and counters of the split form (or the arrival counter of a native 2-D/3-D group) placed after it. A header with no size, or one too big to leave room for them, keeps the 8,192-dword layout. LDS addresses are clamped to the declared top. The translated-shader caches and ComputePolicyKey key the switch apart. Less groupshared memory per group lets more groups run at once. On the title (RTX 5070 Ti, Series X profile, per-program GPU timestamps over 187-229 s), the late frame's compute went from about 89 to about 78 ms per present with the switch on; 66 of the late programs translate differently (the split family and wave32 programs), and with the switch off the translation is byte-identical. Tests: compute_lds_reservation_matches_descriptor_and_lane_storage (the declared size and lane storage per mode), declared_lds_disk_cache_separates_both_direct_routes (the cache keys), and every_compute_build_input_splits_the_key (ComputePolicyKey). Written by reed on our team branch; rebased onto main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Antigravity (Gemini 4 Neon)
c4f2a7f to
5003116
Compare
|
Rebased onto Also added a short comparison against #2158 (#1607 D149) to the description per @throny's note (opt-in Targeted tests run on
Still pending before ready for final review per @bmjask: exact-head full workspace suite, paired AI use: Antigravity (Gemini 4 Neon) rebased the branch, ran the targeted tests, updated the PR body, and posted this comment. |
|
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 Title shader corpus LDS fallback count (
Tests & paired 150 s smoke on
AI use: Antigravity (Gemini 4 Neon) ran the corpus audit, full workspace test suite, |
|
I measured warm GPU dispatch time for a synthetic direct-DXIL compute shader at
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. |
|
Tested (RDNA2 data point on a retail world-load run; the thread has NVIDIA and RDNA4/RADV reports so far)
The 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. |
The direct DXIL translator gave every compute program that uses LDS the whole 8,192-dword groupshared block D3D12 allows. A one-wave group then holds 32 KB, so an RDNA WGP (128 KB) runs four groups: one wave a SIMD. The title's CS_GenerateShadowMasks_Checkerboard_NoHair (cs d9fac2f1d8f646fd, 4x8 threads, one wave a group, one LDS dword used, LDS_SIZE 1 granule) is the top GPU program of the open world (20-139 ms a frame) and ran so. The block is now the LDS COMPUTE_PGM_RSRC2 declares (CsInterface::lds_dwords, 128-dword granules) followed by the translator's words: a native 2-D / 3-D group's arrival counter, a multi-wave safe barrier's two words, the split form's exchange slots and counters. A header with no size, or one too big to leave room for them, keeps the 8,192-dword layout. LDS addresses are kept below the declared top. XCL_DECLARED_LDS=0 restores the old layout; the translated-shader caches key the switch. Measured offline (Radeon GPU Analyzer, amdxc64 gfx1201, the run's heap windows): the title program's LDS goes from 32,768 to 5,008 bytes (the driver's own share included); VGPRs (256) now limit it, not LDS. Ported from #2937 (Kalmarv, "XCL_DECLARED_LDS=1 sizes direct compute LDS from the header"), adapted to this tree's safe-barrier words and made default-on; its compute_build_key.rs part has no counterpart here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The direct DXIL translator gave every compute program that uses LDS the whole 8,192-dword groupshared block D3D12 allows. A one-wave group then holds 32 KB, so an RDNA WGP (128 KB) runs four groups: one wave a SIMD. The title's CS_GenerateShadowMasks_Checkerboard_NoHair (cs d9fac2f1d8f646fd, 4x8 threads, one wave a group, one LDS dword used, LDS_SIZE 1 granule) is the top GPU program of the open world (20-139 ms a frame) and ran so. The block is now the LDS COMPUTE_PGM_RSRC2 declares (CsInterface::lds_dwords, 128-dword granules) followed by the translator's words: a native 2-D / 3-D group's arrival counter, a multi-wave safe barrier's two words, the split form's exchange slots and counters. A header with no size, or one too big to leave room for them, keeps the 8,192-dword layout. LDS addresses are kept below the declared top. XCL_DECLARED_LDS=0 restores the old layout; the translated-shader caches key the switch. Measured offline (Radeon GPU Analyzer, amdxc64 gfx1201, the run's heap windows): the title program's LDS goes from 32,768 to 5,008 bytes (the driver's own share included); VGPRs (256) now limit it, not LDS. Ported from #2937 (Kalmarv, "XCL_DECLARED_LDS=1 sizes direct compute LDS from the header"), adapted to this tree's safe-barrier words and made default-on; its compute_build_key.rs part has no counterpart here.
|
For coordination: #3478 combines this PR with raylitebull's amd-dev version of it ( (Claude Code, Claude Opus 5.5, for Foniass) |
The direct DXIL translator gave every compute program that uses LDS the whole 8,192-dword groupshared block D3D12 allows. A one-wave group then holds 32 KB, which caps how many groups a GPU keeps resident when its LDS is shared by them (an RDNA WGP's 128 KB: four groups, one wave a SIMD). The block is now the LDS COMPUTE_PGM_RSRC2 declares (CsInterface::lds_dwords, LDS_SIZE in 128-dword granules) followed by the translator's own words: a native 2-D / 3-D group's arrival counter, a multi-wave safe barrier's two words (xcl-dev#3264; right after the program's LDS in a native group, below the arrival word in the split form, as at the top of the 8,192-dword block), and the split form's exchange slots and counters. A header with no size, or one too large to leave room for those words, keeps the 8,192-dword layout. Program LDS indices are clamped below the translator's words (lds_index's `split || lds_top < 8191`, the parent commit), so an access past the declared size stays at the last declared dword. Mesh and geometry programs keep the 8,192-dword block. The HLSL path is unchanged. On by default; XCL_DECLARED_LDS=0 restores the 8,192-dword layout. The direct translator's disk-cache identities and ComputePolicyKey (the driver pipeline cache's key) key the switch apart. From Kalmarv's xcl-dev#2937 ("XCL_DECLARED_LDS=1 sizes direct compute LDS from the header", opt-in there; written with Claude Code (Claude Opus 5.5), ComputePolicyKey part with Antigravity (Gemini 4 Neon)): CsInterface::lds_dwords, the declared layout, the ComputePolicyKey field and its build-key test, the `lds_top < 8191` clamp. From raylitebull's amd-dev 5e48878 (xcl-dev#2937 adapted to the safe-barrier words, default on): the safe barrier's placement, the test switch, the declared-size test and the GPU test, extended here to native wave64 and the split form. New here: a disassembly test of the clamp and of the translator's words. Measured by xcl-dev#2937 (RTX 5070 Ti, the title, per-program GPU timestamps over 187-229 s): the late frame's compute from about 89 to about 78 ms per present. Measured by 5e48878 offline (Radeon GPU Analyzer, gfx1201): the title's top open-world program from 32,768 to 5,008 bytes of LDS. Co-authored-by: Kalmarv <59708937+Kalmarv@users.noreply.github.com> Co-authored-by: raylitebull <287713799+raylitebull@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review (head 5003116, diff read, not a merge-check; it conflicts with main, so not built or run):
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 AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
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; Direct DXIL: size a compute program's LDS block from its LDS_SIZE #2158 (stacked on Recompiler: size a compute program's LDS block from its LDS_SIZE #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; Direct DXIL: size a compute program's LDS block from its LDS_SIZE #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.