Search code examples
iosmetal

How to specify label property for MTLComputePipelineState


label is a readonly property of MTLComputePipelineState so we can't change it after the creation (unlike with MTLTexture). But I don't see any way to even specify it during the creation of MTLComputePipelineState. What do I miss?


Solution

  • You are probably creating the MTLComputePipelineState using newComputePipelineStateWithFunction:error function or it's Swift equivalent. It doesn't have a way to populate the label property.

    Instead, if you want to set a label, you could fill out an MTLComputePipelineDescriptor and use newComputePipelineStateWithDescriptor:options:reflection:error to create the pipeline.

    To get an equivalent pipeline, you would just need to populate computeFunction property on the MTLComputePipelineDescriptor with an MTLFunction that you were passing to newComputePipelineStateWithFunction:error and populate the label property with the label you want.