Repository navigation
runtime: the CPU half of Xbox physical pages, with write-fault dirty tracking - #5381
maxxgabriel wants to merge 16 commits into
Conversation
|
AI-assisted independent GPU check of head With
Scope: the local test copies disabled the timing/benchmark blocks (including the paging queued-work timing check); the paging test substituted a bounded four-page scattered-bind check, and the physical test added CPU assertions without changing the GPU upload/readback path. No performance claim, unbounded stress, or end-to-end title integration is covered. The separate Windows CPU mapping/dirty-rearm review is claimed by Hiiva; this is not a full |
Hiiva
left a comment
There was a problem hiding this comment.
Independent Windows CPU review of 22afe9c5daa64ac6709e31a6a9378e47ec52e054.
The standalone probe includes the unmodified runtime/src/xbox_physical.h. Its 41 positive checks pass: aligned aliases share bytes, a first write marks the physical page, take_dirty() protects both views again, another alias write is tracked, invalid/unallocated page indices and oversized batches leave existing mappings unchanged, aligned remap/unmap preserves the other alias, and destruction releases the reservations. A separate ignored copy with only the take_dirty() re-protection call omitted fails the re-protection assertion, so this check exercises the new behavior.
One nonblocking boundary observation at runtime/src/xbox_physical.h:114: map(base + offset, {replacement}) accepts offsets 1, 4096, and 65535 and changes the preceding 64 KiB slot. This occurs with both a fresh placeholder and an existing mapping. The native MapViewOfFile3 controls reject those starts (1132, 487, 1132), preserve the placeholder, and subsequently accept the aligned mapping. The helper's integer slot calculation explains the observed rounding.
I am not treating that comparison as a blocking Xbox or game defect. The helper has no explicit invalid-start rejection promise, its current test callers supply aligned addresses, and the XMem/device wiring is deliberately deferred. Making the aligned-address boundary explicit before adding callers would avoid relying on accidental rounding.
Scope: original synthetic pagefile sections and placeholder reservations only, no game files or GPU execution. This does not replace the PR's GPU coherence/validation test. Windows 11 x64 build 26200, MSVC 19.44.35228, Windows SDK 10.0.26100.0; Vulkan headers 1.4.363.0 were used to compile the header, with no Vulkan calls. AI-assisted: yes.
…gs, lock the queue in bind_sparse_ordered
22afe9c to
df8b3cc
Compare
|
Tested 4b1252c natively on Windows 11 Pro 26200 (MSVC 14.44.35207, Vulkan SDK 1.4.363.0), merged onto
No game files. AI-assisted (Claude Code). |
… or empty arena, and an empty submit
Kam471
left a comment
There was a problem hiding this comment.
Reviewed head 4b1252c5ef.
Stack: contains #5378's tip 6571ec5533 plus 3 commits (correctly rebased; git merge-base --is-ancestor pr/5378 pr/5381 is true).
Build: vcvars64 + Ninja + Vulkan 1.4.363, then
cmake --build build --target vk_xbox_paging_test vk_xbox_physical_test
.\build\vk_xbox_physical_test.exe-> PASS: one page at two VAs; CPU writes P0..P3 visible through arena VA 0x300000000 after one upload; GPU fill -> readback P2 = 0x5a; first write fault 2.51 us; take_dirty 256 pages 0.161 ms; 16 MiB upload 8.34 ms..\build\vk_xbox_paging_test.exe-> PASS (181 calls, 20144 binds), the #5378 suites still green on top.
Inert: xbox_physical.h is included only by xbox_paging.h; no src caller; CMake adds test executables only. Dirty tracking is exercised by the test rather than claimed.
Verdict: LGTM, merge after #5378.
4b1252c to
56541e4
Compare
…64 GiB of sparse address space
…staged readback, and check the device functions
56541e4 to
02392f1
Compare
|
Ran an automated multi-agent review (Claude Code ultrareview) on this PR's current head. It found 17 candidates and refuted most of them; 10 were confirmed. All are graded nit, but only because nothing calls Correctness
Lifetime
Performance
I didn't run anything for these; they come from the review's code read. AI-assisted (Claude Code). |
|
finding for #5381 (D3D-546), from a check of how Leonida keeps CPU and GPU copies of shared pages in sync. It's a design note, not a full review. With per-page dirty tracking,
A test that would catch it:
Possible fixes: track GPU-written ranges per page and either read them back before the upload (merge) or upload only the CPU-dirty byte ranges instead of whole pages. It isn't reachable on |
|
Tested 02392f1 on Intel UHD Graphics 770, driver 32.0.101.7088, with LEONIDA_VK_VALIDATION=1 and the Khronos validation layer inserted by the loader, and on NVIDIA GeForce RTX 4080, driver 617.42, without validation: vk_xbox_physical_test and vk_xbox_paging_test exit 0 and print PASS on both. The UHD 770 run prints "device: Intel(R) UHD Graphics 770 (validation on)" and "validation errors: 0". On the RTX 4080, vk_xbox_physical_test logs "CPU writes to P0..P3 read back through arena VA 0x300000000 after one upload: match" and "GPU fill of arena page -> readback -> CPU view of P2 reads 0x5a". vk_xbox_physical_test prints only PASS on success, so its other checks are not itemised. AI-assisted. |
…over CPU writes, start GPU halves from the CPU half
… for kernel writes, free pages
|
Windows x64 / Radeon RX 580 / driver 31.0.21924.61 validation: this PR's exact head 9b11bcc built with MSVC 14.44 and passed vk_xbox_physical_test on physical hardware. Shared CPU aliases, dirty tracking, CPU-to-GPU upload and GPU-to-CPU readback passed. I also integrated the backing locally with main 1cc6e3c plus startup reservation/large-page work. That required adapting the sparse-bind queue path to retain the newer wait pins, resource types and cancellation behavior. The integrated runtime built, xmem_test passed 170 checks, and vk_xbox_paging_test plus vk_xbox_physical_test both passed. The integration branch is https://github.com/aidity/Leonida/tree/integration/physical-pages-current for comparison; it is not a competing implementation of this PR. Measured integrated upload of 256 dirty pages (16 MiB) was about 18 ms on this GPU. The title-facing committed graphics-allocation wiring is still absent, so this does not claim the game's startup pool is supported or that gameplay works. No game inputs or trace files are attached. AI-assisted with Codex. |
|
Call-site evidence for the wiring this PR leaves open ("they get wired once a call site shows their arguments"), from the retail
I'm not writing a second store. Once this PR lands I can do the thin |
|
Follow-up validation: the 2/4 MiB reserve-alignment change is at aidity@aa03123b6 (layered on our integration branch). It adds an optional alignment argument to PhysicalPageStore::reserve, validates power-of-two/aligned fixed addresses, and supplies VirtualAlloc2 address requirements for anonymous coarse-aligned windows. Default 64 KiB behavior is preserved. The test covers 2/4 MiB reserve addresses, mapping/writing a page, dirty tracking and invalid alignment requests. Both vk_xbox_physical and vk_xbox_paging pass on RX 580, driver 31.0.21924.61, Windows/MSVC, alongside the XMem and loader integration checks. Please consider folding the alignment argument into this PR; it is needed by the console's coarse-page requests. No duplicate PR opened. |
|
Tested 9b11bcc on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass
AI-assisted (Claude Code). |
Claimed in the coordination issue as: D3D-546 (#313)
Depends on: #5378 (this branch includes its commit; the diff of its own is the second commit)
What and why
On the console the CPU and GPU address the same physical page. Here the GPU side has to be device-local, so
runtime/src/xbox_physical.hgives each page two halves and keeps them coherent:PhysicalPageStore): a 64 KiB slot of one pagefile-backed section. Views are placed at the title's VAs over placeholders (VirtualAlloc2withMEM_RESERVE_PLACEHOLDER,MapViewOfFile3withMEM_REPLACE_PLACEHOLDER), so one page can be mapped at several VAs.PhysicalGpu): aPagePoolpage, allocated on first use.take_dirty()write-protects dirty pages again, andrecord_uploadcopies them ahead of the title's commands.record_readbackthenfinish_readback.This is the mechanism
XMemAllocatePhysicalPagesandXMemMapPhysicalPages[Scatter]map onto; they get wired once a call site shows their arguments.Details worth a look:
split()checks that withVirtualQuery.map()and the record calls check the whole call before changing anything, so a bad page index or an exhausted pool leaves nothing half-applied.PhysicalGpuis destroyed.Measured on a GTX 1660 SUPER (median of 8):
take_dirtyof 256 pagesTested
vk_xbox_physical_test(Windows only): PASS, and 0 errors underLEONIDA_VK_VALIDATION=1. Covers a page mapped at two VAs, CPU writes read back through the arena, and a GPU fill read through a CPU view.vk_xbox_paging_test: still PASS.NVIDIA GeForce GTX 1660 SUPER, driver 610.88, Windows 11, MSVC 14.51, Vulkan SDK 1.4.363.1.
Checklist
docs/design.md, with how it was confirmed. (No translator change.)