aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/devdraw
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/devdraw')
-rw-r--r--src/cmd/devdraw/cocoa-screen-metal.m15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m
index 78110302..21c041a5 100644
--- a/src/cmd/devdraw/cocoa-screen-metal.m
+++ b/src/cmd/devdraw/cocoa-screen-metal.m
@@ -153,6 +153,7 @@ threadmain(int argc, char **argv)
id<MTLLibrary> library;
MTLRenderPipelineDescriptor *pipelineDesc;
NSError *error;
+ NSArray *allDevices;
const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled
| NSWindowStyleMaskClosable
@@ -197,8 +198,18 @@ threadmain(int argc, char **argv)
[win setContentView:myContent];
[myContent setWantsLayer:YES];
[myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay];
-
- device = MTLCreateSystemDefaultDevice();
+
+ device = nil;
+ allDevices = MTLCopyAllDevices();
+ for(id mtlDevice in allDevices) {
+ if ([mtlDevice isLowPower] && ![mtlDevice isRemovable]) {
+ device = mtlDevice;
+ break;
+ }
+ }
+ if(!device)
+ device = MTLCreateSystemDefaultDevice();
+
commandQueue = [device newCommandQueue];
layer = (DrawLayer *)[myContent layer];