fix iphone 5s compile issue (#4027)

This commit is contained in:
Zeqiang Li
2021-11-02 17:41:27 +08:00
committed by GitHub
parent a2d87f2e60
commit 68d508abbd
3 changed files with 12 additions and 8 deletions
@@ -81,7 +81,6 @@ void CCMTLCommandBuffer::doDestroy() {
_mtlCommandQueue = nil;
_parallelEncoder = nil;
// mtlCommandbuffer released in present.completeHandler
CC_SAFE_DELETE(_gpuCommandBufferObj);
}
@@ -102,7 +101,7 @@ void CCMTLCommandBuffer::begin(RenderPass *renderPass, uint subpass, Framebuffer
if (!_gpuCommandBufferObj->isSecondary) {
auto *mtlQueue = static_cast<CCMTLQueue *>(_queue)->gpuQueueObj()->mtlCommandQueue;
// Only primary command buffer should request command buffer explicitly
_gpuCommandBufferObj->mtlCommandBuffer = [mtlQueue commandBuffer];
_gpuCommandBufferObj->mtlCommandBuffer = [[mtlQueue commandBuffer] retain];
}
_numTriangles = 0;
@@ -73,6 +73,8 @@ void CCMTLQueue::submit(CommandBuffer *const *cmdBuffs, uint count) {
_gpuQueueObj->numTriangles += cmdBuffer->getNumTris();
id<MTLCommandBuffer> mtlCmdBuffer = cmdBuffer->gpuCommandBufferObj()->mtlCommandBuffer;
[mtlCmdBuffer commit];
[mtlCmdBuffer release];
cmdBuffer->gpuCommandBufferObj()->mtlCommandBuffer = nil;
cmdBuffer->reset();
}
}
@@ -64,19 +64,22 @@ void CCMTLSwapchain::doInit(const SwapchainInfo &info) {
layer.framebufferOnly = NO;
//setDisplaySyncEnabled : physic device refresh rate.
//setPresentsWithTransaction : Core Animation transactions update rate.
auto syncModeFunc = [&](BOOL sync, BOOL transaction) {
#if CC_PLATFORM == CC_PLATFORM_MAC_OSX
[layer setDisplaySyncEnabled:sync];
#endif
[layer setPresentsWithTransaction:transaction];
};
switch (_vsyncMode) {
case VsyncMode::OFF:
[layer setDisplaySyncEnabled:NO];
[layer setPresentsWithTransaction:NO];
syncModeFunc(NO, NO);
break;
case VsyncMode::ON:
[layer setDisplaySyncEnabled:YES];
[layer setPresentsWithTransaction:YES];
syncModeFunc(YES, YES);
case VsyncMode::RELAXED:
case VsyncMode::MAILBOX:
case VsyncMode::HALF:
[layer setDisplaySyncEnabled:YES];
[layer setPresentsWithTransaction:NO];
syncModeFunc(YES, NO);
default:
break;
}