---
title: Metal sample code library
framework: Metal
role: collectionGroup
path: metal/metal-sample-code-library
---

# Metal sample code library

Explore the complete set of Metal samples.

## Overview

Overview Browse the topics below to find samples relevant to a concept you want to learn more about, starting with the basic computation and render workflows. The samples in the lighting and multiple technique sections demonstrate how to take advantage of the unique GPU architecture of Apple silicon.

## Topics

### Compute workflows

- [Performing calculations on a GPU](metal/performing-calculations-on-a-gpu.md)
- [Selecting device objects for compute processing](metal/selecting-device-objects-for-compute-processing.md)
- [Customizing a TensorFlow operation](metal/customizing-a-tensorflow-operation.md)
- [Customizing a PyTorch operation](metal/customizing-a-pytorch-operation.md)

### Machine learning workflows

- [Running a machine learning model on the GPU timeline](metal/running-a-machine-learning-model-on-the-gpu-timeline.md)
- [Training a neural network to render irradiance in real time](metal/training-a-neural-network-to-render-irradiance-in-real-time.md)
- [Running inline ML operations in a shader with Metal 4](metal/running-inline-ml-operations-in-a-shader-with-metal-4.md)

### Render workflows

- [Using Metal to draw a view’s contents](metal/using-metal-to-draw-a-view's-contents.md)
- [Drawing a triangle with Metal 4](metal/drawing-a-triangle-with-metal-4.md)
- [Selecting device objects for graphics rendering](metal/selecting-device-objects-for-graphics-rendering.md)
- [Customizing render pass setup](metal/customizing-render-pass-setup.md)
- [Creating a custom Metal view](metal/creating-a-custom-metal-view.md)
- [Calculating primitive visibility using depth testing](metal/calculating-primitive-visibility-using-depth-testing.md)
- [Encoding indirect command buffers on the CPU](metal/encoding-indirect-command-buffers-on-the-cpu.md)
- [Implementing order-independent transparency with image blocks](metal/implementing-order-independent-transparency-with-image-blocks.md)
- [Loading textures and models using Metal fast resource loading](metal/loading-textures-and-models-using-metal-fast-resource-loading.md)
- [Adjusting the level of detail using Metal mesh shaders](metal/adjusting-the-level-of-detail-using-metal-mesh-shaders.md)
- [Creating a 3D application with hydra rendering](metal/creating-a-3d-application-with-hydra-rendering.md)
- [Culling occluded geometry using the visibility result buffer](metal/culling-occluded-geometry-using-the-visibility-result-buffer.md)
- [Improving edge-rendering quality with multisample antialiasing (MSAA)](metal/improving-edge-rendering-quality-with-multisample-antialiasing-msaa.md)
- [Achieving smooth frame rates with a Metal display link](metal/achieving-smooth-frame-rates-with-a-metal-display-link.md)

### Textures

- [Combining blit and compute operations in a single pass](metal/combining-blit-and-compute-operations-in-a-single-pass.md)
- [Reading pixel data from a drawable texture](metal/reading-pixel-data-from-a-drawable-texture.md)
- [Creating and sampling textures](metal/creating-and-sampling-textures.md)
- [Streaming large images with Metal sparse textures](metal/streaming-large-images-with-metal-sparse-textures.md)

### Argument buffers

- [Managing groups of resources with argument buffers](metal/managing-groups-of-resources-with-argument-buffers.md)
- [Using argument buffers with resource heaps](metal/using-argument-buffers-with-resource-heaps.md)
- [Encoding argument buffers on the GPU](metal/encoding-argument-buffers-on-the-gpu.md)
- [Rendering terrain dynamically with argument buffers](metal/rendering-terrain-dynamically-with-argument-buffers.md)

### Shaders

- [Creating a Metal dynamic library](metal/creating-a-metal-dynamic-library.md)
- [Using function specialization to build pipeline variants](metal/using-function-specialization-to-build-pipeline-variants.md)

### Synchronization

- [Synchronizing CPU and GPU work](metal/synchronizing-cpu-and-gpu-work.md)
- [Implementing a multistage image filter using heaps and events](metal/implementing-a-multistage-image-filter-using-heaps-and-events.md)
- [Implementing a multistage image filter using heaps and fences](metal/implementing-a-multistage-image-filter-using-heaps-and-fences.md)

### Lighting techniques

- [Rendering a scene with forward plus lighting using tile shaders](metal/rendering-a-scene-with-forward-plus-lighting-using-tile-shaders.md)
- [Rendering a scene with deferred lighting in Objective-C](metal/rendering-a-scene-with-deferred-lighting-in-objective-c.md)
- [Rendering a scene with deferred lighting in Swift](metal/rendering-a-scene-with-deferred-lighting-in-swift.md)
- [Rendering a scene with deferred lighting in C++](metal/rendering-a-scene-with-deferred-lighting-in-c++.md)
- [Rendering reflections with fewer render passes](metal/rendering-reflections-with-fewer-render-passes.md)

### Multiple techniques

- [Modern rendering with Metal](metal/modern-rendering-with-metal.md)
- [Encoding indirect command buffers on the GPU](metal/encoding-indirect-command-buffers-on-the-gpu.md)

### Ray tracing

- [Rendering reflections in real time using ray tracing](metal/rendering-reflections-in-real-time-using-ray-tracing.md)
- [Accelerating ray tracing using Metal](metal/accelerating-ray-tracing-using-metal.md)
- [Control the ray tracing process using intersection queries](metal/control-the-ray-tracing-process-using-intersection-queries.md)
- [Accelerating ray tracing and motion blur using Metal](metal/accelerating-ray-tracing-and-motion-blur-using-metal.md)
- [Rendering a curve primitive in a ray tracing scene](metal/rendering-a-curve-primitive-in-a-ray-tracing-scene.md)

### HDR

- [Processing HDR images with Metal](metal/processing-hdr-images-with-metal.md)

### OpenGL

- [Migrating OpenGL code to Metal](metal/migrating-opengl-code-to-metal.md)
- [Mixing Metal and OpenGL rendering in a view](metal/mixing-metal-and-opengl-rendering-in-a-view.md)
