METAL-PIPELINES-SCRIPT(5) Metal METAL-PIPELINES-SCRIPT(5)

metal-pipelines-script - Metal pipelines script JSON file format

A Metal pipelines script is used to specify a collection of Metal libraries and pipeline descriptors. metal-nt consumes this information to determine which input file to read and which GPU binaries must be generated and stored in a GPU binaries archive.

A Metal pipelines script has a JSON based textual representation. Its canonical file extension is .mtlp-json. The script itself is a single object that can have the members:

An object describing the input Metal libraries from file or generated via the function constants specialization process. See LIBRARIES.
An object describing of the compute pipelines, render pipelines, and tile-render pipelines that need to be compiled into GPU binaries. See PIPELINES.
An array of objects describing the named predicate definitions. Predicates can be used to control whether a pipeline should be compiled or ignored. See PREDICATES.
An array of objects describing the named function constant values definitions. These can be referenced by name from specialized function library definitions. See NAMED FUNCTION CONSTANT VALUES.

The object describing the collection of Metal libraries can have the members:

An array of objects describing a Metal library on disk. Each object can define the members:
Unique identifier for the library in a Metal pipelines script. The label value is used for the alias: URIs to reference a function from the library with the given label. See FUNCTION REFERENCE.
Path to the Metal library on disk. If the path is relative, the library is resolved considering the library search paths provided with the option -L to metal-nt.

An array of objects describing a Metal library generated via the function constants specialization process. Each object can define the members:
Unique identifier for the library in a Metal pipelines script. The label value is used for the alias: URIs to reference a function from the library with the given label. See FUNCTION REFERENCE.
Reference to the function to be specialized. See FUNCTION REFERENCE for more details about the different syntax to reference a function.
Name of the function after specialization. If not specified, the original name is used.
Name of the named function constant values object to use for the constant specialization values. See NAMED FUNCTION CONSTANT VALUES.
An array of objects describing the constant specialization values. The constant specialization values defined in this array overrides the corresponding values provided by the named function constant values object specified via named_function_constant_values. See FUNCTION CONSTANT VALUE.


A named function constant values object can define the members:

The name for the named function constant values being defined.
constant_values (required)
An array of objects describing the constant specialization values. See FUNCTION CONSTANT VALUE.

A function constant value object can define the members:

String with one of the following values:
  • FunctionConstantIndex
  • FunctionConstantName

If id_type is FunctionConstantIndex then id must be an object with a single member data whose value must be an integer between 0 and 65535 representing the index of a function constant variable.

If id_type is FunctionConstantName then id must be a string whose value represent the name of function constant variable.

Data type of the function constant value. It must be one of the following string values:
  • ConstantBool
  • ConstantBool2
  • ConstantBool3
  • ConstantBool4
  • ConstantChar
  • ConstantChar2
  • ConstantChar3
  • ConstantChar4
  • ConstantUChar
  • ConstantUChar2
  • ConstantUChar3
  • ConstantUChar4
  • ConstantShort
  • ConstantShort2
  • ConstantShort3
  • ConstantShort4
  • ConstantUShort
  • ConstantUShort2
  • ConstantUShort3
  • ConstantUShort4
  • ConstantInt
  • ConstantInt2
  • ConstantInt3
  • ConstantInt4
  • ConstantUInt
  • ConstantUInt2
  • ConstantUInt3
  • ConstantUInt4
  • ConstantLong
  • ConstantLong2
  • ConstantLong3
  • ConstantLong4
  • ConstantULong
  • ConstantULong2
  • ConstantULong3
  • ConstantULong4
  • ConstantFloat
  • ConstantFloat2
  • ConstantFloat3
  • ConstantFloat4
  • ConstantHalf
  • ConstantHalf2
  • ConstantHalf3
  • ConstantHalf4

An object with a single member data whose value is either a scalar or array of 2/3/4 integer/floating point values depending on the value of value_type.

The object describing the collection of Metal pipelines can have the members:

An array of objects describing a Metal compute pipeline. See COMPUTE PIPELINE DESCRIPTOR.
An array of objects describing a Metal render pipeline. See RENDER PIPELINE DESCRIPTOR.
An array of objects describing a Metal tile render pipeline. See TILE RENDER PIPELINE DESCRIPTOR.

This is the equivalent structure of MTLComputePipelineDescriptor in the Metal API. A Metal compute pipeline descriptor object can have the members:

A predicate expression that determines if the pipeline should be compiled or ignored. The default value is the empty expression. See PREDICATES.
Reference to a kernel function. See FUNCTION REFERENCE for more details about the different syntax to reference a function.
A boolean value that indicates if the threadgroup size is always a multiple of the thread execution width. The default value is false.
The maximum number of threads in a threadgroup when dispatching a command using this pipeline. If set to 0, the implementation calculates this value based on the properties of the device and the compute function. The default value is 0.
The maximum function call depth from the compute function. The default value is 1.
The organization of input data for the compute function. See STAGE INPUT OUTPUT DESCRIPTOR.
This is an array of objects describing the buffer mutability option for the compute function. Each array index corresponds to the same index in the buffer argument table for the compute function. See PIPELINE BUFFER DESCRIPTOR.
A boolean value that indicates if the resulting pipeline state can be referenced by commands in an indirect command buffer. The default value is false.
A boolean value that indicates if the resulting pipeline state can be used to create new pipelines by adding binary functions to its callable functions list. The default value is false.

This is the equivalent structure of MTLRenderPipelineDescriptor in the Metal API. A Metal render pipeline descriptor object can have the members:

A predicate expression that determines if the pipeline should be compiled or ignored. The default value is the empty expression. See PREDICATES.
Reference to a vertex function. See FUNCTION REFERENCE for more details about the different syntax to reference a function.
Reference to a fragment function. See FUNCTION REFERENCE for more details about the different syntax to reference a function.
The maximum function call depth from the vertex function. The default value is 1.
The maximum function call depth from the fragment function. The default value is 1.
The organization of vertex data for the vertex function. See VERTEX DESCRIPTOR.
The type of primitive topology the pipeline renders. It must be one of the following string values:
  • Unspecified (default)
  • Point
  • Line
  • Triangle

The maximum tessellation factor that the tessellator uses when tessellating patches. The default value is 16.
A boolean value that determines if the pipeline scales the tessellation factor. The default value is false.
The format of the tessellation factors in the tessellation factor buffer. It must be one of the following string values:
Half (default)

The size of the control point indices in a control point index buffer. It must be one the following string values:
  • None (default)
  • UInt16
  • UInt32

The step function for determining the tessellation factors for a patch from the tessellation factor buffer. It must be one of the following string values:
  • Constant (default)
  • PerPatch
  • PerInstance
  • PerPatchAndPerInstance

The winding order of triangles from the tessellator. It must be one of the following string values:
  • Clockwise (default)
  • CounterClockwise.

The partitioning mode that the tessellator uses to derive the number and spacing of segments for subdividing a corresponding edge. It must be one of the following string values:
  • Pow2 (default)
  • Integer
  • FractionalOdd
  • FractionalEven

The maximum vertex amplification count you can set when encoding render commands. The default value is 1.
A boolean value that determines if the pipeline rasterizes primitives. The default value is true.
A boolean value that indicates if the alpha channel fragment output for color attachments is read and used to compute a sample coverage mask. The default value is false.
A boolean value that indicates if the alpha channel values for color attachments are forced to the largest representable value. The default value is false.
The number of samples in each fragment. The default value is 1.
An array of objects describing the color data. Each object is the equivalent structure of MTLRenderPipelineColorAttachmentDescriptor in the Metal API, and can define the members:
The pixel format of the color attachment's texture. The default value is Invalid. See PIXEL FORMAT.
A bitmask that restricts which color channels are written into the texture. It must be a string containing one or more of the following string values separated by space:
  • None
  • Red
  • Green
  • Blue
  • Alpha
  • All (default)

A boolean value that determines if blending is enabled. The default value is false.
The blend operation assigned for the alpha data. The default value is Add. See BLEND OPERATION.
The blend operation assigned for the RGB data. The default value is Add. See BLEND OPERATION.
The destination blend factor used by the alpha blend operation. The default value is Zero. See BLEND FACTOR.
The destination blend factor used by the RGB blend operation. The default value is Zero. See BLEND FACTOR.
The source blend factor used by the alpha blend operation. The default value is One. See BLEND FACTOR.
The source blend factor used by the RGB blend operation. The default value is One. See BLEND FACTOR.

The pixel format of the attachment that stores depth data. The default value is Invalid. See PIXEL FORMAT.
The pixel format of the attachment that stores stencil data. The default value is Invalid. See PIXEL FORMAT.
This is an array of objects describing the buffer mutability option for the vertex function. Each array index corresponds to the same index in the buffer argument table for the vertex function. See PIPELINE BUFFER DESCRIPTOR.
This is an array of objects describing the buffer mutability option for the fragment function. Each array index corresponds to the same index in the buffer argument table for the fragment function. See PIPELINE BUFFER DESCRIPTOR.
A boolean value that indicates if the resulting pipeline state can be referenced by commands in an indirect command buffer. The default value is false.
A boolean value that indicates if the resulting pipeline state can be used to create new pipelines by adding binary functions to the vertex callable functions list. The default value is false.
A boolean value that indicates if the resulting pipeline state can be used to create new pipelines by adding binary functions to the fragment callable functions list. The default value is false.

This is the equivalent structure of MTLTileRenderPipelineDescriptor in the Metal API. A Metal tile render pipeline descriptor object can have the members:

A predicate expression that determines if the pipeline should be compiled or ignored. The default value is the empty expression. See PREDICATES.
Reference to a kernel or fragment function. See FUNCTION REFERENCE for more details about the different syntax to reference a function.
A boolean value that indicates if all threadgroups completely cover tiles. The default value is false.
The maximum number of threads in a threadgroup when dispatching a command using this pipeline. If set to 0, the implementation calculates this value based on the properties of the device and the tile function. The default value is 0.
The maximum function call depth from the tile function. The default value is 1.
The number of samples in each fragment. The default value is 1.
An array of objects describing the color data. Each object is the equivalent structure of MTLTileRenderPipelineColorAttachmentDescriptor in the Metal API, and can define the members:
The pixel format associated with the tile shading render pipeline. The default value is Invalid. See PIXEL FORMAT.

This is an array of objects describing the buffer mutability option for the tile function. Each array index corresponds to the same index in the buffer argument table for the tile function. See PIPELINE BUFFER DESCRIPTOR.
A boolean value that indicates if the resulting pipeline state can be used to create new pipelines by adding binary functions to its callable functions list. The default value is false.

This is the equivalent structure of MTLStageInputOutputDescriptor in the Metal API. A Metal stage/output descriptor object can have the members:

An array of objects describing where and how to fetch data for the function. Each object is the equivalent structure of MTLAttributeDescriptor in the Metal API, and can define the members:
The index in the argument table for the buffer that contains the data for the attribute.
The byte offset of the data from the start of the buffer data.
The format of the attribute's data. See ATTRIBUTE FORMAT.

An array of objects describing how a function fetches input data for attributes from buffers. Each array index corresponds to the same index in the buffer argument table for the function. Each object is the equivalent structure of MTLBufferLayoutDescriptor in the Metal API, and can define the members:
The distance in bytes between entries in the buffer for the attributes.
Determines which aspect of command execution triggers data fetches. It must be one of the following string values:
  • Constant
  • PerInstance
  • PerPatch
  • PerPatchControlPoint
  • PerVertex
  • ThreadPositionInGridX
  • ThreadPositionInGridY
  • ThreadPositionInGridXIndexed
  • ThreadPositionInGridYIndexed

The rate at which data is fetched by the step function.

The location of the index buffer for a compute function using indexed thread addressing.
The data type of the indices stored in the index buffer. It must be one of the following string values:
  • UInt16
  • UInt32


This is the equivalent structure of MTLVertexDescriptor in the Metal API. A Metal vertex descriptor object can have the members:

An array of objects describing where and how to fetch data for the function. Each object is the equivalent structure of MTLVertexAttributeDescriptor in the Metal API, and can define the members:
The index in the argument table for the buffer that contains the data for the attribute.
The byte offset of the data from the start of the buffer data.
The format of the attribute's data. See ATTRIBUTE FORMAT.

An array of objects describing how a function fetches input data for attributes from buffers. Each array index corresponds to the same index in the buffer argument table for the function. Each object is the equivalent structure of MTLVertexBufferLayoutDescriptor in the Metal API and can define the members:
The distance in bytes between entries in the buffer for the attributes.
Determines which aspect of command execution triggers data fetches. It must be one of the following string values:
  • Constant
  • PerInstance
  • PerPatch
  • PerPatchControlPoint
  • PerVertex (default)

The rate at which data is fetched by the step function.


This is the equivalent structure of MTLPipelineBufferDescriptor in the Metal API. A Metal pipeline buffer descriptor can define the members:

A mutability option that determines if a buffer's contents can be updated before related commands use the buffer. It must be one of the following string values:
  • Default (default)
  • Mutable
  • Immutable


This is the equivalent of MTLVertexFormat and MTLAttributeFormat in the Metal API. It must be one of the following string values:

  • Invalid
  • Char
  • Char2
  • Char3
  • Char4
  • UChar
  • UChar2
  • UChar3
  • UChar4
  • UCharNormalized
  • UChar2Normalized
  • UChar3Normalized
  • UChar4Normalized
  • CharNormalized
  • Char2Normalized
  • Char3Normalized
  • Char4Normalized
  • Short
  • Short2
  • Short3
  • Short4
  • UShort
  • UShort2
  • UShort3
  • UShort4
  • ShortNormalized
  • Short2Normalized
  • Short3Normalized
  • Short4Normalized
  • UShortNormalized
  • UShort2Normalized
  • UShort3Normalized
  • UShort4Normalized
  • Int
  • Int2
  • Int3
  • Int4
  • UInt
  • UInt2
  • UInt3
  • UInt4
  • Int1010102Normalized
  • UInt1010102Normalized
  • UChar4Normalized_BGRA
  • Half
  • Half2
  • Half3
  • Half4
  • Float
  • Float2
  • Float3
  • Float4

This is the equivalent of MTLPixelFormat in the Metal API. It must be one of the following string values:

  • Invalid
  • A8Unorm
  • R8Unorm
  • R8Unorm_sRGB
  • R8Snorm
  • R8Uint
  • R8Sint
  • R16Unorm
  • R16Snorm
  • R16Uint
  • R16Sint
  • R16Float
  • RG8Unorm
  • RG8Unorm_sRGB
  • RG8Snorm
  • RG8Uint
  • RG8Sint
  • B5G6R5Unorm
  • A1BGR5Unorm
  • ABGR4Unorm
  • BGR5A1Unorm
  • R32Uint
  • R32Sint
  • R32Float
  • RG16Unorm
  • RG16Snorm
  • RG16Uint
  • RG16Sint
  • RG16Float
  • RGBA8Unorm
  • RGBA8Unorm_sRGB
  • RGBA8Snorm
  • RGBA8Uint
  • RGBA8Sint
  • BGRA8Unorm
  • BGRA8Unorm_sRGB
  • RGB10A2Unorm
  • RGB10A2Uint
  • RG11B10Float
  • RGB9E5Float
  • BGR10A2Unorm
  • RG32Uint
  • RG32Sint
  • RG32Float
  • RGBA16Unorm
  • RGBA16Snorm
  • RGBA16Uint
  • RGBA16Sint
  • RGBA16Float
  • RGBA32Uint
  • RGBA32Sint
  • RGBA32Float
  • BC1_RGBA
  • BC1_RGBA_sRGB
  • BC2_RGBA
  • BC2_RGBA_sRGB
  • BC3_RGBA
  • BC3_RGBA_sRGB
  • BC4_RUnorm
  • BC4_RSnorm
  • BC5_RGUnorm
  • BC5_RGSnorm
  • BC6H_RGBFloat
  • BC6H_RGBUfloat
  • BC7_RGBAUnorm
  • BC7_RGBAUnorm_sRGB
  • PVRTC_RGB_2BPP
  • PVRTC_RGB_2BPP_sRGB
  • PVRTC_RGB_4BPP
  • PVRTC_RGB_4BPP_sRGB
  • PVRTC_RGBA_2BPP
  • PVRTC_RGBA_2BPP_sRGB
  • PVRTC_RGBA_4BPP
  • PVRTC_RGBA_4BPP_sRGB
  • EAC_R11Unorm
  • EAC_R11Snorm
  • EAC_RG11Unorm
  • EAC_RG11Snorm
  • EAC_RGBA8
  • EAC_RGBA8_sRGB
  • ETC2_RGB8
  • ETC2_RGB8_sRGB
  • ETC2_RGB8A1
  • ETC2_RGB8A1_sRGB
  • ASTC_4x4_sRGB
  • ASTC_5x4_sRGB
  • ASTC_5x5_sRGB
  • ASTC_6x5_sRGB
  • ASTC_6x6_sRGB
  • ASTC_8x5_sRGB
  • ASTC_8x6_sRGB
  • ASTC_8x8_sRGB
  • ASTC_10x5_sRGB
  • ASTC_10x6_sRGB
  • ASTC_10x8_sRGB
  • ASTC_10x10_sRGB
  • ASTC_12x10_sRGB
  • ASTC_12x12_sRGB
  • ASTC_4x4_LDR
  • ASTC_5x4_LDR
  • ASTC_5x5_LDR
  • ASTC_6x5_LDR
  • ASTC_6x6_LDR
  • ASTC_8x5_LDR
  • ASTC_8x6_LDR
  • ASTC_8x8_LDR
  • ASTC_10x5_LDR
  • ASTC_10x6_LDR
  • ASTC_10x8_LDR
  • ASTC_10x10_LDR
  • ASTC_12x10_LDR
  • ASTC_12x12_LDR
  • ASTC_4x4_HDR
  • ASTC_5x4_HDR
  • ASTC_5x5_HDR
  • ASTC_6x5_HDR
  • ASTC_6x6_HDR
  • ASTC_8x5_HDR
  • ASTC_8x6_HDR
  • ASTC_8x8_HDR
  • ASTC_10x5_HDR
  • ASTC_10x6_HDR
  • ASTC_10x8_HDR
  • ASTC_10x10_HDR
  • ASTC_12x10_HDR
  • ASTC_12x12_HDR
  • GBGR422
  • BGRG422
  • Depth16Unorm
  • Depth32Float
  • Stencil8
  • Depth24Unorm_Stencil8
  • Depth32Float_Stencil8
  • X32_Stencil8
  • X24_Stencil8
  • BGRA10_XR
  • BGRA10_XR_sRGB
  • BGR10_XR
  • BGR10_XR_sRGB

This is the equivalent of MTLBlendOperation in the Metal API. It must be one of the following string values:

  • Add
  • Subtract
  • ReverseSubtract
  • Min
  • Max

This is the equivalent of MTLBlendFactor in the Metal API. It must be one of the following string values:

  • Zero
  • One
  • SourceColor
  • OneMinusSourceColor
  • SourceAlpha
  • OneMinusSourceAlpha
  • DestinationColor
  • OneMinusDestinationColor
  • DestinationAlpha
  • OneMinusDestinationAlpha
  • SourceAlphaSaturated
  • BlendColor
  • OneMinusBlendColor
  • BlendAlpha
  • OneMinusBlendAlpha
  • Source1Color
  • OneMinusSource1Color
  • Source1Alpha
  • OneMinusSource1Alpha

Referencing functions in Metal libraries can be done in different ways based on the kind of library being referenced.

The function name shall be used in the case the desired function is part of the input library specified as a command line argument to metal-nt.

{
  "pipelines": {
    "compute_pipelines": [
      {
        "compute_function": "my_kernel_function"
      }
    ]
  }
}


The syntax alias:<library-identifier>#<function-name> shall be used in the case the desired function is part of a library defined in the libraries object of the Metal script.

{
  "libraries": {
    "paths": [
      {
        "label": "lib1",
        "path": "path/to/lib1.metallib"
      }
    ]
  }
  "pipelines": {
    "compute_pipelines": [
      {
        "compute_function": "alias:lib1#my_kernel_function"
      }
    ]
  }
}


The syntax file:<path-to-library-file>#<function-name> shall be used in the case the desired function is part of a library file on disk.

Paths can either be absolute or relative. Relative paths are always resolved using the library search paths provided with the option -L to metal-nt.

{
  "pipelines": {
    "compute_pipelines": [
      {
        "compute_function": "file:path/to/lib1.metallib#my_kernel_function"
      }
    ]
  }
}


A predicate expression is an arbitrary boolean expression combining builtin predicates and user defined named predicates with the operator && (logical AND), || (logical OR), and ! (logical NOT).

The supportsFamily(<family>) predicate evaluates to true if the target architecture specified with the option -arch to metal-nt supports the specified family. The supported <family> values are:
  • apple1
  • apple2
  • apple3
  • apple4
  • apple5
  • apple6
  • apple7
  • apple8
  • mac2
  • common1
  • common2
  • common3
  • metal3


It is possible to define named predicates in a Metal pipelines script. Each object describing a named predicate can define the members:

The name for the predicate being defined.
Predicate expression. It can reference other named predicates previously defined.

A named predicate can be referenced in an expression with the syntax $<predicate-name>().

{
  "named_predicates": [
    {
      "name": "myPredicate1",
      "predicate": "supportsFamily(apple6) || supports(mac2)"
    },
    {
      "name": "myPredicate2",
      "predicate": "$myPredicate1() && !supportsFamily(common1)"
    }
  ],
  "pipelines": {
    "compute_pipelines": [
      {
        "compute_function": "my_kernel_basic"
      },
      {
        "enable": "$myPredicate1()",
        "compute_function": "my_kernel_advanced"
      },
      {
        "enable": "$myPredicate2() || supportsFamily(apple8) || supportsFamily(metal3)",
        "compute_function": "my_kernel_more_advanced"
      }
    ]
  }
}


This example shows a Metal pipelines script with two compute pipelines and three render pipelines. All the functions are from the input library provided as a command line argument to metal-nt.

{
  "pipelines": {
    "compute_pipelines": [
      {
        "compute_function": "my_kernel_1"
      },
      {
        "compute_function": "my_kernel_2"
      }
    ],
    "render_pipelines": [
      {
        "vertex_function": "my_vertex",
        "fragment_function": "my_fragment_1",
        "color_attachments": [
          {
            "pixel_format": "BGRA8Unorm"
          }
        ]
      },
      {
        "vertex_function": "my_vertex",
        "fragment_function": "my_fragment_2",
        "color_attachments": [
          {
            "pixel_format": "BGRA8Unorm"
          }
        ]
      },
      {
        "vertex_function": "my_vertex_side_effects",
        "rasterization_enabled": false
      }
    ]
  }
}


This example shows a Metal pipelines script with two render pipelines. The fragment functions used in these render pipelines are specialized functions, hence the script contains a description of the specialization process. Since the only way to reference the specialized function libraries is via the library unique identifier, the ALIAS URI syntax is used to reference the specialized functions.

{
  "named_function_constant_values": [
    {
      "name": "my_common_fc_values",
      "constant_values": [
        {
          "id_type": "FunctionConstantIndex",
          "id": {
            "data": 0
          },
          "value_type": "ConstantUInt",
          "value": {
            "data": 42
          }
        },
        {
          "id_type": "FunctionConstantName",
          "id": "base_color",
          "value_type": "ConstantFloat4",
          "value": {
            "data": [0.5, 0.22, 0.25, 1.0]
          }
        }
      ]
    }
  ],
  "libraries": {
    "specialized_functions": [
      {
        "label": "fragment_1_lib",
        "function": "my_fragment",
        "named_constant_values": "my_common_fc_values",
        "constant_values": [
          {
            "id_type": "FunctionConstantName",
            "id": "base_color",
            "value_type": "ConstantFloat4",
            "value": {
              "data": [0.25, 0.25, 0.5, 1.0]
            }
          },
        ]
      },
      {
        "label": "fragment_2_lib",
        "function": "my_fragment",
        "named_constant_values": "my_common_fc_values",
        "constant_values": [
          {
            "id_type": "FunctionConstantIndex",
            "id": {
              "data": 0
            },
            "value_type": "ConstantUInt",
            "value": {
              "data": 23
            }
          }
        ]
      }
    ]
  },
  "pipelines": {
    "render_pipelines": [
      {
        "vertex_function": "my_vertex",
        "fragment_function": "alias:fragment_1_lib#my_fragment",
        "color_attachments": [
          {
            "pixel_format": "BGRA8Unorm"
          }
        ]
      },
      {
        "vertex_function": "my_vertex",
        "fragment_function": "alias:fragment_2_lib#my_fragment",
        "color_attachments": [
          {
            "pixel_format": "BGRA8Unorm"
          }
        ]
      }
    ]
  }
}


Note that in fragment_1_lib the function constant value for the variable base_color provided by my_common_fc_values is overriden locally. Similarly in fragment_2_lib the function constant value for the variable with index 0 provided by my_common_fc_values is overridden locally.

This example shows a Metal pipelines script with three compute pipelines where functions are from libraries either defined as input libraries on disk in the Metal script (see paths), or directly referenced using the FILE URI syntax, or from specialized function libraries using the ALIAS URI syntax.

{
  "libraries": {
    "paths": [
      {
        "label": "lib1",
        "path": "libraries/lib1.metallib"
      }
    ],
    "specialized_functions": [
      {
        "label": "kernel_42_lib",
        "function": "alias:lib1#my_kernel",
        "specialized_name": "my_specialized_kernel",
        "constant_values": [
          {
            "id_type": "FunctionConstantIndex",
            "id": {
              "data": 0
            },
            "value_type": "ConstantUInt",
            "value": {
              "data": 42
            }
          }
        ]
      }
    ]
  },
  "pipelines": {
    "compute_pipelines": [
      {
        "compute_function": "alias:kernel_42_lib#my_specialized_kernel"
      },
      {
        "compute_function": "file:/path/to/custom/lib.metallib#custom_kernel"
      },
      {
        "compute_function": "alias:lib1#base_kernel"
      }
    ]
  }
}


2014-2023, The Metal Team

July 5, 2023 15