Title: [234117] trunk/Source/WebCore
Revision
234117
Author
[email protected]
Date
2018-07-23 16:20:16 -0700 (Mon, 23 Jul 2018)

Log Message

[macOS] Ensure that WebGL contexts are always set to an accelerated virtual screen
https://bugs.webkit.org/show_bug.cgi?id=187923

Patch by Justin Fan <[email protected]> on 2018-07-23
Reviewed by Dean Jackson.

On eGPU displays, it is possible that CGL does not match the preferred renderer.
In this case, and when the web process is blocked from accessing the window server,
3D contexts *may* default to the software renderer. Ensure that even if this occurs,
we set the context to use a hardware-accelerated renderer/virtual screen.

No new tests. Existing behavior covered by existing tests.
Requires multiple screens, at least one attached to an eGPU, to stress.

* platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
(WebCore::identifyAndSetCurrentGPU):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (234116 => 234117)


--- trunk/Source/WebCore/ChangeLog	2018-07-23 23:07:33 UTC (rev 234116)
+++ trunk/Source/WebCore/ChangeLog	2018-07-23 23:20:16 UTC (rev 234117)
@@ -1,3 +1,21 @@
+2018-07-23  Justin Fan  <[email protected]>
+
+        [macOS] Ensure that WebGL contexts are always set to an accelerated virtual screen
+        https://bugs.webkit.org/show_bug.cgi?id=187923
+
+        Reviewed by Dean Jackson.
+
+        On eGPU displays, it is possible that CGL does not match the preferred renderer. 
+        In this case, and when the web process is blocked from accessing the window server, 
+        3D contexts *may* default to the software renderer. Ensure that even if this occurs,
+        we set the context to use a hardware-accelerated renderer/virtual screen.
+
+        No new tests. Existing behavior covered by existing tests.
+        Requires multiple screens, at least one attached to an eGPU, to stress. 
+
+        * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
+        (WebCore::identifyAndSetCurrentGPU):
+
 2018-07-23  Sam Weinig  <[email protected]>
 
         Convert some obvious never-null pointers to references in the editing code

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


--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm	2018-07-23 23:07:33 UTC (rev 234116)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm	2018-07-23 23:20:16 UTC (rev 234117)
@@ -175,6 +175,8 @@
     CGLError error = CGLDescribePixelFormat(pixelFormatObj, 0, kCGLPFAVirtualScreenCount, &virtualScreenCount);
     ASSERT(error == kCGLNoError);
 
+    GLint firstAcceleratedScreen = -1;
+
     for (GLint virtualScreen = 0; virtualScreen < virtualScreenCount; ++virtualScreen) {
         GLint rendererID = 0;
         error = CGLDescribePixelFormat(pixelFormatObj, virtualScreen, kCGLPFARendererID, &rendererID);
@@ -181,13 +183,29 @@
         ASSERT(error == kCGLNoError);
         if (error != kCGLNoError)
             continue;
+
         if (rendererID == preferredRendererID) {
             error = CGLSetVirtualScreen(contextObj, virtualScreen);
             ASSERT(error == kCGLNoError);
             LOG(WebGL, "Context (%p) set to GPU renderer (%d).", contextObj, rendererID);
-            break;
+            return;
         }
+
+        if (firstAcceleratedScreen < 0) {
+            GLint isAccelerated = 0;
+            error = CGLDescribePixelFormat(pixelFormatObj, virtualScreen, kCGLPFAAccelerated, &isAccelerated);
+            ASSERT(error == kCGLNoError);
+            if (isAccelerated)
+                firstAcceleratedScreen = virtualScreen;
+        }
     }
+
+    // No renderer match found; set to first hardware-accelerated virtual screen.
+    if (firstAcceleratedScreen >= 0) {
+        error = CGLSetVirtualScreen(contextObj, firstAcceleratedScreen);
+        ASSERT(error == kCGLNoError);
+        LOG(WebGL, "Renderer (%d) not matched; Context (%p) set to virtual screen (%d).", preferredRendererID, contextObj, firstAcceleratedScreen);
+    }
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to