I just need to render multiple objects simultaneously. But I am getting an error as mention. Here I am passing multiple objects to my render func.
var sceneObject:Array<Node> = [objectToDraw,temObjectToDraw]
for scene in sceneObject{
scene .render(commandQueue: commandQueue, pipelineState: pipelineState, drawable: drawable,viewportSize:viewPortSize, clearColor: nil/*,texture: texture*/)
}
where render() class is as follows
func render(.....) {
...
commandBuffer.present(drawable)
commandBuffer.commit()
}
But I'm getting log error message:
[CAMetalLayerDrawable texture] should not be called after already presenting this drawable. Get a nextDrawable instead.
Does someone have a clue?
I ran into this recently. In my case, the problem was that the
MTKView.draw()command was being executed on a different thread from the buffer set up. I had been dispatching to a background thread to do some Core Image work, then dispatching back to the main thread to draw (sinceMTKViewinherits fromUIViewand cannot be called safely off the main thread).