Changeset 211101 in webkit
- Timestamp:
- Jan 24, 2017, 1:22:39 PM (10 years ago)
- Location:
- branches/safari-603-branch/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/mac/GraphicsContext3DMac.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-603-branch/Source/WebCore/ChangeLog
r211100 r211101 1 2017-01-24 Matthew Hanson <matthew_hanson@apple.com> 2 3 Merge r211028. rdar://problem/30060378 4 5 2017-01-20 Dean Jackson <dino@apple.com> 6 7 [WebGL] Do not allow GPU muxing on some old Mac hardware 8 https://bugs.webkit.org/show_bug.cgi?id=167259 9 <rdar://problem/30060378> 10 11 Reviewed by Simon Fraser and Darin Adler. 12 13 Some old Macbook Pro models should never use the 14 integrated GPU for WebGL, because they are unstable 15 when swapping between that and the discrete GPU. 16 17 Unfortunately this hardware configuration isn't in our 18 testing infrastructure, so it was confirmed manually. 19 Meanwhile, our existing tests make sure this patch 20 doesn't break anything elsewhere. 21 22 * platform/graphics/mac/GraphicsContext3DMac.mm: 23 (WebCore::attachToAppleGraphicsControl): Helper function 24 to get a mach port that talks to Apple's Graphics Control 25 system. 26 (WebCore::hasMuxCapability): Decides whether a system 27 can do live GPU switching, based on whether or not it 28 has a muxable GPU, and if that GPU is not the old hardware 29 we know is problematic. 30 (WebCore::hasMuxableGPU): Helper to return the static hasMuxCapability value. 31 (WebCore::setPixelFormat): Only request the integrated card when the 32 GPU is muxable. 33 1 34 2017-01-24 Matthew Hanson <matthew_hanson@apple.com> 2 35 -
branches/safari-603-branch/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
r209549 r211101 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.