creating-metal4-shader-pipelines
Pipeline Creation
Overview
Covers Metal 4 pipeline state creation when porting games: loading pre-compiled metallibs, building render/compute/mesh PSOs via MTL4Compiler, function constants, flexible PSOs, color-attachment mapping, async compilation, and pipeline caching.
For compiling HLSL/DXIL shaders to metallibs, see the compiling-with-metal-shaderconverter skill.
For compiling Metal shader language (MSL) source, see MSL Source Compilation below.
References
Read the relevant Metal 4 SDK header before writing pipeline code — the headers are the source of truth for property names, types, and method signatures.
- Metal 4 SDK headers -
$(xcrun --show-sdk-path)/System/Library/Frameworks/Metal.framework/Headers/— focus onMTL4Compiler.h,MTL4RenderPipeline.h,MTL4ComputePipeline.h,MTL4MeshRenderPipeline.h,MTL4TileRenderPipeline.h,MTL4LinkingDescriptor.h - Apple documentation - Using the Metal 4 compilation API
Cross-API PSO Compatibility
Metal 3 PSOs work on Metal 4 encoders (and vice versa). This enables incremental porting — pipeline creation can be migrated to MTL4Compiler independently of encoder migration.