Repository navigation
xmem: map a run of physical pages over several placeholders - #76
SuryaK5125 wants to merge 1 commit into
Conversation
|
Tested
AI-assisted (DeepSeek V4.1 Flash coding agent). |
b44fd4b to
dea90cc
Compare
|
I ran the Environment
Commands cargo xwin test -p victory-hle --target x86_64-pc-windows-msvc --no-run
WINEPREFIX=... "$PROTON/files/bin/wine" victory_hle-<hash>.exe --test-threads=1Results (
This only covers synthetic tests. I didn't check a title load under Proton. |
…ders Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Merge candidate. Recommending a look, not approving. The head is the same as at the earlier note, and it still merges cleanly onto
CI: On your reply: thanks for the side-by-side comparison. It makes the choice clearer and leaves this verdict unchanged. Generated by Claude Code |
…st-76-111a GPU: test alias view over compute-written texture (Marvisak#76)
MapViewOfFile3 with MEM_REPLACE_PLACEHOLDER replaces exactly one placeholder: the range must be the placeholder's own. map() split the placeholder around the range and mapped one view over it, so it worked only when the range lay in a single placeholder. Every mapping leaves its reservation split at its ends and unmapping does not join the pieces, so after a partial unmap, a scattered mapping or a shorter earlier run, a run over those pages failed with ERROR_INVALID_ADDRESS and XMemMapPhysicalPages returned NULL, its range already unmapped. map() now splits only at the run's two ends and gives each placeholder in the range a view of its part. Placeholders are never coalesced: the host also coalesces placeholders of separate reservations, and pieces a title split itself would stay joined after the unmap. If a view fails, those made before it become placeholders again. The split call also frees memory that replaced a placeholder back to one, committed pages included, so split_at() splits only where everything below the split point is reserved. The GPU side is told once that the whole run is remapped, then each page of each view is linked with the other views showing it, as for a single view. New tests: a run remapped after a partial unmap, a run from one placeholder into the next, a title-split piece kept through a map and an unmap, a run over two adjacent reservations that leaves each its own allocation, a run over several placeholders that links and then forgets its aliases, and a failed run that is rolled back without touching committed memory next to it. All but the last fail on main (XMemMapPhysicalPages returns NULL). cargo test -p victory-hle passes on Windows 11.
dea90cc to
ce93a81
Compare
|
Rebased onto 940d32f (ce93a81). All 149 HLE tests and CI pass. Since #1224 addresses the same issue, I tested both approaches against the same upstream base using six regression tests:
The three failures on #1224 involve a run starting inside a placeholder, preservation of title-created placeholder boundaries, and preservation of adjacent independent reservations. The first appears fixable independently of the coalescing approach. There is a performance trade-off: in a synthetic Windows debug-build benchmark with 16 pages across 16 placeholders, #76 took approximately 100/77 µs for map/unmap, versus 31–54/24–29 µs for #1224. At four placeholders or fewer, the difference was close to measurement noise. Wine performance was not measured. Coalescing only internally created splits might eventually combine the advantages of both approaches, but would require additional reservation tracking. All testing was synthetic, without game files. |
XMemMapPhysicalPagesfails withERROR_INVALID_ADDRESSwhen mapping a run of physical pages across multiple placeholders. This can happen after a partial unmap or scatter mapping, since unmapping doesn't join the placeholders back together.Instead of mapping the entire run as one view, this change maps each placeholder separately and rolls back if a mapping fails. Existing placeholder boundaries are preserved, since coalescing can also join unrelated reservations.
The split operation now checks that the affected memory is reserved before proceeding to avoid freeing committed pages.
Rebased onto current main (940d32f) as ce93a81. The upstream alias tracking in
map()is kept: the GPU side is told once that the whole run was remapped, then each page of each view is linked with its other views, as for a single view.Testing (ce93a81):
XMemMapPhysicalPagesreturns NULL).cargo test -p victory-hleon Windows 11: 149 passed, 0 failed.xmem.rs. rustfmt is clean for the changed lines.Earlier testing (dea90cc, the previous revision on 9aef3d9):
Also checked compatibility with #53 and #61. All three changes together passed the HLE tests at dea90cc.