Title: [252055] trunk/Source/WebCore
Revision
252055
Author
[email protected]
Date
2019-11-05 08:52:31 -0800 (Tue, 05 Nov 2019)

Log Message

Enable powerPreference controlled GPU switching with ANGLE
https://bugs.webkit.org/show_bug.cgi?id=203773

GPU switching can't be controlled from within ANGLE running in the content process
due to sandbox restrictions. So we need to continue using the existing
HighPerformanceGPUManager path with ANGLE.

Although the high power GPU is activated on request with this change, ANGLE does
not use it yet.

Patch by James Darpinian <[email protected]> on 2019-11-05
Reviewed by Alex Christensen.

* platform/graphics/GraphicsContext3D.cpp:
* platform/graphics/GraphicsContext3D.h:
* platform/graphics/GraphicsContext3DManager.cpp:
(WebCore::GraphicsContext3DManager::updateHighPerformanceState):
(WebCore::GraphicsContext3DManager::disableHighPerformanceGPUTimerFired):
* platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
(WebCore::GraphicsContext3D::GraphicsContext3D):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252054 => 252055)


--- trunk/Source/WebCore/ChangeLog	2019-11-05 16:40:27 UTC (rev 252054)
+++ trunk/Source/WebCore/ChangeLog	2019-11-05 16:52:31 UTC (rev 252055)
@@ -1,3 +1,25 @@
+2019-11-05  James Darpinian  <[email protected]>
+
+        Enable powerPreference controlled GPU switching with ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=203773
+
+        GPU switching can't be controlled from within ANGLE running in the content process
+        due to sandbox restrictions. So we need to continue using the existing
+        HighPerformanceGPUManager path with ANGLE.
+
+        Although the high power GPU is activated on request with this change, ANGLE does
+        not use it yet.
+
+        Reviewed by Alex Christensen.
+
+        * platform/graphics/GraphicsContext3D.cpp:
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/GraphicsContext3DManager.cpp:
+        (WebCore::GraphicsContext3DManager::updateHighPerformanceState):
+        (WebCore::GraphicsContext3DManager::disableHighPerformanceGPUTimerFired):
+        * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+
 2019-11-05  youenn fablet  <[email protected]>
 
         mp4 video element broken with service worker

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp (252054 => 252055)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp	2019-11-05 16:40:27 UTC (rev 252054)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp	2019-11-05 16:52:31 UTC (rev 252055)
@@ -656,7 +656,7 @@
     }
 }
 
-#if !(PLATFORM(COCOA) && USE(OPENGL))
+#if !(PLATFORM(COCOA) && (USE(OPENGL) || USE(ANGLE)))
 void GraphicsContext3D::setContextVisibility(bool)
 {
 }

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (252054 => 252055)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2019-11-05 16:40:27 UTC (rev 252054)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2019-11-05 16:52:31 UTC (rev 252055)
@@ -1567,7 +1567,7 @@
     Platform3DObject m_vao { 0 };
 #endif
 
-#if PLATFORM(COCOA) && USE(OPENGL)
+#if PLATFORM(COCOA) && (USE(OPENGL) || USE(ANGLE))
     bool m_hasSwitchedToHighPerformanceGPU { false };
 #endif
 };

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3DManager.cpp (252054 => 252055)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3DManager.cpp	2019-11-05 16:40:27 UTC (rev 252054)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3DManager.cpp	2019-11-05 16:52:31 UTC (rev 252055)
@@ -35,7 +35,7 @@
 #include <sys/sysctl.h>
 #endif
 
-#if PLATFORM(MAC) && USE(OPENGL)
+#if PLATFORM(MAC) && (USE(OPENGL) || USE(ANGLE))
 #include "SwitchingGPUClient.h"
 #include <OpenGL/OpenGL.h>
 #endif
@@ -222,7 +222,7 @@
 
 void GraphicsContext3DManager::updateHighPerformanceState()
 {
-#if PLATFORM(MAC) && USE(OPENGL)
+#if PLATFORM(MAC) && (USE(OPENGL) || USE(ANGLE))
     if (!hasLowAndHighPowerGPUs())
         return;
     
@@ -262,7 +262,7 @@
         return;
 
     m_requestingHighPerformance = false;
-#if PLATFORM(MAC) && USE(OPENGL)
+#if PLATFORM(MAC) && (USE(OPENGL) || USE(ANGLE))
     SwitchingGPUClient::singleton().releaseHighPerformanceGPU();
 #endif
 }

Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm (252054 => 252055)


--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm	2019-11-05 16:40:27 UTC (rev 252054)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm	2019-11-05 16:52:31 UTC (rev 252055)
@@ -178,12 +178,19 @@
     }
 }
 
-#endif // PLATFORM(MAC) && USE(OPENGL)
+#endif // PLATFORM(MAC) && (USE(OPENGL) || USE(ANGLE))
 
 GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle, GraphicsContext3D* sharedContext)
     : m_attrs(attrs)
     , m_private(makeUnique<GraphicsContext3DPrivate>(this))
 {
+
+#if HAVE(APPLE_GRAPHICS_CONTROL)
+    m_powerPreferenceUsedForCreation = (hasLowAndHighPowerGPUs() && attrs.powerPreference == GraphicsContext3DPowerPreference::HighPerformance) ? GraphicsContext3DPowerPreference::HighPerformance : GraphicsContext3DPowerPreference::Default;
+#else
+    m_powerPreferenceUsedForCreation = GraphicsContext3DPowerPreference::Default;
+#endif
+
 #if !USE(ANGLE)
 #if USE(OPENGL_ES)
     if (m_attrs.isWebGL2)
@@ -209,12 +216,6 @@
         ::glEnable(GraphicsContext3D::PRIMITIVE_RESTART_FIXED_INDEX);
 #elif USE(OPENGL)
 
-#if HAVE(APPLE_GRAPHICS_CONTROL)
-    m_powerPreferenceUsedForCreation = (hasLowAndHighPowerGPUs() && attrs.powerPreference == GraphicsContext3DPowerPreference::HighPerformance) ? GraphicsContext3DPowerPreference::HighPerformance : GraphicsContext3DPowerPreference::Default;
-#else
-    m_powerPreferenceUsedForCreation = GraphicsContext3DPowerPreference::Default;
-#endif
-
     bool useMultisampling = m_attrs.antialias;
 
     Vector<CGLPixelFormatAttribute> attribs;
@@ -699,6 +700,9 @@
     m_hasSwitchedToHighPerformanceGPU = true;
 }
 
+#endif // USE(OPENGL)
+
+#if USE(OPENGL) || USE(ANGLE)
 void GraphicsContext3D::setContextVisibility(bool isVisible)
 {
     if (m_powerPreferenceUsedForCreation == GraphicsContext3DPowerPreference::HighPerformance) {
@@ -708,7 +712,7 @@
             GraphicsContext3DManager::sharedManager().removeContextRequiringHighPerformance(this);
     }
 }
-#endif // USE(OPENGL)
+#endif // USE(OPENGL) || USE(ANGLE)
 
 #if USE(ANGLE)
 void GraphicsContext3D::allocateIOSurfaceBackingStore(IntSize size)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to