devdraw: prefer low-power GPU for macOS metal rendering (#231)
This commit is contained in:
parent
26c6b25795
commit
6160158729
1 changed files with 13 additions and 2 deletions
|
|
@ -153,6 +153,7 @@ threadmain(int argc, char **argv)
|
||||||
id<MTLLibrary> library;
|
id<MTLLibrary> library;
|
||||||
MTLRenderPipelineDescriptor *pipelineDesc;
|
MTLRenderPipelineDescriptor *pipelineDesc;
|
||||||
NSError *error;
|
NSError *error;
|
||||||
|
NSArray *allDevices;
|
||||||
|
|
||||||
const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled
|
const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled
|
||||||
| NSWindowStyleMaskClosable
|
| NSWindowStyleMaskClosable
|
||||||
|
|
@ -198,7 +199,17 @@ threadmain(int argc, char **argv)
|
||||||
[myContent setWantsLayer:YES];
|
[myContent setWantsLayer:YES];
|
||||||
[myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay];
|
[myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay];
|
||||||
|
|
||||||
|
device = nil;
|
||||||
|
allDevices = MTLCopyAllDevices();
|
||||||
|
for(id mtlDevice in allDevices) {
|
||||||
|
if ([mtlDevice isLowPower] && ![mtlDevice isRemovable]) {
|
||||||
|
device = mtlDevice;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!device)
|
||||||
device = MTLCreateSystemDefaultDevice();
|
device = MTLCreateSystemDefaultDevice();
|
||||||
|
|
||||||
commandQueue = [device newCommandQueue];
|
commandQueue = [device newCommandQueue];
|
||||||
|
|
||||||
layer = (DrawLayer *)[myContent layer];
|
layer = (DrawLayer *)[myContent layer];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue