Repository navigation
Conversation
|
Nonuniform gather readback across both adapters at e9e8b25 + 0ff8a53. 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
left a comment
There was a problem hiding this comment.
Tiling is faithful: accumulation order is unchanged (base 0→2304 step 64, j 0→63), 20×12 groups of 8×8 covers 160×96 ⊇ 160×90, and active plus both group barriers keep the 90 % 8 == 2 tail legal; CELLS = 2304 = 36×64 keeps the tile loads in range. Barrier scoping is sound: keep→mean and place→gather touch only cells, and the global barrier before raise still orders gather's points and 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:
- It hardcodes its own
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. - It never calls
after(), so deleting the pre-gathercellsbarrier also leaves the suite green — verified. - It returns silently when no device exists (
: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.- "64× fewer global UAV reads" is per-thread; the total is 60× (14,400 → 15,360 threads, 33.2 M → 0.55 M cell loads). Worth correcting in the body.
Merge: the only conflict is the appended test at the end of mod tests, because #2904 merged at 17:14Z and already appended the_colour_drops_compile; keep both (and the two closing braces). If #2908 lands first, switch the new test's host() to require_host() so it SKIPs loudly.
|
Checked on native Windows 11 with the native D3D12 driver (no VKD3D), rustc 1.98.1. Heads-up: this now conflicts with Head
Barrier scoping. I went through which UAV each pass writes. What the LDS tiling buys on a native driver. Same random 2,304 cells and null depth SRV on both sides;
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 Not checked: the game. GPUs tested: one hardware adapter (native D3D12 driver) and WARP. AI-assisted: yes (Claude Code). |
Claimed 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)