gpu/ambient: LDS-tile gather compute pass and scope internal UAV barriers (D3D12-GPU-AMBIENT-LDS-GATHER) #2893
Open
github-bot
wants to merge 1 commit from
github-bot/gh-2893 into main
AGit
pull from: github-bot/gh-2893
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2893
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2893"
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?
@djrolfes on GitHub · 2026-12-01 15:37 UTC · original
djrolfes:djrolfes/gpu-ambient-lds-gather→main· +143 −26 · 1 files · 1 commits · openClaimed in the coordination issue as:
D3D12-GPU-AMBIENT-LDS-GATHER.What and why
Tile the
ambient::gathercompute shader through workgroup shared memory (LDS) for 64× fewer global UAV reads and scope internal ambient UAV barriers (d3d12/crates/leonida-gpu/src/ambient.rs).main,gatherruns[numthreads(8, 2, 1)](Dispatch(20, 45, 1)) and every one of the 14,400 (160 × 90) threads independently reads allCELLS = 2,304entries ofcells[](cells[CELLS + 1 + i]andcells[i].rgb) from global UAV memory.keep → mean,mean → ...,place → gather) emitted a globalpResource = NULLUAV barrier, andRole::Resolvealso emitted a pre-dispatch global UAV barrier beforeplace+gathereven though neither touchesviews.image.gatherto[numthreads(8, 8, 1)](Dispatch(20, 12, 1)), cooperatively loading 64-cell tiles intogroupshared float4 tile_pos[64]andgroupshared float3 tile_light[64](CELLS = 64 × 36 = 2,304, an exact multiple of 64), reducing global UAV reads by 64× while guarding partial-group rows (90 % 8 == 2) withbool active = at.x < PX && at.y < PY;so inactive threads still participate in cooperative loads andGroupMemoryBarrierWithGroupSync()before returning.uav_barrier(list, resource: Option<&ID3D12Resource>)to scope internalcellstransitions (keep → mean, aftermean,place → gather) toSome(&pass.cells).Role::Resolve, defers the globaluav_barrier(l, None)until immediately beforepass.raise(synchronizing bothpass.pointswritten bygatherand the title'sviews.imageUAV write beforeraisereads/modifiesviews.image).d3d12/crates/leonida-gpu/src/ambient.rs) + live D3D12 GPU red→green test (gather_dispatches_the_partial_group) + MEASURED 300 s in-world Option-A roam gate withLEONIDA_AMBIENT=0.8and local mid-roam video visual/flicker check.Tested
python3 -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/ambient.rs→ exit 0.leonida-gpuunit test binary (x86_64-pc-windows-msvc) and ran live D3D12 GPU tests under Wine + VKD3D-Proton 3.2.0 (NVIDIA GeForce RTX 3070 Ti, driver620.73.04):origin/main(only the new GPU testambient::tests::gather_dispatches_the_partial_groupapplied, dispatching(20, 12, 1)and asserting all160 × 90output points receive the final tileCELLS - 1): (3840 = 24 × 160— rows24..90were left unwritten undermain's[numthreads(8, 2, 1)].)e9e8b257b(rebased onto3e7b34a52):e9e8b257b, Series S + DLSS Quality1280×720 → 1920×1080,LEONIDA_AMBIENT=0.8, Option Amods/gate_drivermode = roam):310.35 sin-world after world entry at74.71 s).1,580frames after +60 s (1,648total world presents),9.85median FPS (10.90end median FPS),405.56 msp95 frame time,6.964 slongest present gap (<= 10.0 s).6,692 MiBpeak VRAM (<= 7,400 MiB),0device losses (0x887A0005),0crashes,0panics,0faults before stop,0kernelNVRM: Xiderrors.GATE CONTROLreached att = 79.7 s(moved = 7.62 m,mode = roam),30GATE MARKroam ticks,0GATE FAIL.48consecutive presented frames mid-roam withLEONIDA_AMBIENT=0.8(reversals_ge_5 = 0,blink_pct_mean = 0.402%); visual inspection confirmed clean indirect ambient lighting with zero tile seams (including the partial bottom row90 % 8 == 2), zero NaN/black blocks, and zero flicker during camera motion (temporary capture deleted locally; no frames attached).GPUs tested: NVIDIA GeForce RTX 3070 Ti 8 GB, driver 620.73.04, Arch Linux (Wine 11.22 + VKD3D-Proton 3.2.0).
AI-assisted: yes (authored by Gemini 4 Neon; reviewed in a separate independent review pass by Gemini 4 Neon).
Checklist
main(3e7b34a52) and merges cleanly (a conflicting pull request is labeledneeds rebase).check_no_game_data.pyclean on both source and PR description).docs/design.md, with how it was confirmed. (n/a — GPU ambient stand-in compute pass optimization)@merzleckeier on GitHub · 2026-12-01 15:58 UTC · original
Nonuniform gather readback across both adapters at
e9e8b257+0ff8a532f. All four ambient unit tests passed on each GPU. I then ran main's 8×2 gather and this PR's 8×8 tiled gather against the same 2,304 synthetic cells with varying positions, RGB and weights (including zero weights) and a null depth SRV. Both readbacks wrote all 14,400 points (172,800 finite floats).The readback required an actual D3D12 device. Dispatching only 11 tiled groups vertically as a negative control left exactly the last two rows (3,840 floats) unwritten on each GPU. This exercises the gather kernel and partial-group coverage. The full ambient pass sequence and frame-time effect were outside the fixture.
MEASURED with synthetic inputs. AI-assisted (Codex).
@KelboLive on GitHub · 2026-12-01 17:30 UTC · original · reviewed
Tiling is faithful: accumulation order is unchanged (base 0→2304 step 64,
j0→63), 20×12 groups of 8×8 covers 160×96 ⊇ 160×90, andactiveplus both group barriers keep the90 % 8 == 2tail legal;CELLS = 2304 = 36×64keeps the tile loads in range. Barrier scoping is sound:keep→meanandplace→gathertouch onlycells, and the global barrier beforeraisestill orders gather'spointsand the title's image write ahead of raise's read-modify-write (ambient.rs:614), with the post-raise barrier kept — I found no new raise/resolve race. 632/0/59 on the crate, and the new test passes on the real adapter and on WARP.The test, however, pins the kernel, not the wiring:
Dispatch(20,12,1)(ambient.rs:969) instead of the call-site grid, so shrinking the production dispatch to 20×11 leaves all 632 tests green — I verified it.after(), so deleting the pre-gathercellsbarrier also leaves the suite green — verified.:915), so on a host without one it is a no-op rather than a SKIP.Sharing one grid const between the call site and the test would make the full-coverage assertion guard the wiring, and calling
after()would give the barrier a test.Two notes:
CELLS % 64 == 0is an unstated invariant (an out-of-range load ifCXever stops being 64) — a static assert would pin it.Merge: the only conflict is the appended test at the end of
mod tests, because #2904 merged at 17:14Z and already appendedthe_colour_drops_compile; keep both (and the two closing braces). If #2908 lands first, switch the new test'shost()torequire_host()so it SKIPs loudly.@Kal0s-design on GitHub · 2026-12-01 17:50 UTC · original
Checked on native Windows 11 with the native D3D12 driver (no VKD3D), rustc 1.98.1.
Heads-up: this now conflicts with
main(d2a564b66).fe612066aaddedthe_colour_drops_compileat the end ofambient.rs's tests, in the same spot asgather_dispatches_the_partial_group. It is only the two tests touching; keeping both resolves it. I resolved it that way locally and tested the result.Head
e9e8b257b+maind2a564b66, conflict resolved by keeping both tests:cargo test -p leonida-gpu --lib ambient::on the card: 5 passed, 0 failed.LEONIDA_D3D12_WARP=1(software adapter): 5 passed.gather_dispatches_the_partial_groupalso passes there, so the partial last row is written on WARP too.Barrier scoping. I went through which UAV each pass writes.
keep,meanandplacewrite onlycells,gatherwrites onlypoints, andraisewrites the title's view. So scoping thekeep -> mean -> ...andplace -> gatherbarriers topass.cellscovers every dependency. The global barrier beforeraisecoverspointsand the title's view. Radiance still starts with the global barrier, whichkeepneeds since it reads the title's radiance UAV. I see no missing wait.What the LDS tiling buys on a native driver. Same random 2,304 cells and null depth SRV on both sides;
gatheralone, run 201 times in one list with a UAV barrier between dispatches. Best of 5 rounds, minus a 1-dispatch list. Two runs each:gatherdispatchmain(8x2,Dispatch(20, 45, 1))8x8+ LDS,Dispatch(20, 12, 1))That is about 2.3-2.4x faster for the dispatch, about 0.11 ms a frame when the pass runs. These are wall-clock times around a synchronous submit, not GPU timestamps, so treat them as approximate.
One wording note on the description: the "RED on
origin/main" is the new test dispatching(20, 12, 1)againstmain's8x2shader.mainitself dispatches(20, 45, 1)and covers all 90 rows, so that run shows the test needs the PR's group size. It is not a defect onmain.Not checked: the game.
GPUs tested: one hardware adapter (native D3D12 driver) and WARP.
AI-assisted: yes (Claude Code).
e9e8b257b2to7c7e99b481@lixonik on GitHub · 2026-12-01 21:36 UTC · original
RUN
Independent native Windows 10 + RTX 5070 (Blackwell) verification of
#2893(7c7e99b48) vsmain(1e3e316c5).Verdict
cargo test --locked -p leonida-gpu --lib ambient:: -- --nocapture: 5 passed, 0 failed (includingthe_passes_build,the_colour_drops_compile, andgather_dispatches_the_partial_group).LEONIDA_AB=20,LEONIDA_AMBIENT_ON): 0 errors / 0 device lost on both runs; all three ambient stand-in roles initialized cleanly (Resolve1280x720,Air80x46,Reflect1280x720,level=0.8). On settled standing frames (~4,400--4,550 draws), the GPU-sidecard_busycost of turningLEONIDA_AMBIENT_ONon (on minus off) dropped from +0.70 ms onmainto +0.07 ms on#2893, while whole-frame median was unchanged (no clear difference, as expected on a CPU-bound Series S frame wherecard busy ~26--27 ms < submitting thread ~36--37 ms,gpu_wait 0.0 ms).Setup
621.40), Ryzen 9 5950X (16C/32T), 64 GiB RAM, Windows 10 Pro 22H2 (build 19045).diagprofile (diagnostics,dlss,mimalloc), Series S profile,-NoFrameGen, standing in the world from the same save snapshot,-More @{ LEONIDA_AB = '20,LEONIDA_AMBIENT_ON' }.Measurements (
MEASURED)d3d12_run_fps.py)d3d12_ab_compare.py phases(median, on minus off)card_busy(onvsoff, draws ~4,400--4,550)main(1e3e316c5)gpu_wait 0.0 ms-0.800 +- 1.331 ms(5 pairs, 3 dropped;no clear difference)26.8 / 26.4 / 26.0 msvs on27.0 / 27.2 ms(4 adjacent pairs:+0.700 +- 0.208 ms)#2893(7c7e99b48)gpu_wait 0.0 ms-0.133 +- 0.384 ms(3 pairs, 5 dropped;no clear difference)27.3 / 26.6 / 26.3 msvs on27.2 / 26.8 / 26.4 ms(3 non-overlapping pairs:+0.067 +- 0.088 ms; incl. phase 9:+0.467 +- 0.232 msover 6 adjacent pairs)(Note: whole-frame medians across the two separate runs are within run-to-run variance on a CPU-bound Series S frame; the
card_busyon - offwithin-run delta isolates the GPU cost of the ambient pass itself.)AI-assisted: Antigravity
@MoonEyes on GitHub · 2026-12-02 12:30 UTC · original
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
@MoonEyes on GitHub · 2026-12-02 18:01 UTC · original
Triage of head
7c7e99b48(merge base1e3e316c5, 340 commits behind;git merge-treeagainst currentmain45dc41f95: no conflicts).1 file:
d3d12/crates/leonida-gpu/src/ambient.rs(+143/-26).CI green on the head (6 checks).
Existing verification: @merzleckeier compared main's and this gather on 2,304 synthetic cells on two GPUs; @lixonik verified this head natively (RTX 5070, 5 ambient tests). The conflict @Kal0s-design reported on
d2a564b66is gone: it merges cleanly into currentmain.This check: Not re-reviewed in depth. Render-path change (an LDS-tiled compute pass): @MoonEyes's in-game gate asks for a 300 s run on the current head, and none is posted for
7c7e99b48.I did not build it: the crate is Windows-only (or the C++ runtime's Windows build), so no red/green was run here.
Verdict: blocked (code verified; still needs the in-game run on the current head that the render-path gate asks for).
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@MoonEyes on GitHub · 2026-12-02 18:21 UTC · original
RUN (in game, batch of seventeen render-path pull requests), each head merged with
git merge --no-ffonto main3c106eb2f, in one build: #311115b579756, #29485284c6eae, #26981f188c4f7, #294644bf554fe, #3001d924cbb65, #28320c861595a, #291558e8535cf, #2822d359a2f85, #2896c9c6b103d, #29838278ef1b9, #3115ba5121192, #2945d2c08c14f, #297574512d658, #295126da88e8e, #2800b6ebcedd4, #28937c7e99b48, #3113fa1460b6b(and #30970d7a451ab, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.
AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-12-03 04:51 UTC · original
VERIFY-2893 — en su rama 3 fallos, sobre
mainsólo 1 (el de la iGPU): los otros dos eran de su baseUn fichero, +143/−26, seis días abierto. El método del
AGENTS.md, que hoy ya me ha salvado dos veces:Los dos fallos que no eran de la iGPU desaparecen al aplicar el cambio sobre
main:published(two, two + BLOCK)era un test de su base quemainya arregló, y el otro venía con él.Lo que la PR hace: un pase de cómputo que recoge el
LDSen mosaico para el ambiente (gpu/ambient), y acota los barriers UAV internos a su ámbito. 143 líneas de shader/compute en un fichero: el tipo de cambio que no se puede revisar leyendo el diff sin el contexto del pase, y por eso lo verificado es lo que la suite dice y lo que no.Lo que no verifiqué: el ambiente renderizado — necesita el título, y el mosaico de
LDSes exactamente el tipo de cambio que se ve en la imagen y no en un test.Y lo que esto añade al método: «3 fallos» en una rama de seis días no es «3 fallos en el PR», y la diferencia entre los dos números es el
cherry-pick— el segundo comando de esta noche que convierte un rojo alarmante en un dato limpio.@MoonEyes on GitHub · 2026-12-03 17:26 UTC · original
In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #2915, #2896, #2893 and #2889 merged into main
09273248c; this PR tested at its current head7c7e99b48. Series S 1080, DLSS FG 2x,play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s, screen kept on.AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
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.