Skip to content

perf(gpu): alias title buffers by default under Rosetta with D3DMetal - #322

Merged
pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
earpjonathan:gpu/alias-buffers-default
Nov 26, 2026
Merged

pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
earpjonathan:gpu/alias-buffers-default

Conversation

@earpjonathan

Copy link
Copy Markdown
Contributor

Sent again after #293, as suggested there. It is now rebased on main, and there is an in-game run on D3DMetal in #131: #131 (comment)

VICTORY_ALIAS_BUFFERS (#207, from #204) is now on by default under Rosetta with D3DMetal, and never with WARP. VICTORY_ALIAS_BUFFERS=0 keeps the host copies. The start-up probe still falls back to the copies wherever mach_vm_remap onto a D3DMetal buffer does not work, so those hosts behave as before.

Why: with host copies, the pages that shaders wrote in a submission are copied back into title memory after the submission runs.

  • Each copy-back opens the page's write guard and closes it again, under the guard lock. Under Wine that costs one VirtualProtect per 64 KiB view.
  • This is part of the queue's post-run work, which runs while HELD is locked.
  • The submission's bottom-of-pipe writes (Written, list::defer_write) land only after it.

So held work on other queues that waits for those values waits for the copy-back too, and so does every queue call behind HELD. Aliased buffers need no copy-back and no refresh, so none of this happens for them.

In the game (M5 Pro, D3DMetal 4.0 beta 3; details and caveats in the #131 comment)

  • With aliasing, 7 title buffers (4.82 GB in all) were aliased at start-up in every run.
  • The world-load stall was rarer but not gone: 1 stall in 3 aliased runs, against 5 watchdog stops in 9 runs without aliasing.
  • The closest pair of 10-minute runs gave 561 ms against 615 ms a frame, 327 MB against 448 MB copied a frame, and 21 ms against 33 ms of copy-back. The two runs are different builds, so not all of that is aliasing.
  • The saved frames show the same shot. A translucent foreground layer is lighter in the aliased run, and two stills can't tell timing from rendering.

Changes

  • alias::decide_enabled takes the switch as Option<bool>: unset is on.
  • Tests: the existing cases now set the switch. New cases leave it unset and check that aliasing is on under Rosetta only, and never with WARP.
  • docs/macos.md: the switch moves out of "Optional switches", none of which changes the default, into a section of its own that documents VICTORY_ALIAS_BUFFERS=0.
  • VICTORY_PHYSICAL_TILES (Back XMem physical pages with CPU-visible tile heaps on Rosetta #275) has its own switch and is unchanged.

Tested (on the rebased branch)

  • Full Wine suite (tools/macos/test-wine.sh --workspace --no-fail-fast, CrossOver 26.3's wine with Wine's own d3d12): 1098 passed, 0 failed, 25 ignored.
  • cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features, for x86_64-pc-windows-gnullvm.

AI-assisted, prepared with Claude Code.

🤖 Generated with Claude Code

VICTORY_ALIAS_BUFFERS is now on unless set to 0, under Rosetta with
D3DMetal only (never WARP); the start-up probe still falls back to the host
copies where the remap does not work. Aliased buffers need no copy-back
after a submission, which otherwise runs under HELD before the submission's
bottom-of-pipe writes land. docs/macos.md gives it a section of its own,
out of the table of switches that change nothing by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derz92

derz92 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

For the record, since my earlier VICTORY_ALIAS_BUFFERS=1 run on #207 looked bad: that build also had #279, which on its own freezes this title's loading here. So it says nothing reliable against aliasing. I'm rerunning it on M5 Max, macOS 26, D3DMetal 4.0 beta 3, on main with #279 reverted, and will post the pair (with and without) here.

🤖 Generated with Claude Code

@pragyaangaur

Copy link
Copy Markdown
Owner

Thank you for the in-game run and for the honest caveats. That is the evidence I asked for, so this is merged. VICTORY_ALIAS_BUFFERS=0 is the way back. If anyone sees a regression with it on, please say so on #131.

@pragyaangaur
pragyaangaur merged commit a1dd5dd into pragyaangaur:main Nov 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants