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.

Shared ground, separate turns

SKETCHBOOK / 02 Copper Orchard · 2-week chapter

Page 1 of 4: Unified memory is still a contract

One physical pool is not one owner

Unified memory is still a contract

On the M4 Pro, CPU and GPU can use unified physical memory, but their access still needs a schedule. A shared MTLBuffer gives the CPU a contents pointer and the GPU a resource binding. It does not make an overlapping CPU write and GPU read safe. If the previous frame is consuming a camera record, write the next frame into a different available range or wait for the completion that returns ownership of that range.

Private storage is intended for GPU access and does not provide a CPU contents pointer. Upload through a staging resource and a blit when that fits the workload. Shared storage is convenient for frequently updated small data and readback. Managed storage belongs to a different synchronization model on supported macOS devices; do not paste its didModifyRange/synchronize recipe onto the Apple-silicon shared path without understanding the target. Query and document the selected mode.

Use a byte budget before newBuffer. Validate count, element stride, multiplication, and the device’s maximum buffer length. A device limit is not a sensible application budget by itself. A scene can be technically allocatable and still overwhelm system memory shared with other applications. Keep resource creation failure visible and leave the last complete scene intact.

From the page to your own work

Your studio assignment.

Verify a small GPU computation and design the ranges your future frames may write.

A finish line you can see

A CPU/GPU comparison, buffer budget, and two-frame ownership diagram.

  1. Run the 1,003-element probe and record actual device output.
  2. Explain why its blocking wait is appropriate for this test.
  3. Reject an oversized byte request before resource creation.
  4. Describe the event returning a submitted slot to the CPU.
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 might a renderer use both shared and private resources on a unified-memory system?
  • Access pattern and API storage contracts matter even with shared physical memory.
  • CPU-updated small data and GPU-only long-lived data have different needs.
  • Measure the actual workload while preserving explicit synchronization and lifetime.

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

A small creative variation ↗

Change the affine coefficients and add a CPU oracle value you calculate by hand.

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

Coming back after a break? ↩

Run the probe, inspect element zero, and trace only its input, dispatch, completion, and output.

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