fix some bugs on macos and improve presentation queue

This commit is contained in:
Greg Wells
2025-07-01 16:15:43 -04:00
parent 4c7fe77db3
commit 504603e5ac
11 changed files with 41 additions and 36 deletions

View File

@@ -8,19 +8,15 @@ gnReturnCode metalPresent(gnOutputDeviceHandle device, gnPresentInfo info) {
for (int i =0 ; i < info.presentationQueueCount; i++) {
info.presentationQueues[i]->info.surface->windowSurface->layer.device = device->outputDevice->device;
id<CAMetalDrawable> drawable = [info.presentationQueues[i]->info.surface->windowSurface->layer nextDrawable];
if (drawable == nil) {
return GN_FAILED_TO_CREATE_FRAMEBUFFER;
}
if (drawable == nil) return GN_FAILED_TO_CREATE_FRAMEBUFFER;
__block gnPresentationQueue presentationQueue = info.presentationQueues[i];
__block uint32_t imageIndex = info.imageIndices[i];
id<MTLCommandBuffer> commandBuffer = [device->outputDevice->transferQueue commandBuffer];
MTLRenderPassDescriptor* passDesc = [MTLRenderPassDescriptor renderPassDescriptor];
passDesc.colorAttachments[0].texture = drawable.texture;
passDesc.colorAttachments[0].loadAction = MTLLoadActionClear;
passDesc.colorAttachments[0].storeAction = MTLStoreActionStore;
passDesc.colorAttachments[0].clearColor = MTLClearColorMake(1.0f, 0, 0, 1.0f);
id<MTLRenderCommandEncoder> render = [commandBuffer renderCommandEncoderWithDescriptor:passDesc];
[render endEncoding];
[commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
uint32_tArrayListAdd(&presentationQueue->presentationQueue->avaliableTextures, imageIndex);
}];
id<MTLBlitCommandEncoder> blit = [commandBuffer blitCommandEncoder];