Skip to content

Add next/present swapchain API for Metal - #116

Open
tryk016 wants to merge 1 commit into
Try:masterfrom
tryk016:codex/pr-tempest-metal-dynamic-swapchain
Open

tryk016 wants to merge 1 commit into
Try:masterfrom
tryk016:codex/pr-tempest-metal-dynamic-swapchain

Conversation

@tryk016

@tryk016 tryk016 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

First Metal implementation of #110. next() acquires a drawable and returns an attachment for that frame:

Attachment img = swapchain.next(); // acquire drawable

// Record rendering into img.
auto fence = device.submit(cmd);
device.present(std::move(img)); // consume img

Rendering goes straight into the drawable, without private presentation textures or a final blit. Dropping the attachment discards the frame. Recorded and submitted command buffers keep the image alive for as long as they need it.

submit() still commits immediately. present() uses a separate command buffer on the same queue, with presentDrawable before commit. Acquisition failures throw SwapchainSuboptimal; reset remains explicit.

The indexed API remains available for existing callers and the other backends.

Tested with Metal validation on macOS, iOS Simulator and iPhone, including GPU lifetime and pixel readback checks. OpenGothic rendered 1800 frames on both Mac and iPhone, with a swapchain reset.

@tryk016 tryk016 mentioned this pull request Oct 1, 2026
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.

1 participant