Disable frame boundary semaphore in CommandBuffer

This commit is contained in:
pandamicro
2020-11-26 00:28:01 +08:00
committed by Yun Hsiao Wu
parent 62316c02dc
commit 0c385ea0de
@@ -44,7 +44,12 @@ namespace cc {
namespace gfx {
CCMTLCommandBuffer::CCMTLCommandBuffer(Device *device)
: CommandBuffer(device), _mtlDevice((CCMTLDevice *)device), _mtlCommandQueue(id<MTLCommandQueue>(((CCMTLDevice *)device)->getMTLCommandQueue())), _mtkView((MTKView *)(((CCMTLDevice *)device)->getMTKView())) {
: CommandBuffer(device)
, _mtlDevice((CCMTLDevice *)device)
, _mtlCommandQueue(id<MTLCommandQueue>(((CCMTLDevice *)device)->getMTLCommandQueue()))
, _mtkView((MTKView *)(((CCMTLDevice *)device)->getMTKView()))
//, _frameBoundarySemaphore(dispatch_semaphore_create(MAX_INFLIGHT_BUFFER))
{
const auto setCount = device->bindingMappingInfo().bufferOffsets.size();
_GPUDescriptorSets.resize(setCount);
_dynamicOffsets.resize(setCount);
@@ -58,11 +63,14 @@ bool CCMTLCommandBuffer::initialize(const CommandBufferInfo &info) {
}
void CCMTLCommandBuffer::destroy() {
// dispatch_semaphore_signal(_frameBoundarySemaphore);
}
void CCMTLCommandBuffer::begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer, int submitIndex) {
if (_commandBufferBegan) return;
// dispatch_semaphore_wait(_frameBoundarySemaphore, DISPATCH_TIME_FOREVER);
_mtlCommandBuffer = [_mtlCommandQueue commandBuffer];
[_mtlCommandBuffer retain];
[_mtlCommandBuffer enqueue];
@@ -81,6 +89,14 @@ void CCMTLCommandBuffer::begin(RenderPass *renderPass, uint subpass, Framebuffer
void CCMTLCommandBuffer::end() {
if (!_commandBufferBegan) return;
[_mtlCommandBuffer presentDrawable:_mtkView.currentDrawable];
[_mtlCommandBuffer addCompletedHandler:^(id<MTLCommandBuffer> commandBuffer) {
// GPU work is complete
// Signal the semaphore to start the CPU work
// dispatch_semaphore_signal(_frameBoundarySemaphore);
[commandBuffer release];
}];
[_mtlCommandBuffer commit];
_commandBufferBegan = false;
}