Repository navigation
♻️ [gfx] own Metal autorelease pools within device frames - #34
Merged
Merged
Conversation
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.
Engine::TickFrame currently imports Metal solely to manage a macOS autorelease pool. Move that native lifetime into MetalDevice::BeginFrame/EndFrame so Engine only coordinates the platform-independent frame lifecycle.
Keep BeginFrame in the existing GraphicsFrameSystem schedule. Add a non-throwing EndFrame hook and invoke it from Engine's RAII frame guard after the full frame, including schedule-preparation failures, task exceptions, and synchronous SDL live-resize callbacks. Metal drains only the current frame pool, rejects overlapping begins, and leaves enclosing Cocoa and device fallback pools intact. Other backends inherit an empty EndFrame; it does not wait for GPU completion.
Regression coverage verifies temporary-reference reclamation, enclosing-pool preservation, exceptional Engine frames and subsequent recovery through the SDL modal callback path, and submitted Metal recordings surviving frame-pool teardown while GPU execution is gated. Document the host pairing contract and the separate responsibility for initialization, frame-external work, and worker threads.
Validation on macOS ARM64 (Apple M5), debug with profiling enabled:
xmake build -j 4 unit_testspassed.xmake lua xmake/scripts/check_interop.lua: 216 consumer/adapter files and 27 boundary files, zero violations.git diff --checkpassed.Windows compilation is left to CI. SDL modal-frame tests use synchronous exposed events rather than manual window dragging.