From c904706a6b7af010f9a9b6838ef4bd1433198f8a Mon Sep 17 00:00:00 2001 From: rogerman Date: Wed, 18 May 2022 12:44:00 -0700 Subject: [PATCH] Cocoa Port: If default.metallib is missing or corrupted in the app bundle, then fail running Metal video output and fall back to using OpenGL instead. --- .../cocoa/userinterface/MacMetalDisplayView.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm b/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm index 33af2728a..8f8c7498e 100644 --- a/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm +++ b/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm @@ -61,9 +61,17 @@ } device = MTLCreateSystemDefaultDevice(); - if (device == nil) { + NSLog(@"Metal: A Metal device could not be found."); + [self release]; + return nil; + } + + defaultLibrary = [device newDefaultLibrary]; + if (defaultLibrary == nil) + { + NSLog(@"Metal: The default.metallib could not be loaded!"); [self release]; return nil; } @@ -103,8 +111,6 @@ _fetchCommandQueue = [device newCommandQueue]; [_fetchCommandQueue setLabel:@"CQ_DeSmuME_FramebufferFetch"]; - defaultLibrary = [device newDefaultLibrary]; - MTLComputePipelineDescriptor *computePipelineDesc = [[MTLComputePipelineDescriptor alloc] init]; [computePipelineDesc setThreadGroupSizeIsMultipleOfThreadExecutionWidth:YES];