Skip to content

Present: make the presented texture resident before the display command buffer reads it (pink window, GPU page faults) - #89

Closed
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:present-residency
Closed

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:present-residency

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

This came up while bringing up Super Smash Bros. Ultimate (#65). It is a general fix for every game.

Problem

Smash presents its window texture in its first frames, before anything has drawn into it. The present path creates the host texture on that first resolution and adds it to the residency set (res_add), but only a submission commits that set. The display command buffer therefore sampled memory the GPU didn't have mapped yet:

  • The display command buffer failed with kIOGPUCommandBufferCallbackErrorPageFault at the first presents.
  • After a few such faults, macOS ignored every command buffer of the process (kIOGPUCommandBufferCallbackErrorSubmissionsIgnored).
  • The window stayed pink.

Headless runs never present to a window, which is why the problem only showed in windowed runs.

Change

The present commits the residency set right after resolving the presented texture (nvn_mtl.m). res_commit costs nothing when nothing changed. docs/agents/04-graphics.md has the case.

Checked

  • Smash 13.0.5, windowed on the Mac: the opening movie, the DLC first-boot screens, the title, the main menu and a match render correctly, with no GPU errors.
  • Breath of the Wild, windowed: with this one change on an older base (the one its Mac shader library on this machine matches), it reaches the title at 60 fps with no GPU errors.
  • This branch: the Mac host builds and dm/tools/tests pass.

…re, for every game. Super Smash Bros. Ultimate 13.0.5 presents its window texture in its first frames before drawing into it; the texture was made on that first resolution in the present path and joined the residency set (res_add), which only a submission commits, so the display command buffer sampled it outside the committed set: kIOGPUCommandBufferCallbackErrorPageFault at the first presents, after which macOS ignored every command buffer of the process (194 command buffer and 174 upload errors in the user's run) and the window stayed pink. Headless runs never present, which is why they looked right. res_commit is free when nothing changed. Smash windowed now: the opening movie, the DLC first-boot screens, the title, the main menu and a first match render right, no GPU error. Breath of the Wild windowed with only this change on the sync-lag branch its libraries match: its title, 60 fps, no GPU error. docs/agents/04-graphics.md says so
@seedds

seedds commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Merged into main as 43b35a6 (cherry-picked onto main, authorship kept). Thanks! #94 carries its own copy of this commit, so rebasing #94 onto main should drop it there.

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.

2 participants