Collection

Metal sample architecture

Source-backed, high-level architecture notes for Apple sample-code pages grouped in the Metal folder.

  • Catalog module label: Metal
  • Coverage: 52 / 52 sample pages documented
  • Source policy: archive hashes and extracted-tree references are verified locally before analysis

Samples

Sample Platforms High-level architecture Documented patterns
Accelerating ray tracing and motion blur using Metal iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; ViewController hands work to Renderer, which owns motion acceleration structures before ray-tracing compute kernel. Scene/renderer separation, Bounded frames in flight, Host-shader data contract
Accelerating ray tracing using Metal iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; ViewController hands work to Renderer, which owns acceleration-structure construction before ray-tracing shader work. Scene/renderer separation, Bounded frames in flight, Host-shader data contract
Achieving smooth frame rates with a Metal display link iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C, Objective-C++ host code with Metal shaders; GameViewController hands work to GameView, which owns display-link pacing before per-frame Metal submission. Delegate-driven frame loop, Platform adapter boundary, Bounded frames in flight
Adjusting the level of detail using Metal mesh shaders iOS, iPadOS, Mac Catalyst, macOS C++, Objective-C, Objective-C++ host code with Metal shaders; Python is build/tooling support; AAPLViewController hands work to AAPLRendererAdapter, which owns metal-cpp renderer through an Objective-C++ adapter before object and mesh shader stages. Adapter, View-controller organization, Host-shader data contract
Calculating primitive visibility using depth testing iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns depth-stencil state and render-pass setup before raster shader stages. Renderer boundary, Delegate-driven frame loop, Explicit depth-state policy
Capturing Metal commands programmatically macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns capture-scope lifecycle before captured Metal command stream. Manager object, Renderer boundary, Scoped instrumentation
Combining blit and compute operations in a single pass iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; ViewController hands work to Metal4Renderer, which owns combined command-encoder setup before blit and compute commands in one pass. Renderer boundary, Explicit GPU pipeline, Host-shader data contract
Control the ray tracing process using intersection queries iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; ViewController hands work to Renderer, which owns intersection-query configuration before inline ray queries in a Metal kernel. Scene/renderer separation, Explicit GPU pipeline, Host-shader data contract
Creating a 3D application with hydra rendering Objective-C++ host code with Metal shaders; Python is build/tooling support; AAPLViewController hands work to AAPLRenderer, which owns Objective-C++ Hydra renderer integration before Hydra render delegate backed by Metal. Renderer boundary, Framework adapter, View-controller organization
Creating a custom Metal view iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns platform-specific custom view before drawable acquisition and command submission. Delegate-driven view, Platform adapter boundary, Renderer boundary
Creating a Metal dynamic library iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLEditViewController hands work to AAPLRenderer, which owns runtime Metal library linking before functions loaded from a dynamic library. Renderer boundary, Runtime shader composition, Configuration-driven pipeline
Creating and sampling textures iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns image loading and texture creation before textured raster pipeline. Renderer boundary, Resource-loader object, Host-shader data contract
Culling occluded geometry using the visibility result buffer iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns visibility-query buffer management before occlusion-tested draw calls. Renderer boundary, Two-phase visibility pipeline, Host-shader data contract
Customizing a PyTorch operation Objective-C++, Python source; the Python model invokes compiled_lib.mps_softshrink, and the Objective-C++ binding compiles embedded MSL before encoding it on PyTorch’s MPS command stream. Custom operator bridge, Reference-versus-custom strategy, Language boundary
Customizing a TensorFlow operation C++, Python host code with Metal shaders; the Python HashEncoder layer invokes a registered TensorFlow operation whose C++ kernel dispatches the Metal hash-encoding functions. Custom operator bridge, Framework registration, Language boundary
Customizing render pass setup iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns render-pass descriptor ownership before multiple attachment/store actions. Renderer boundary, Explicit render-pass policy, Host-shader data contract
Customizing shaders using function pointers and stitching iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLConfigurationViewController hands work to AAPLRenderer, which owns function-table and stitched-function construction before indirectly selected shader functions. Runtime shader composition, Strategy by function selection, Renderer boundary
Drawing a triangle with Metal 4 iOS, iPadOS, Mac Catalyst, macOS, tvOS C, Objective-C host code with Metal shaders; ViewController hands work to MetalKitViewDelegate, which owns renderer selection behind a shared delegate before Metal 4 or legacy triangle path. Strategy, Delegate-driven frame loop, Shared renderer contract
Encoding argument buffers on the GPU iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns GPU-side argument-buffer encoding before argument-consuming raster stages. Renderer boundary, GPU-driven resource binding, Host-shader data contract
Encoding indirect command buffers on the CPU iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns CPU construction of indirect commands before GPU execution of the command buffer. Renderer boundary, Pre-encoded command stream, Host-shader data contract
Encoding indirect command buffers on the GPU iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns compute encoding of indirect commands before GPU execution of generated draws. Renderer boundary, GPU-driven command generation, Host-shader data contract
Implementing a multistage image filter using heaps and events iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns heap-backed intermediate image stages before event-ordered compute filters. Filter pipeline, Event-based synchronization, Heap resource reuse
Implementing a multistage image filter using heaps and fences iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns heap-backed intermediate image stages before fence-ordered compute filters. Filter pipeline, Fence-based synchronization, Heap resource reuse
Implementing order-independent transparency with image blocks iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns image-block render-pass setup before tile-local transparency resolve. Renderer boundary, Tile-local accumulation, Host-shader data contract
Improving edge-rendering quality with multisample antialiasing (MSAA) iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns multisample target and resolve setup before MSAA rasterization and resolve. Renderer boundary, Configuration strategy, Explicit resolve stage
Loading textures and models using Metal fast resource loading macOS Objective-C, Objective-C++ host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns IO command queue and asset loader before GPU-resident texture/model resources. Resource-loader boundary, Asynchronous loading pipeline, Renderer boundary
Managing groups of resources with argument buffers iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns argument-buffer encoding before resource-indexed shader access. Renderer boundary, Data-driven resource table, Host-shader data contract
Migrating OpenGL code to Metal iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; AAPLMetalViewController hands work to AAPLMetalRenderer, which owns parallel OpenGL and Metal renderers before equivalent backend-specific draw paths. Strategy, Backend isolation, Shared scene contract
Mixing Metal and OpenGL rendering in a view iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLMetalViewController hands work to AAPLMetalRenderer, which owns separate Metal and OpenGL renderers before shared-view interoperability and presentation. Adapter, Backend isolation, Shared resource boundary
Modern rendering with Metal iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; AAPLCameraController hands work to AAPLRenderer, which owns scene, mesh, and texture-management subsystems before multi-pass modern renderer shaders. Subsystem decomposition, Resource manager, Delegate-driven frame loop
Performing calculations on a GPU macOS Objective-C host code with Metal shaders; Command-line main hands work to MetalAdder, which owns command-line MetalAdder orchestration before parallel add compute kernel. Command object, Compute pipeline, Host-shader data contract
Processing HDR images with Metal iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C, Objective-C++ host code with Metal shaders; AAPLWindowController hands work to AAPLRenderer, which owns HDR scene renderer and post processor before tone-map/bloom shader stages. Post-processing pipeline, Renderer boundary, Host-shader data contract
Reading pixel data from a drawable texture iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns drawable render and readback coordination before GPU-to-CPU pixel copy. Renderer boundary, Explicit readback boundary, Delegate-driven frame loop
Rendering a curve primitive in a ray tracing scene iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; ViewController hands work to Renderer, which owns curve geometry and acceleration-structure setup before curve intersection/ray-tracing shader. Geometry hierarchy, Renderer boundary, Host-shader data contract
Rendering a scene with deferred lighting in C++ iOS, iPadOS, Mac Catalyst, macOS, tvOS C++, Objective-C, Objective-C++ host code with Metal shaders; Python is build/tooling support; AAPLViewController hands work to AAPLViewAdapter, which owns Objective-C++ view adapter and metal-cpp renderer before deferred G-buffer and lighting passes. Adapter, Renderer hierarchy, Host-shader data contract
Rendering a scene with deferred lighting in Objective-C iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns Objective-C deferred renderer before G-buffer and lighting passes. Renderer boundary, Diagnostic manager, Host-shader data contract
Rendering a scene with deferred lighting in Swift iOS, iPadOS, Mac Catalyst, macOS, tvOS Swift host code with Metal shaders; ViewController hands work to Renderer, which owns base renderer with two concrete strategies before single-pass or traditional deferred shaders. Strategy, Renderer inheritance, Local protocol abstraction
Rendering a scene with forward plus lighting using tile shaders iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns forward-plus light culling and rendering before tile shader and raster lighting stages. Tiled lighting pipeline, Renderer boundary, Host-shader data contract
Rendering reflections in real time using ray tracing iOS, iPadOS, Mac Catalyst, macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns hybrid raster/ray-tracing renderer before ray-traced reflections plus raster composition. Hybrid rendering pipeline, Scene data model, Host-shader data contract
Rendering reflections with fewer render passes iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns layered render-pass orchestration before vertex amplification/layer selection. Pass consolidation, Renderer boundary, Host-shader data contract
Rendering terrain dynamically with argument buffers iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; AAPLGameViewController hands work to AAPLMainRenderer, which owns main renderer coordinating specialized renderers before terrain, vegetation, and particle shader passes. Composite renderer, Specialized renderer objects, Argument-buffer resource graph
Running a machine learning model on the GPU timeline macOS Objective-C source; Command-line main hands work to MLMatrixMultiplier, which owns matrix objects and MLMatrixMultiplier encoder before Metal 4 machine-learning pipeline on a command buffer. Command-line composition, Encoder object, GPU timeline integration
Running inline ML operations in a shader with Metal 4 macOS Objective-C host code with Metal shaders; Command-line main hands work to MatrixMultiplier, which owns command-line matrix multiplier before inline ML shader operation and writeback. Command-line composition, Compute pipeline, Host-shader data contract
Selecting device objects for compute processing macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns device-selection controller and simulation before compute renderer on the selected device. Device-selection strategy, Simulation/renderer separation, Fallback policy
Selecting device objects for graphics rendering macOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns device-selection controller before renderer bound to the selected display device. Device-selection strategy, Renderer boundary, Fallback policy
Streaming large images with Metal sparse textures iOS, iPadOS, Mac Catalyst, macOS Objective-C, Objective-C++ host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns sparse-texture residency manager before tile mapping and sampled rendering. Resource manager, Explicit residency state, Renderer boundary
Supporting Simulator in a Metal app iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C, Swift host code with Metal shaders; Swift / Objective-C app hands work to Renderer, which owns parallel Swift and Objective-C app variants before shared Metal feature with simulator guards. Parallel language implementations, Capability guard, Renderer boundary
Synchronizing CPU and GPU work iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns per-frame buffer-ring management before semaphore-gated command submission. Bounded frames in flight, Ring buffer, Delegate-driven frame loop
Training a neural network to render irradiance in real time macOS Objective-C, Python host code with Metal shaders; offline Python training exports model weights, and the runtime renderer selects an irradiance technique that consumes them during Metal rendering. Offline/online split, Strategy, Renderer boundary
Using argument buffers with resource heaps iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns heap allocation plus argument-buffer encoding before heap-backed resource access in shaders. Heap resource ownership, Argument-buffer resource table, Renderer boundary
Using function specialization to build pipeline variants iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C host code with Metal shaders; AAPLViewController hands work to AAPLRenderer, which owns function-constant pipeline construction before specialized material/LOD shader variants. Strategy by specialization, Pipeline cache, Host-shader data contract
Using Metal to draw a view’s contents iOS, iPadOS, Mac Catalyst, macOS, tvOS Objective-C source; AAPLViewController hands work to AAPLRenderer, which owns view controller and minimal renderer before clear, present, and commit. Renderer boundary, Delegate-driven frame loop, Minimal command lifecycle

Cross-sample signals

Recurring documented patterns

Pattern label Sample documents
Renderer boundary 29
Host-shader data contract 23
Delegate-driven frame loop 7
Bounded frames in flight 4
Strategy 4
Scene/renderer separation 3
Adapter 3
Platform adapter boundary 2
View-controller organization 2
Explicit GPU pipeline 2
Runtime shader composition 2
Custom operator bridge 2
Language boundary 2
Filter pipeline 2
Heap resource reuse 2
Backend isolation 2
Resource manager 2
Compute pipeline 2
Command-line composition 2
Device-selection strategy 2
Fallback policy 2

Type-role naming evidence

Counts below are declaration-name suffixes, not inferred patterns.

Role suffix Distinct declarations across samples
Delegate 89
Renderer 57
Controller 55
View 10
Scene 6
Manager 4
Loader 2
Adapter 2
Model 2
Monitor 1
Store 1

Swift access-control evidence

These are declaration occurrences in scanned Swift source, including implicit internal declarations.

Access level Occurrences
implicit internal 480
private 15
fileprivate 1
public 1

References

Generated from the verified local catalog and completed Markdown documents.