Metal: expose transaction presentation completion#9828
Draft
yay wants to merge 1 commit into
Draft
Conversation
53b91ae to
2dbc941
Compare
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.
Why
This came out of chasing a particularly slippery macOS live-resize race in egui.
When a
CAMetalLayeruses transaction presentation, AppKit can report that native live resize hasended while the final transaction-presented drawable is still in flight. If the client disables
transaction presentation and reconfigures its surface at that point, the window can briefly stop
accepting interaction and then adjust to a slightly different size when the delayed drawable is
finally shown.
A timer or an extra event-loop turn made the problem less frequent, but did not make it reliable.
The useful synchronization point is Metal's own confirmation that the final drawable was
presented. The downstream context is emilk/egui#8280.
What changed
presentsWithTransaction.MTLDrawable::addPresentedHandlerto record the greatest generation Metal has presented.retained and callbacks registered after completion run immediately.
This is intentionally Metal HAL-specific. It does not change the portable wgpu surface API or
the non-transaction presentation path.
This is a draft because I would appreciate feedback on the HAL API shape before adapting the
downstream egui PR to it.