Signal completed renderer frames to embedded hosts - #121
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe renderer instrumentation path now carries a callback configuration from ChangesFrame completion instrumentation
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Surface
participant Renderer
participant GraphicsBackend
participant InstrumentationCallback
Surface->>Renderer: pass instrumentation during initialization
Renderer->>GraphicsBackend: complete frame
GraphicsBackend->>Renderer: report healthy frame
Renderer->>InstrumentationCallback: emit frame_completed
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR adds a
Confidence Score: 5/5Safe to merge — the change is narrow, the callback fires at the correct point in the swap-chain lifecycle, and the existing enum-parity test enforces C/Zig alignment. All five changed files are consistent: the new event is plumbed through Options → renderer struct → frameCompleted(), the emit happens before releaseFrame() so the frame is still held, the C header and Zig enum stay in sync, and the Surface.zig reordering is correct. No functional regressions or missing guard conditions were found. No files require special attention. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant RT as Renderer Thread
participant GPU as GPU / Metal CB
participant FC as frameCompleted()
participant IC as Instrumentation Callback
participant SC as SwapChain
RT->>GPU: commit command buffer (draw_frame_end fired)
Note over RT: renderer thread returns immediately (async)
GPU-->>FC: bufferCompleted block (Metal CB thread)
FC->>FC: determine health from MTLCommandBufferStatus
FC->>GPU: api.present() [if healthy]
FC->>FC: emit frame_completed [if healthy]
FC->>IC: callback(userdata, FRAME_COMPLETED)
Note over IC: embedded compositor publishes cross-process IOSurface
FC->>SC: releaseFrame() — frame permit returned
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant RT as Renderer Thread
participant GPU as GPU / Metal CB
participant FC as frameCompleted()
participant IC as Instrumentation Callback
participant SC as SwapChain
RT->>GPU: commit command buffer (draw_frame_end fired)
Note over RT: renderer thread returns immediately (async)
GPU-->>FC: bufferCompleted block (Metal CB thread)
FC->>FC: determine health from MTLCommandBufferStatus
FC->>GPU: api.present() [if healthy]
FC->>FC: emit frame_completed [if healthy]
FC->>IC: callback(userdata, FRAME_COMPLETED)
Note over IC: embedded compositor publishes cross-process IOSurface
FC->>SC: releaseFrame() — frame permit returned
Reviews (1): Last reviewed commit: "renderer: signal completed embedded fram..." | Re-trigger Greptile |
Adds an append-only renderer instrumentation event after a healthy GPU frame completes and is presented. Embedded compositors can publish cross-process IOSurfaces without blocking the renderer thread or racing Metal writes.\n\nVerification:
zig build test -Dapp-runtime=none -Demit-macos-app=false -Demit-xcframework=false -Dtest-filter="renderer instrumentation"; universal ReleaseFast GhosttyKit build with-Demit-macos-app=false.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Signals a new renderer event when a GPU frame is completed and presented, so embedded hosts can publish IOSurfaces safely without blocking or racing Metal writes. Adds
.frame_completedto the C/zig instrumentation and wires it through the renderer.New Features
GHOSTTY_RENDERER_EVENT_FRAME_COMPLETED/.frame_completed, emitted only after a healthy frame is presented.Renderer.Optionsand the backend to fire from GPU completion callbacks.draw_frame_endsemantics unchanged (CPU submission completion).Migration
GHOSTTY_RENDERER_EVENT_FRAME_COMPLETEDto publish cross-process surfaces post-presentation.Written for commit 827c20f. Summary will update on new commits.
Summary by CodeRabbit