Changeset 211028 in webkit
- Timestamp:
- Jan 22, 2017, 10:51:09 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/mac/GraphicsContext3DMac.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r211027 r211028 1 2017-01-20 Dean Jackson <dino@apple.com> 2 3 [WebGL] Do not allow GPU muxing on some old Mac hardware 4 https://bugs.webkit.org/show_bug.cgi?id=167259 5 <rdar://problem/30060378> 6 7 Reviewed by Simon Fraser and Darin Adler. 8 9 Some old Macbook Pro models should never use the 10 integrated GPU for WebGL, because they are unstable 11 when swapping between that and the discrete GPU. 12 13 Unfortunately this hardware configuration isn't in our 14 testing infrastructure, so it was confirmed manually. 15 Meanwhile, our existing tests make sure this patch 16 doesn't break anything elsewhere. 17 18 * platform/graphics/mac/GraphicsContext3DMac.mm: 19 (WebCore::attachToAppleGraphicsControl): Helper function 20 to get a mach port that talks to Apple's Graphics Control 21 system. 22 (WebCore::hasMuxCapability): Decides whether a system 23 can do live GPU switching, based on whether or not it 24 has a muxable GPU, and if that GPU is not the old hardware 25 we know is problematic. 26 (WebCore::hasMuxableGPU): Helper to return the static hasMuxCapability value. 27 (WebCore::setPixelFormat): Only request the integrated card when the 28 GPU is muxable. 29 1 30 2017-01-22 Don Olmstead <don.olmstead@am.sony.com> and Myles C. Maxfield <mmaxfield@apple.com> 2 31 -
trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
r209549 r211028 42 42 #include "ImageBuffer.h" 43 43 #include "Logging.h" 44 #include "WebGLLayer.h" 45 #include "WebGLObject.h" 46 #include "WebGLRenderingContextBase.h" 47 #include <sys/sysctl.h> 48 #include <sysexits.h> 49 #include <wtf/text/CString.h> 50 44 51 #if PLATFORM(IOS) 45 52 #import "OpenGLESSPI.h" … … 49 56 #import <QuartzCore/QuartzCore.h> 50 57 #else 58 #include <IOKit/IOKitLib.h> 51 59 #include <OpenGL/CGLRenderers.h> 52 60 #include <OpenGL/gl.h> 53 61 #endif 54 #include "WebGLLayer.h"55 #include "WebGLObject.h"56 #include "WebGLRenderingContextBase.h"57 #include <sysexits.h>58 #include <wtf/text/CString.h>59 62 60 63 namespace WebCore { … … 79 82 }; 80 83 81 #if !PLATFORM(IOS) 84 #if PLATFORM(MAC) 85 86 enum { 87 kAGCOpen, 88 kAGCClose 89 }; 90 91 static io_connect_t attachToAppleGraphicsControl() 92 { 93 mach_port_t masterPort; 94 95 if (IOMasterPort(MACH_PORT_NULL, &masterPort) != KERN_SUCCESS) 96 return MACH_PORT_NULL; 97 98 CFDictionaryRef classToMatch = IOServiceMatching("AppleGraphicsControl"); 99 if (!classToMatch) 100 return MACH_PORT_NULL; 101 102 kern_return_t kernResult; 103 io_iterator_t iterator; 104 if ((kernResult = IOServiceGetMatchingServices(masterPort, classToMatch, &iterator)) != KERN_SUCCESS) 105 return MACH_PORT_NULL; 106 107 io_service_t serviceObject = IOIteratorNext(iterator); 108 IOObjectRelease(iterator); 109 if (!serviceObject) 110 return MACH_PORT_NULL; 111 112 io_connect_t dataPort; 113 IOObjectRetain(serviceObject); 114 kernResult = IOServiceOpen(serviceObject, mach_task_self(), 0, &dataPort); 115 IOObjectRelease(serviceObject); 116 117 return (kernResult == KERN_SUCCESS) ? dataPort : MACH_PORT_NULL; 118 } 119 120 static bool hasMuxCapability() 121 { 122 io_connect_t dataPort = attachToAppleGraphicsControl(); 123 124 if (dataPort == MACH_PORT_NULL) 125 return false; 126 127 bool result; 128 if (IOConnectCallScalarMethod(dataPort, kAGCOpen, nullptr, 0, nullptr, nullptr) == KERN_SUCCESS) { 129 IOConnectCallScalarMethod(dataPort, kAGCClose, nullptr, 0, nullptr, nullptr); 130 result = true; 131 } else 132 result = false; 133 134 IOServiceClose(dataPort); 135 136 if (result) { 137 // This is detecting Mac hardware with an Intel g575 GPU, which 138 // we don't want to make available to muxing. 139 // Based on information from Apple's OpenGL team, such devices 140 // have four or fewer processors. 141 // <rdar://problem/30060378> 142 int names[2] = { CTL_HW, HW_NCPU }; 143 int cpuCount; 144 size_t cpuCountLength = sizeof(cpuCount); 145 sysctl(names, 2, &cpuCount, &cpuCountLength, nullptr, 0); 146 result = cpuCount > 4; 147 } 148 149 return result; 150 } 151 152 static bool hasMuxableGPU() 153 { 154 static bool canMux = hasMuxCapability(); 155 return canMux; 156 } 157 82 158 static void setPixelFormat(Vector<CGLPixelFormatAttribute>& attribs, int colorBits, int depthBits, bool accelerated, bool supersample, bool closest, bool antialias, bool allowOffline, bool useGLES3) 83 159 { … … 93 169 // system, and not force the discrete GPU. 94 170 // See https://developer.apple.com/library/mac/technotes/tn2229/_index.html 95 if (allowOffline )171 if (allowOffline && hasMuxableGPU()) 96 172 attribs.append(kCGLPFAAllowOfflineRenderers); 97 173
Note:
See TracChangeset
for help on using the changeset viewer.