d3d12: one guarded copy per run of adjacent written geometry tiles (RT-GEOMETRY-READBACK-RUN-MERGE) #2085
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2085"
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 ubiquitarianism/leonida. Originally posted by BubsMcgee on 2026-11-25T19:50:40Z.
A
GeometryViewsrefresh copies only the 64 KiB tiles the title wrote (the page diffing already there), but it reads each written tile with its own readability probe and guarded copy. When the title writes a run of tiles across tile boundaries, that is one probe and one copy per 64 KiB for data that is contiguous in title memory.This groups the written tiles (already in address order) into maximal runs whose addresses differ by one tile, and reads a run a ready view needs as one guarded copy. The per-tile pass then reuses those bytes through
read_tile(). A run that cannot be read whole (an uncommitted page inside it) falls back to the per-tile reads, so the zeroing behaviour is unchanged. Whole-view refreshes (LEONIDA_GEOMETRY_WHOLE_VIEWS=1) read nothing here, as before.Same behaviour as DexNom/VIctory's
copy_fetch_runs(crates/victory-gpu/src/host.rs, GPL-3.0-or-later, commit570a941), re-implemented for this header; no identifiers or code copied.docs/related_projects.mdalready credits the VIctory readback work.Files
runtime/shims/d3d12_geometry_views.h:read_run()/run_needed()and the run grouping inrefresh().runtime/test/geometry_views_test.cpp: case 5, two address-adjacent written tiles of one view are one 128 KiB copy (case 4's non-adjacent tiles stay two 64 KiB copies).Tests
geometry_views_test: 14/14 checks pass (synthetic, fake Vulkan device, no game data or GPU).gta6rt_d3d12_combuilds (MSVC 19.44, Windows 11 26300; RTX 3080 Ti on 616.64 present but not needed by the test).Claimed as
RT-GEOMETRY-READBACK-RUN-MERGEin the coordination issue. Independent of #1678, which touches onlyd3d12_title_buffer_windows.h. No game data. AI-assisted (opencode). Depends on: none.Imported from ubiquitarianism/leonida. Originally posted by Snooozs on 2026-11-25T20:01:44Z.
From the code at this head (
runtime/shims/d3d12_geometry_views.h), not run:written_vas_is cleared at the end ofrefresh()(line 354),written_at its start. If anything in between throws (tile_scratch_.resizeinread_runorread_tile, or the copy functor), the next refresh starts with an emptywritten_and a filledwritten_vas_, so the loop overwritten_vas_.size()indexeswritten_[w]past its end, and the stale addresses are read again. Clearing both at the start closes it.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-25T22:23:49Z.
Code review at
82169e0e0, plus a heads-up on an overlap with #2094 (RT-GEOMETRY-VIEW-EVICTION, mine), which rewrites the same part ofrefresh().written_andwritten_vas_are both cleared at the start ofrefresh(), and a run is capped at 1 MiB (kMaxRunBytes).run_needed()readswritten_[i]->viewsthrough the rawconst Tile*pointers. In #2094 those pointers are gone on purpose:refresh()letsmutex_go every 64 tiles, and with evictionretire_range()can erase a tile fromtiles_in that window, so aTile*taken before the unlock can dangle. #2094 keeps onlywritten_vas_and looks each tile up again (tiles_.find(va), skipping a missing one and any!aliveview). Whichever of the two lands second has a textual conflict here, and resolving it by keepingwritten_would bring the dangling pointer back. Doing the same lookup inrun_needed()now makes this PR independent of the order: On main today nothing erases a tile during the walk, so this is not a bug at this head, only at the merge.If #2094 lands first I am happy to send the rebase of
read_run/run_neededonto it, or to review yours;geometry_views_testcan run both together.Measured:
geometry_views_testat82169e0e0passes 16/16 checks, 3/3 runs, on a GTX 1050 Ti (Windows 10 19045, NVIDIA 582.66, MSVC RelWithDebInfo).git merge-treeof this head with #2094 (6fd430ebc) conflicts inruntime/shims/d3d12_geometry_views.handruntime/test/geometry_views_test.cpp.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T12:42:28Z.
@BubsMcgee this PR now conflicts with
main(runtime/shims/d3d12_geometry_views.h,runtime/test/geometry_views_test.cpp). Could you mergemaininto your branch (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/2085#issuecomment-7176309868. If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:40:28Z.
Carried as #2733 because of the conflict with main after #2566; @BubsMcgee, if you come back, say so and the carry is dropped.