Skip to content

Recompiler: XCL_DECLARED_LDS=1 sizes direct compute LDS from the header (~11 ms less GPU per frame) - #2937

Closed
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:declared-lds
Closed

Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:declared-lds

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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=1 it declares what the program's header asks for: the static workgroup LDS from COMPUTE_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)

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):

  • 0 / 497 have COMPUTE_PGM_RSRC2.LDS_SIZE == 0.
  • 491 / 497 (98.8%) shrink strictly below 8,192 dwords (<= 512: 248, 513..=1024: 104, 1025..=2048: 60, 2049..=4096: 45, 4097..8192: 34 on wave32-hw).
  • 2 / 497 declare 8,192 dwords on native wave32 (1-D group, control = 0, exact 8,192-dword fit).
  • 4 / 497 declare 8,192 dwords in wave64 [1024, 1, 1] (slot = 1, control = 97 in 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, where control = 0):
    • 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

What is in it

  • CsInterface::lds_dwords from COMPUTE_PGM_RSRC2 (recomp/mod.rs).
  • setup_storage sizes xcl_lds from it and places the exchange words and counters after the guest LDS; lds_index clamps to the declared top (dxil/lanes.rs, dxil/kernel.rs, dxil/lower_mem.rs); test CsInterface literals follow the new field.
  • The translated-shader disk caches and ComputePolicyKey key the switch apart (recomp/pso.rs, real/compute_build_key.rs).
  • Tests: 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), and every_compute_build_input_splits_the_key (ComputePolicyKey, real/compute_build_key.rs).

Tested

  • Rebased head 5003116e on main 227d2cb3 (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, 26 SKIPPED:
      • 21 no wave64 (RTX 5070 Ti is wave32 hardware: gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole, 4 recomp::lower wave64 tests, 14 recomp::lower_dxil wave64 tests, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware)
      • 3 per-lane wave32 refusals for #1426 semantics (f16_programs_on_the_gpu arithmetic/packed, f32_programs_on_the_gpu conversions)
      • 2 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)
    • With 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 (1 SKIPPED: 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.
  • Earlier head c4f2a7f3:
    • Title, Series X profile, per-program GPU timestamps over 187–229 s: late frame's compute went from ~89 to ~78 ms per present with the switch on; 66 of the late programs translate differently, and with the switch off translation is byte-identical.
    • Independent GPU readback reports on c4f2a7f3 in 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-SBM cache, default XCL_DECLARED_LDS unset, 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). main exited 0x0 with a 0 B minidump (crashes: 1); head 5003116e exited 0x0 with 0 crashes and 0 device removals (second run after warming 5003116e's new ComputePolicyKey driver PSO blobs; the first cold-PSO run also exited 0x0 with 2,110 frames, 0 crashes, 0 device removals).

main (227d2cb3):

xcl-smoke v1
commit: 227d2cb388f103268dac7635ea720eb3e5352d4e
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 2914 (PresentX 2914)
presents per 2 s (last 3): 44 40 12
device removals: 0
crashes: 1
peak commit: 32755 MB

PR head (5003116e):

xcl-smoke v1
commit: 5003116e91c039be335a8544f807bfe5ff9a559f
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 3284 (PresentX 3284)
presents per 2 s (last 3): 39 43 7
device removals: 0
crashes: 0
peak commit: 32485 MB

Not tested

  • 150 s retail smoke with XCL_DECLARED_LDS=1 on rebased head 5003116e (smoke above ran with default XCL_DECLARED_LDS unset; unit/GPU tests above covered XCL_DECLARED_LDS=1).
  • Native wave64 hardware (AMD) on 5003116e; Intel; Wine; opt-in XCL_HEAP_WINDOWS=1 unit tests; titles other than this one.

AI use

  • Claude Code (Claude Opus 5.5): wrote the original change and tests on our team branch and split it onto main (c4f2a7f3).
  • Antigravity (Gemini 4 Neon): rebased onto main (227d2cb3 -> 5003116e), added declared_lds to ComputePolicyKey, updated workspace CsInterface literals, ran the offline title corpus LDS audit, ran the full workspace test suite + XCL_DECLARED_LDS=1 tests + paired 150 s retail smoke, and updated this description.

@ettehn

ettehn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Independent Windows GPU readback on c4f2a7f: RTX 5070 Ti Laptop (12 GB), NVIDIA 621.24, native D3D12. I used console_wave64_compute_through_the_pso_hook_dispatch_and_read_back, with one local fixture change: rsrc2 |= 1 << 15 to declare the 128 LDS dwords the synthetic program writes before reading its partner lane. Runtime code was unchanged.

With XCL_DIRECT_DXIL=1 and fresh XCL caches per run, all four combinations of XCL_PER_LANE=0/1 and XCL_DECLARED_LDS=0/1 completed the dispatch and passed readback. SDK dxc -dumpbin shows @xcl_lds at 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.

@andrewDoing

Copy link
Copy Markdown
Contributor

Independent synthetic readback on PR head c4f2a7f313db2c85ffd5becadafebc58dee85799 plus 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.

@SzczepanGrela

Copy link
Copy Markdown

RX 9070 / RADV native-wave64 verification of c4f2a7f313db2c85ffd5becadafebc58dee85799 against main 8b957bec6f82495aec940944c6bf47faa02db590.

Tested

  • RX 9070 16 GB, Ryzen 7 7700, CachyOS 7.3.0-5-cachyos, RADV / Mesa 26.3.1-arch3.5. Rust 1.97.1 Windows GNU release executables under GE-Proton11-12 / Wine 11.0 Staging; native DXGI/D3D12, vkd3d-proton 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=1 and 4: 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:

<unit.exe> workflow_declared_lds_ --nocapture --test-threads=1

Separate processes for XCL_DECLARED_LDS=0/1, both revisions, three repetitions per configuration:

  • Layout probe: 144 validated containers per process, both direct lowering routes, 1-D/2-D/3-D groups, native wave32/wave64 and split-form IR. Header LDS reservations include unspecified, small, non-power-of-two, near-limit and oversized cases.
  • GPU probe: 30 dispatches per process, HLSL/direct/per-lane, native wave32/wave64 and five header reservations. Each dispatch runs six 16x8 groups. The program is the existing gpu_compute_mode_dispatch_abi program: 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.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
…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.
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
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.
@LocranKing

Copy link
Copy Markdown

Tested PR #2937 (c4f2a7f3) against main (8b957bec) on Windows 11 (26300), Ryzen 5 5500 (6C/12T), RTX 3060 Ti 8 GiB (driver 621.40), rustc 1.100.0, DXC 1.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 failed in lib and all invoked subprocess modes).

Paired 180 s Retail Smoke (9cc6a39e, Series S lockhart, XCL_HEAP_WINDOWS=1, XCL_DIRECT_DXIL=all, XCL_DIRECT_SPLIT_INSTRUCTIONS=0, XCL_PSO_WAIT_MS=50)

Note: XCL_DECLARED_LDS=1 changes the direct-DXIL translator key as designed, so PR #2937 ran from a pre-warmed XCL_DECLARED_LDS=1 DXIL snapshot and entered the world at 231.3 s (109.4 s guest entry, 58.1 s in-world) vs main's 188.4 s (67.2 s entry, 58.9 s in-world).

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.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

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.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Triage note (from #1607 (comment), a check from the outside against CONTRIBUTING.md, not a code review):

PR description is red because the two xcl-smoke blocks (a commit of main, 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).

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 28, 2026
@Kalmarv

Kalmarv commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (227d2cb3 -> 5003116e) as a focused LDS-sizing change, including declared_lds in main's ComputePolicyKey (pso.rs / compute_build_key.rs) and updating all new CsInterface test literals.

Also added a short comparison against #2158 (#1607 D149) to the description per @throny's note (opt-in XCL_DECLARED_LDS=1 with exact declared + control sizing and umin clamping 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: ok
  • compute_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 skipped
  • gpu_compute_mode_dispatch_abi: 1 passed, 0 failed, 0 skipped
  • lds filter: 58 passed, 0 failed, 0 ignored (2 SKIPPED lines on dispatch_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/5003116e xcl-smoke blocks, 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.

@github-actions github-actions Bot added gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) and removed gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 28, 2026
@Kalmarv

Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

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):

  • 0 / 497 have COMPUTE_PGM_RSRC2.LDS_SIZE == 0.
  • 491 / 497 (98.8%) shrink strictly below 8,192 dwords (<= 512: 248, 513..=1024: 104, 1025..=2048: 60, 2049..=4096: 45, 4097..8192: 34 on wave32-hw).
  • 2 / 497 declare 8,192 dwords on native wave32 (1-D, control = 0, exact 8,192 fit).
  • 4 / 497 declare 8,192 dwords in wave64 [1024, 1, 1] (slot = 1, control = 97 in 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, 26 SKIPPED (21 no wave64, 3 #1426 per-lane refusals, 2 no heap windows).
  • With XCL_DECLARED_LDS=1: lds filter 58 passed, 0 failed (1 SKIPPED: no wave64); gpu_compute_mode_dispatch_abi 1 passed, 0 failed, 0 skipped.
  • 150 s smoke (ea3b5e4d, default XCL_DECLARED_LDS unset): main 227d2cb3 = 2,914 frames / 32,755 MB peak commit vs head 5003116e = 3,284 frames / 32,485 MB peak commit, 0 crashes, 0 device removals.
  • Local scripts/pr_check.py --local: description ok.

AI use: Antigravity (Gemini 4 Neon) ran the corpus audit, full workspace test suite, XCL_DECLARED_LDS=1 tests, and paired smoke, updated the PR body, and posted this comment.

@Kalmarv
Kalmarv marked this pull request as ready for review November 29, 2026 00:30
@github-actions github-actions Bot added the needs-rebase Has merge conflicts with its base branch label Nov 29, 2026
@andrewDoing

Copy link
Copy Markdown
Contributor

I measured warm GPU dispatch time for a synthetic direct-DXIL compute shader at 5003116e91c039be335a8544f807bfe5ff9a559f on 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.

Workgroups per dispatch Output DWORDs checked per variant Switch off XCL_DECLARED_LDS=1
1,024 65,536 3.392 µs 1.632 µs
16,384 1,048,576 38.128 µs 11.264 µs

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.

@iggyvilla

Copy link
Copy Markdown
Collaborator

Tested (RDNA2 data point on a retail world-load run; the thread has NVIDIA and RDNA4/RADV reports so far)

  • RX 6650 XT 8 GB (RDNA2, DXGI local budget about 6.3-6.6 GB), Ryzen 7 5700X, 32 GB RAM + 64 GB pagefile, Windows 11, release build, Series S profile (lockhart), XCL_NETWORK=0.
  • Not the current head. I ported the diff of c4f2a7f3 (+122/-29) by hand onto a local fork of amd-dev (7c795f5e plus local VRAM work), so this says nothing about the rebase to 5003116e. The CS pipelines were re-precompiled once because the DXIL keys change (136 new pipelines, 0 refused, 48 s).
  • Two 600 s retail runs of the same world-load script, identical except for the port (the job files differ only in 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.
600 s run without with XCL_DECLARED_LDS=1
exit clean clean, 0 errors
presents 2,684 2,879
FPS, frames 2100-2400 2.9 4.1
peak local VRAM 9,787 MB 8,213 MB (flat 8,064 MB for the last 250 s)
peak commit 29.3 GB 27.1 GB

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.

raylitebull added a commit that referenced this pull request Nov 29, 2026
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>
raylitebull added a commit that referenced this pull request Nov 29, 2026
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.
@Foniass

Foniass commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

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 your lds_dwords, layout, ComputePolicyKey field 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)

Foniass added a commit to Foniass/xcl that referenced this pull request Nov 30, 2026
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>
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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 ComputePolicyKey kept 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.

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

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).

@throny throny added the duplicate This issue or pull request already exists label Dec 1, 2026
@throny throny closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle duplicate This issue or pull request already exists gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) needs-rebase Has merge conflicts with its base branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants