From 8c2df13f3b5141a0772c1db7f4ee35d725ee64d6 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 30 May 2022 00:15:49 -0700 Subject: [PATCH] [Visualization] Disable visualization if no Metal If the system has no working Metal devices, disable the visualization. The legacy visualization was also too slow for said systems to handle reasonably anyway, so I guess it's safe to say that they shouldn't have to handle any visualizers at all. At least have working audio playback, of course, since that is the primary function of the application. Too bad that the OpenGL renderers don't work on my scene, it would be nice to have a fallback there. GL 4.1 crashes on an M1, and both GL 4.1 and 3.2 crash with SIGFPE division by zero error on Intel Macs without Metal devices. Meh. Signed-off-by: Christopher Snowhill --- SpectrumWindowController.m | 1 + Visualization/SpectrumView.m | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/SpectrumWindowController.m b/SpectrumWindowController.m index 6fd4e5beb..5b3528a4e 100644 --- a/SpectrumWindowController.m +++ b/SpectrumWindowController.m @@ -29,6 +29,7 @@ if(!self.spectrumView) { self.spectrumView = [[SpectrumView alloc] initWithFrame:[[self window] frame]]; [[self window] setContentView:self.spectrumView]; + if(!self.spectrumView) return; [self.spectrumView enableCameraControl]; } diff --git a/Visualization/SpectrumView.m b/Visualization/SpectrumView.m index 07c581b2f..d5a51fbf5 100644 --- a/Visualization/SpectrumView.m +++ b/Visualization/SpectrumView.m @@ -45,8 +45,13 @@ extern NSString *CogPlaybackDidStopNotficiation; @synthesize isListening; - (id)initWithFrame:(NSRect)frame { + id device = MTLCreateSystemDefaultDevice(); + + if(!device) return nil; + NSDictionary *sceneOptions = @{ SCNPreferredRenderingAPIKey: @(SCNRenderingAPIMetal), + SCNPreferredDeviceKey: device, SCNPreferLowPowerDeviceKey: @(NO) };