tdevdraw: prefer low-power GPU for macOS metal rendering (#231) - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 61601587295f6d0ef1c4084530fe0318e0c72b16
 (DIR) parent 26c6b2579543e928158fa7d3c00d8b0e04ac270c
 (HTM) Author: Chris Schultz <christopher.schultz@auth0.com>
       Date:   Fri,  5 Apr 2019 14:08:20 -0500
       
       devdraw: prefer low-power GPU for macOS metal rendering (#231)
       
       
       Diffstat:
         M src/cmd/devdraw/cocoa-screen-metal… |      15 +++++++++++++--
       
       1 file changed, 13 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m
       t@@ -153,6 +153,7 @@ threadmain(int argc, char **argv)
                id<MTLLibrary> library;
                MTLRenderPipelineDescriptor *pipelineDesc;
                NSError *error;
       +        NSArray *allDevices;
        
                const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled
                        | NSWindowStyleMaskClosable
       t@@ -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];