HLE: a persistent view above the title's memory, three-state commits, and a write generation per page #871
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/872"
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 fxceless/victory-fork. Originally posted by HailLucifer666 on 2026-11-25T11:24:39Z.
Three changes to the physical-page path, none of which changes it by default (
VICTORY_XMEM_PERSISTENT_VIEWstill off):The view's address. It used to be wherever
MapViewOfFileput it, which can be inside the range the title itself owns — below 40 bits, the range decision 0001 says title structures must live in. A view there either takes an address the title is about to ask for, or makes our own mapping look like a title address to the title's own pointer arithmetic. It is now reserved withVirtualAlloc2's address requirement from 1 TiB toGetSystemInfo().lpMaximumApplicationAddress(asked, never assumed) and mapped into that reservation withMapViewOfFile3. A view that comes back below the ceiling anyway is released and the caller keeps its temporary view — the host is not trusted to honour the requirement.Commit state, three states per page instead of one bit. The bit recorded "committed" but could not promise anything at the moment it mattered: the DirectStorage workers write these sections concurrently, and a thread that lost the race to
VirtualAlloc(MEM_COMMIT)would store into a page whose commit was still in flight. Pages are nowFREE→COMMITTING(claimed by one thread) →COMMITTED(set only afterVirtualAllocreturned); a loser spins onCOMMITTINGinstead of writing. A bounded spin then gives up to the temporary path, which is always correct, so a thread that died mid-commit cannot hang the title.A write generation per 64 KiB page. Bumped after the bytes are written (release), read with acquire: an unchanged digest is a promise about the bytes, not only about the counter.
physical_generation_digest(pages, offset, len)folds a range into one number — the input phase F needs to stop hashing texture memory it already knows. It has no caller here yet beyond its test, and theallow(dead_code)says so rather than pretending otherwise.Tests (3, all device-free):
persistent_view_maps_above_the_title_memory_ceiling— the view lands at or above 1 TiB, a write through it is in the section's pages, and the rule refuses one page below the ceiling.concurrent_commit_state_never_exposes_an_uncommitted_page— eight threads commit the same four uncommitted pages; all eight succeed and every byte each wrote is still there.dirty_generation_digest_changes_on_write_and_stays_stable_when_clean— a physical write moves the range's digest but not an untouched page's; a second identical write moves it again; a page window's bytes count when the window goes; unknown pages and ranges past the end are refused./keeprobes, each restored byte-identical:a write must showa page window's bytes must showabove_title_memoryalways trueLowestStartingAddressset to nullThat last row is the honest part: this host's allocator is already top-down, so it returns an address above 1 TiB with or without the requirement. The requirement is a belt no test here can reach; the predicate is the pin, and that is the one the probe breaks. Said out loud rather than reported as a passing probe.
Gate on
2853f67e:cargo test -p victory-hle xmem::→ 22 passed;cargo test -p victory-hle→ 108 passed, 0 failed; bothclippy --workspace --all-targetspasses red only onmain's three pre-existing lints;xtask4 passed.Not covered: no run in the game, so whether the high address helps anything in practice is unmeasured.
VICTORY_XMEM_PERSISTENT_VIEWstays off.Imported from fxceless/victory-fork. Originally posted by MamaLeVrai on 2026-11-25T12:23:15Z.
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head
2853f67intomainf85101bin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warningsfails with exactly the errorsmainitself has on this machine (placed_filler_twins,depth_written, a sort; PR #841 fixes them), also with--all-features; this PR adds none.cargo test --workspace --locked: run 1: stopped atindirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields(the one that fails onmainitself most runs here (PR #849 and #847 fix its assertion)); run 2: stopped atindirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields(the one that fails onmainitself most runs here (PR #849 and #847 fix its assertion)) (mainalone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
Imported from fxceless/victory-fork. Originally posted by HailLucifer666 on 2026-11-26T13:56:58Z.
Rebased onto the new
#231head (ad67d255); this head is now1e653717(--ontoso only this PR's commit replayed). One import conflict, resolved as the union (GetSystemInfo/SYSTEM_INFOplusGetCurrentProcess/GetCurrentThread), a stray brace removed from theDropmatch, and one new-toolchain lint fixed (let...elseexactly equal to?in the view-size rounding). Verified:cargo checkandclippy -D warningson victory-hle clean;victory-hle xmem::24 passed, 0 failed (the 21 from #231 plus this PR's 3).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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.