Metal 4 and object lifetime

I have a metal kit view and drain the draw method of its delegate like shown below. Let's say I have one or more MTLBuffers with vertex resources bound via the argument table.

When is it ok to drop these buffers?

As far as I know one cannot schedule a completion handler In Metal 4 and I haven't been able to find any documentation about the lifetime requirements here.

Any pointers/ideas appreciated.

class RenderCoordinator: NSObject, MTKViewDelegate {
  public func draw(in view: MTKView) {
    let commandAllocator: any MTL4CommandAllocator = ...
    let commandBuffer: any MTL4CommandBuffer = ...
    let commandQueue: any MTL4CommandQueue = ...
    guard let drawable = view.currentDrawable else { return }

    commandBuffer.beginCommandBuffer(allocator: commandAllocator)

    let state: any MTLRenderPipelineState = ...
    let encoder: any MTL4RenderCommandEncoder = ...
    let argTable: any MTL4ArgumentTable = ...
    encoder.setRenderPipelineState(state)
    encoder.setArgumentTable(argTable, stages: .vertex)

    commandBuffer.endCommandBuffer()
    commandQueue.waitForDrawable(drawable)
    commandQueue.commit([commandBuffer])
    commandQueue.signalDrawable(drawable)
    drawable.present()
  }
}

the code should, of course have said that

    encoder.setArgumentTable(argTable, stages: .vertex)
    // encode draw commands
    commandBuffer.endCommandBuffer()
Metal 4 and object lifetime
 
 
Q