cocos2d-x
cocos2d-x copied to clipboard
when i press power button, MTLDebugCommandBuffer error
- cocos2d-x version: 4.0
- devices test on: iPhone 7, iOS 10
hi. i'm upgrading my app to cocos2d-x v4 because apple deprecated OpenGLES. It is good but when i testing on iOS 10, Xcode give error message [/BuildRoot/Library/Caches/com.apple.xbs/Sources/Metal/Metal-85.83/ToolsLayers/Debug/MTLDebugCommandBuffer.mm:469: failed assertion `No rendertargets set in RenderPassDescriptor.']
this error show when i press power button. when i press home button, it is work. but just press power button and screen off, then error.
i'm trying uncheck 'Metal API Validation' but still not work.
what should i do?
It's not a fundamental solution, but I found a solution to prevent the error from occurring
renderer/backend/metal/CommandBufferMTL.mm
in CommandBufferMTL::getRenderCommandEncoder() ... auto mtlDescriptor = toMTLRenderPassDescriptor(renderPassDescriptor); _renderTargetWidth = (unsigned int)mtlDescriptor.colorAttachments[0].texture.width; _renderTargetHeight = (unsigned int)mtlDescriptor.colorAttachments[0].texture.height; ++ if(mtlDescriptor.colorAttachments[0].texture == NULL) ++ { ++ return _mtlRenderEncoder; ++ } id<MTLRenderCommandEncoder> mtlRenderEncoder = [_mtlCommandBuffer renderCommandEncoderWithDescriptor:mtlDescriptor]; [mtlRenderEncoder retain]; ...
and
in CommandBufferMTL::endFrame() [_mtlRenderEncoder endEncoding]; [_mtlRenderEncoder release]; _mtlRenderEncoder = nil;
++ if(DeviceMTL::getCurrentDrawable() != nil) ++ { [_mtlCommandBuffer presentDrawable:DeviceMTL::getCurrentDrawable()]; ++ } _drawableTexture = DeviceMTL::getCurrentDrawable().texture; [_mtlCommandBuffer addCompletedHandler:^(id<MTLCommandBuffer> commandBuffer) { ...
I hope this helps someone.