Post

Replies

Boosts

Views

Activity

Reply to MTKView issue.
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. code: (void)startRender() { dispatch_block_t renderBlock = ^ { @autoreleasepool { ...... ...... idMTLTexture drawingTexture =  metalView.currentDrawable.texture; ...... passDescriptor.colorAttachments[0].texture = drawingTexture; ...... ...... [renderEncoder popDebugGroup]; [renderEncoder endEncoding]; [commandBuffer presentDrawable:[(CAMetalLayer*)metalView.layer nextDrawable] ]; [commandBuffer commit]; }};  ([NSThread isMainThread])?renderBlock():dispatch_async(dispatch_get_main_queue(), renderBlock); } 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.
May ’21