Title: [279303] trunk/Source
Revision
279303
Author
mmaxfi...@apple.com
Date
2021-06-25 17:39:22 -0700 (Fri, 25 Jun 2021)

Log Message

[macOS] WebGL content is unable to use the discrete GPU
https://bugs.webkit.org/show_bug.cgi?id=227408
<rdar://problem/79216506>

Reviewed by Dean Jackson.

Source/ThirdParty/ANGLE:

There appears to be a key collision:

Source/ThirdParty/ANGLE/include/platform/PlatformMethods.h:#define EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX 0x3482
Source/ThirdParty/ANGLE/include/EGL/eglext_angle.h:#define EGL_POWER_PREFERENCE_ANGLE 0x3482

Both these keys seem to be accepted by EGL_GetPlatformDisplayEXT().

This patch just changes the value of one of them to a value I picked out of a hat, just so they don't conflict.
We should work with upstream to either:
A) Find a better solution (maybe disambiguate these values based on which function is accepting them), or
B) Make a robust way to make sure keys don't collide in the future.

* include/platform/PlatformMethods.h:

Source/WebCore:

Simply pass along the power preference into ANGLE. This is read in
DisplayMtl::getMetalDeviceMatchingAttribute().

No new tests. I _think_ this is untestable, because the web exposed power preference is being set correctly.
We’re correctly reporting to the web content that they have successfully asked for a high power context.
We’re just not honoring that internally. If the test is a performance test, or checks the renderer string,
that test would be hardware-dependent, and couldn’t be a regular layout test.

* platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
(WebCore::InitializeEGLDisplay):

Modified Paths

Diff

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (279302 => 279303)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-06-26 00:23:59 UTC (rev 279302)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-06-26 00:39:22 UTC (rev 279303)
@@ -1,3 +1,25 @@
+2021-06-25  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [macOS] WebGL content is unable to use the discrete GPU
+        https://bugs.webkit.org/show_bug.cgi?id=227408
+        <rdar://problem/79216506>
+
+        Reviewed by Dean Jackson.
+
+        There appears to be a key collision:
+
+        Source/ThirdParty/ANGLE/include/platform/PlatformMethods.h:#define EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX 0x3482
+        Source/ThirdParty/ANGLE/include/EGL/eglext_angle.h:#define EGL_POWER_PREFERENCE_ANGLE 0x3482
+
+        Both these keys seem to be accepted by EGL_GetPlatformDisplayEXT().
+
+        This patch just changes the value of one of them to a value I picked out of a hat, just so they don't conflict.
+        We should work with upstream to either:
+        A) Find a better solution (maybe disambiguate these values based on which function is accepting them), or
+        B) Make a robust way to make sure keys don't collide in the future.
+
+        * include/platform/PlatformMethods.h:
+
 2021-06-24  John Cunningham  <johncunning...@apple.com>
 
         [ANGLE Metal] - Set barriers on transform feedback buffers only up to the in use buffer count

Modified: trunk/Source/ThirdParty/ANGLE/include/platform/PlatformMethods.h (279302 => 279303)


--- trunk/Source/ThirdParty/ANGLE/include/platform/PlatformMethods.h	2021-06-26 00:23:59 UTC (rev 279302)
+++ trunk/Source/ThirdParty/ANGLE/include/platform/PlatformMethods.h	2021-06-26 00:39:22 UTC (rev 279303)
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <array>
 
-#define EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX 0x3482
+#define EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX 0x34FD
 
 #if !defined(ANGLE_PLATFORM_EXPORT)
 #    if defined(__GNUC__) || defined(__clang__)

Modified: trunk/Source/WebCore/ChangeLog (279302 => 279303)


--- trunk/Source/WebCore/ChangeLog	2021-06-26 00:23:59 UTC (rev 279302)
+++ trunk/Source/WebCore/ChangeLog	2021-06-26 00:39:22 UTC (rev 279303)
@@ -1,5 +1,24 @@
 2021-06-25  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        [macOS] WebGL content is unable to use the discrete GPU
+        https://bugs.webkit.org/show_bug.cgi?id=227408
+        <rdar://problem/79216506>
+
+        Reviewed by Dean Jackson.
+
+        Simply pass along the power preference into ANGLE. This is read in
+        DisplayMtl::getMetalDeviceMatchingAttribute().
+
+        No new tests. I _think_ this is untestable, because the web exposed power preference is being set correctly.
+        We’re correctly reporting to the web content that they have successfully asked for a high power context.
+        We’re just not honoring that internally. If the test is a performance test, or checks the renderer string,
+        that test would be hardware-dependent, and couldn’t be a regular layout test.
+
+        * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
+        (WebCore::InitializeEGLDisplay):
+
+2021-06-25  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         [macOS] -[NSString _web_widthWithFont:] returns 0
         https://bugs.webkit.org/show_bug.cgi?id=227385
         <rdar://problem/79430938>

Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm (279302 => 279303)


--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm	2021-06-26 00:23:59 UTC (rev 279302)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm	2021-06-26 00:39:22 UTC (rev 279303)
@@ -121,6 +121,15 @@
         displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE);
     }
     LOG(WebGL, "Attempting to use ANGLE's %s backend.\n", attrs.useMetal ? "Metal" : "OpenGL");
+    if (attrs.powerPreference != GraphicsContextGLAttributes::PowerPreference::Default) {
+        displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE);
+        if (attrs.powerPreference == GraphicsContextGLAttributes::PowerPreference::LowPower)
+            displayAttributes.append(EGL_LOW_POWER_ANGLE);
+        else {
+            ASSERT(attrs.powerPreference == GraphicsContextGLAttributes::PowerPreference::HighPerformance);
+            displayAttributes.append(EGL_HIGH_POWER_ANGLE);
+        }
+    }
     displayAttributes.append(EGL_NONE);
     display = EGL_GetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast<void*>(EGL_DEFAULT_DISPLAY), displayAttributes.data());
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to