Search code examples
metal

What is a "_status < MTLCommandBufferStatusCommitted" assertion failure?


I'm using Metal to execute a compute kernel, but I'm receiving the following error:

failed assertion _status < MTLCommandBufferStatusCommitted at line 316 in -[IOGPUMetalCommandBuffer setCurrentCommandEncoder:]

What does this mean?


Solution

  • I'm not sure you are supposed to see this assertion because it seems internal to OS, but anyway.

    I think what the assertion is trying to say is that you can't add a compute command encoder to a command buffer if the command buffer is committed, scheduled or completed. You can only create a command encoder from a command buffer that has NotEnqueued or Enqueued status.

    The other problem I see here, is that you are not using the Metal API Validation. If you were, you would get a much more meaningful and actionable assertion. You could enable it in Xcode in scheme settings under "Metal API validation" or you can pass an environment variable if you are running your app from CLI or using some other means. More information about validation can be found in man MetalValidation in Terminal.