Theme Catppuccin
Make yourself at homeCatppuccin

A softer light for long learning sessions.

Appearance

Loading your preference…

Dark palette

Choose a dark palette to try it.

Light uses Latte. Your choices stay in this browser.

When a frame comes home

SKETCHBOOK / 05 Copper Orchard · 2-week chapter

Page 1 of 4: Commit is a departure

Completion is the return ticket

Commit is a departure

Committing a command buffer schedules work; it does not mean the GPU has consumed your uniforms or finished writing an output. Keep the slot’s CPU-writable ranges unchanged until the corresponding work completes. Metal’s normal retained-resource command-buffer behavior can keep referenced resource objects alive, but that is not permission to overwrite their contents or reset an application allocator. Your application still owns the access schedule.

Use addCompletedHandler to observe completion without blocking every frame. Register the handler before committing. The callback should inspect status/errors and publish a small completion record to a synchronized queue or safe shared state. Do not assume it runs on your UI thread, and do not mutate Cocoa views from it. The main/render thread can consume the record and return the slot to the available pool.

Begin with a bounded number of submissions. If all slots are busy, apply backpressure. This keeps latency and memory growth understandable. A completion record should identify the slot and generation or submission token so the receiver can reject stale notifications rather than treating an index as timeless permission.

From the page to your own work

Your studio assignment.

Submit bounded overlapping frames and close the window without stale callbacks or premature range reuse.

A finish line you can see

A slot state diagram, completion trace, and shutdown walkthrough.

  1. Register handlers before commit and check completion status.
  2. Keep callback-owned state valid until every callback finishes.
  3. Return slots through synchronized publication with stable tokens.
  4. Avoid holding a callback-needed lock across completion waits.
Keep the evidence in your weekly notebook ↗
Explain it like an engineer

Try answering aloud before opening the review notes. Use your own implementation as evidence.

Why can a completion handler introduce a use-after-free even when Metal retains its GPU resources?
  • The handler may capture a separate C++ object whose lifetime Metal does not manage.
  • Window teardown can destroy that object before callback execution.
  • Retain suitable small state, synchronize access, and drain pending work before teardown.

These prompts support practice; they are not an automatic assessment of your work.

A small creative variation ↗

Add a visible pending-frame counter whose updates are marshaled to the UI thread.

Optional. Save it for later if this chapter already feels full.

Coming back after a break? ↩

Draw one submitted slot and one completion callback. Name the owner of every captured value.

Books & principles behind this study +

Original Parallax explanations and assignments, with these works for further reading.

YOUR MARGIN NOTES

Leave yourself a good question.

What changed your mind? What would you try next?

Notes are private to this browser and saved as you write.

A CHECKPOINT, NOT A SCORE

Can you explain the idea and try the exercise yourself?

Completion records your own assessment. It does not compile or test your C++.
Companion source 6 files