Repository navigation
feat(gpu): alias title memory outside buffers instead of copying it (VICTORY_ALIAS_LOOSE=1) - #669
Merged
Merged
Conversation
`VICTORY_ALIAS_LOOSE=1` (off without it): a window of title memory
outside any buffer object is remapped onto its host buffer, zero copy,
where every page of the window is committed.
Such memory is Grand Theft Auto VI's interface vertices, from its own
allocator. It is not a buffer the title asks the device for, so nothing
aliases it at allocation the way `XMemVirtualAlloc` does, and each
window is copied again on every submission that reaches it.
The whole window must be committed because `alias_region` preserves the
contents by reading every page of it first; the check already there only
vouches for the address asked about.
It pays only with small loose windows, which are now the default on a
Mac with 32 GB or less: a 256 KiB window is committed whole far more
often than a 4 MiB one. In the world with 4 MiB windows 19 regions were
aliased; with 256 KiB windows, 2,793.
Measured on an M5 MacBook Air (16 GB), macOS 27.2, Series build 1.0.2.1
at 1280x720, with `VICTORY_FAULT_TRACKING=1` and 256 KiB windows:
aliased regions 9 -> 1,902
loose window memory 3,527 MB -> 541 MB
copy time, heaviest frame 7,248 ms -> 2,033 ms
copy time, 5 heaviest 4,965 ms -> 1,771 ms (mean)
No `mach_vm_remap` failures, no host GPU failure and no exception across
the runs. The runs were compared by elapsed time, not frame for frame,
so take the ratios as approximate.
Off by default. A window is not an allocation of the title's: it is cut
around whatever address a draw referenced, so nothing tells us when the
title frees or reuses the memory under it, as `XMemFree` does for the
buffers aliased at allocation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
A Mac number for this and #653, one run each on an M3 Max (48 GB, CrossOver 26.1, D3DMetal 4.0b3, Series X). Main
The largest refreshed copies still say |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
VICTORY_ALIAS_LOOSE=1(off by default): a window of title memory outside any buffer object is remapped onto its host buffer, zero copy (alias_region), where every page of the window is committed, instead of being copied on every submission that reaches it.That memory is Grand Theft Auto VI's interface vertices, from its own allocator. It is not a buffer the title asks the device for, so nothing aliases it at allocation the way
XMemVirtualAllocdoes.alias_regionpreserves the contents by reading every page first, so one uncommitted page would fault. The existing check only vouched for the address asked about.Measurements
M5 MacBook Air (16 GB), macOS 27.2, Series build 1.0.2.1, 1280x720,
VICTORY_FAULT_TRACKING=1, 256 KiB windows:No
mach_vm_remapfailure, host GPU failure or exception across the runs. The runs were compared by elapsed time rather than frame for frame, so take the ratios as approximate.Why off by default
A window is not an allocation of the title's: it is cut around whatever address a draw referenced, so nothing says when the title frees or reuses the memory under it, as
XMemFreedoes for buffers aliased at allocation.Tests
x86_64-pc-windows-gnullvmon the workspace with and without--all-features, andcargo xtask policyis ok.Not run on this exact base: the measurements above; rebased onto current main, where the only conflict was the new loose-window default next to it.
Re-test
VICTORY_FAULT_TRACKING=1into the world with and withoutVICTORY_ALIAS_LOOSE=1, comparing thehost buffer copies heldandcopies per framelines.🤖 Generated with Claude Code