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?
The following is my the modified code, no error tips 【CAMetalLayerDrawable present] should not be called after already presenting this drawable. Get a nextDrawable instead.】, hope it helps you.
It may be in other background threads before rendering, when GPU start render, used dispatch_async(get_main), make sure render work in main thread.
Show the error tips because: You need to pass "metalView.layer.nextDrawable" instead of "metalView.currentDrawable" parameters when commandBuffer calls presentDrawable.