mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #2391] d3d12: slot-133 shadows pass over the title's reserved pages until the journal names them (RT-SHADOW-RESERVATION-SKIP) #2392
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2392
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2391
Author: @azsekazvamdimitar
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:shadow-reservation-skip📝 Commits (1)
a525962d3d12: slot-133 shadows pass over the title's reserved pages until the journal names them (RT-SHADOW-RESERVATION-SKIP)📊 Changes
5 files changed (+194 additions, -16 deletions)
View changed files
📝
runtime/README.md(+1 -1)📝
runtime/shims/d3d12_vulkan_device.cpp(+41 -12)📝
runtime/shims/xmem.cpp(+13 -2)📝
runtime/src/title_page_watch.h(+82 -1)📝
runtime/test/d3d12_existing_heap_test.cpp(+57 -0)📄 Description
Claimed in the coordination issue as: RT-SHADOW-RESERVATION-SKIP (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7198477484)
Note: #1867 changes the same lines of the walk's skip rule. This applies to
mainwithout it; whichever lands second takes both clauses.What and why
Under Wine the slot-133 shadow walk spends most of its time in VirtualQuery of pages that are only reserved. A local census on my retail boot put them in the stream pools' 16 GiB physical-page windows: each unmapped 64 KiB slot is its own placeholder after xmem unmaps a view, and the walk asked about 450-7,500 of them a refresh. Each query takes 1.5 us while nothing else maps memory and 15-70 us (single ones 200-400 us) while the title's mapping threads hold Wine's virtual-memory lock, so after the story load the walk took 100-330 ms a submission.
Nothing but xmem's own calls and the title's memory calls (VirtualAlloc, VirtualFree, VirtualProtect, the XMem functions, all shimmed; the title imports no other memory API) changes a page inside those reservations, and every one of them is recorded in
title_memory_map. This leans on the assumption indocs/runtime_imports.mdthat nothing commits into a window with kernel32's VirtualAlloc, which a placeholder refuses. So:leonida::title_reservations(title_page_watch.h). Every successful release forgets its range, also one xmem's own tables missed; a new reservation drops any stale range it overlaps; a window replaced by ordinary memory is forgotten.MEM_RESERVE,MEM_PRIVATE) marks it settled and passes over it like an unchanged page until the journal names it, a release moves the registry's generation, or the walk is forced (LEONIDA_SHADOW_FULL_WALK=1, or a journal that overflowed). Aliased, pinned and write-watched pages never settle.#417 (commits into windows) stays compatible: such a commit goes through the journalled VirtualAlloc shim, and its releases through the free shim that forgets the range.
Two shapes I tried first and dropped: passing over every page last seen uncommitted, trusting the journal everywhere, misses commits made inside ntdll (heap growth), and that boot hung; a per-refresh cache of uncommitted runs shared across trackers never answered a query in the game.
The same retail boot, RTX 3090, GE-Proton, main
a73a57e13with #1851, #1957, #1918, #2097, #1867 and #2117, shaders translated with llvm-mc 23.1.6, synchronous pipelines,LEONIDA_RT_AS=off, the ray-hit shading programs skipped (LEONIDA_SKIP_COMPUTE),LEONIDA_DEVICE_FAULT=2, title watchdog kicked. First world minute (120-270 s; the world starts at about 190 s):Later in the world the walk without this reached 125-330 ms a submission; none of the runs with it got that far, because on this setting most runs end in a GPU hang (checkpoints in
sr_denoisingand the particle light-atlas pass). Without the change 2 of 7 runs went the full 25 minutes; with it none of 5 did (a title access violation at the world start, which contributes only pre-world refreshes to the table above, and hangs). To tell whether the change is behind that:Tested
d3d12_existing_heapgains a check: the reserved pages of a registered reservation are asked about once and then not again; a page committed there (and journalled, as the title's VirtualAlloc shim does) arrives at the next submission, a decommit reads zeros, and after the reservation is forgotten the pages are asked about again. With the pass-over clause removed from the walk it fails at the query count.d3d12_existing_heap(with and without write watch),d3d12_host_prefix,d3d12_mapped_plane_async,d3d12_xmem_placed,d3d12_title_va(+_shadow) andxs_proxy_mockpass under WineHQ 11.22 (winewayland) and GE-Proton11-14 (winex11);d3d12_existing_heapalso withLEONIDA_SHADOW_FULL_WALK=1.main935a2cd5b.GPUs tested: NVIDIA GeForce RTX 3090, driver 590.48.01, Debian 13 (Linux 6.12), Wine/Proton as above.
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.