Skip to content

Metal: keep render passes across framebuffer rebinds; cache partial-clear state - #110

Closed
navjack wants to merge 1 commit into
renderbag:mainfrom
navjack:metal-render-pass-and-clear-fixes
Closed

navjack wants to merge 1 commit into
renderbag:mainfrom
navjack:metal-render-pass-and-clear-fixes

Conversation

@navjack

@navjack navjack commented Sep 15, 2026

Copy link
Copy Markdown

setFramebuffer ended the active render encoder even when the same
framebuffer was rebound. Renderers that set the framebuffer before every
draw started a new render pass per draw, which dominated encoding time on
Apple GPUs. Return early when the target is unchanged, an encoder is open
and no clears are pending, matching the Vulkan backend's guard.

Partial color clears created a new depth-stencil state on every clear and
never released it; use a device-lifetime clearColorDepthState instead.
Both partial clear paths now compute the clear pipeline key from the
framebuffer formats and look up the cached pipeline before allocating a
render pipeline descriptor, which is only built on a cache miss.

Testing

  • Developed and used in the macOS Metal port of LostOdysseyRecomp (Apple M4 Pro, macOS 27, Xcode 27), exercising this path during gameplay.
  • This branch is the single commit cherry-picked onto current main; -fsyntax-only compile of the changed sources on arm64 macOS against main passes.

🤖 Generated with Claude Code

…lear state

setFramebuffer ended the active render encoder even when the same
framebuffer was rebound. Renderers that set the framebuffer before every
draw started a new render pass per draw, which dominated encoding time on
Apple GPUs. Return early when the target is unchanged, an encoder is open
and no clears are pending, matching the Vulkan backend's guard.

Partial color clears created a new depth-stencil state on every clear and
never released it; use a device-lifetime clearColorDepthState instead.
Both partial clear paths now compute the clear pipeline key from the
framebuffer formats and look up the cached pipeline before allocating a
render pipeline descriptor, which is only built on a cache miss.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@DarioSamo

Copy link
Copy Markdown
Contributor

AI-generated contributions are not accepted, especially ones with Claude as the co-author. No copyright will be given to Anthropic in any of my projects.

@DarioSamo DarioSamo closed this Sep 15, 2026
@renderbag renderbag locked as spam and limited conversation to collaborators Sep 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants