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.

Write the orchard’s language

SKETCHBOOK / 03 Copper Orchard · 2-week chapter

Page 1 of 3: MSL is familiar, not identical

Address spaces carry meaning

MSL is familiar, not identical

Metal Shading Language uses familiar C++ syntax but adds GPU execution semantics and address spaces. A device pointer addresses device-buffer data, constant denotes read-only constant data, thread is per-thread storage, and threadgroup is shared within a threadgroup. These are not decorative keywords. A C++ function using arbitrary heap allocation, operating-system services, or host containers cannot simply be pasted into a GPU shader.

A vertex function produces a position and interpolated outputs; a fragment function consumes the rasterized inputs and returns attachment values. Attributes such as [[position]], [[stage_in]], and [[buffer(0)]] connect the stages and resource bindings. Treat the numeric binding as part of a documented interface. Keep a tiny original shader for the first fruit: a stable transform and a warm gradient, then change one parameter deliberately.

Compile the library and resolve named functions before building a pipeline. Preserve compiler diagnostics and use a last-known-good pipeline during experimentation. For a reproducible release, record how the shader library was built for the target. Runtime compilation is useful for the teaching probe and development experiments; do not silently make every frame recompile the library.

From the page to your own work

Your studio assignment.

Draw a small warm orchard using a verified C++/MSL vertex interface.

A finish line you can see

A three-fruit image, host/shader layout table, and preserved shader diagnostic.

  1. Check record layout at compile time.
  2. Identify whether vertex fetch uses a descriptor or direct indexing.
  3. Match pipeline formats to the drawable/depth targets.
  4. Recover from a shader failure using the previous complete pipeline.
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 an apparently identical C++ and MSL struct produce broken geometry?
  • Their vector alignment or padding can differ.
  • The vertex path may apply a descriptor layout or typed-array stride.
  • Check offsets, widths, stride, and matrix convention independently.

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

A small creative variation ↗

Add a UV or normal diagnostic palette while preserving the same geometry budget.

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

Coming back after a break? ↩

Draw one constant-color triangle. Confirm its record stride before restoring transforms.

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 2 files