Bug 202834 - Implementation of powerPreference on WebGL's ANGLE/OpenGL backend is insufficient
Summary: Implementation of powerPreference on WebGL's ANGLE/OpenGL backend is insuffic...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: webglangle
  Show dependency treegraph
 
Reported: 2019-10-10 17:39 PDT by Kenneth Russell
Modified: 2022-07-01 13:19 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Russell 2019-10-10 17:39:52 PDT
The EGL_ANGLE_power_preference extension advertised by ANGLE, and used by the ANGLE backend for WebGL to implement the powerPreference attribute, has some deficiencies preventing it from working as desired.
https://chromium.googlesource.com/angle/angle/+/refs/heads/master/extensions/EGL_ANGLE_power_preference.txt

Basically:

1) ANGLE never calls CGLSetVirtualScreen against its internal CGLContextObj when either activating or deactivating the discrete GPU. This means that the "high-performance" power preference is effectively a no-op, even though the discrete GPU is actually being activated via the allocation of a CGLPixelFormatObj that doesn't support offline renderers.

2) If this started being called, multisampled renderbuffers would stop working which were allocated on the "other" GPU. This behavior was discovered in Chromium and has just been worked around in https://bugs.chromium.org/p/chromium/issues/detail?id=681341#c58 . The symptom is that content with antialias:true (the default) stops rendering.

In order to fix these issues, it appears the following changes are needed:

A) ANGLE's implementation of EGL_ANGLE_power_preference needs to be improved to actually call CGLSetVirtualScreen appropriately.
B) Some sort of callback notification about GPU switching needs to be dispatched out of ANGLE back to WebKit.
C) WebKit needs to respond to these notifications:
C1) For WebGL 1.0 contexts with preserveDrawingBuffer:false, or WebGL 2.0 contexts with preserveDrawingBuffer:false *and* no user-allocated multisampled renderbuffers, silently reallocate the multisampled renderbuffers associated with the antialiasing implementation.
C2) For any contexts with preserveDrawingBuffer:true, *or* WebGL 2.0 contexts in which the user has allocated a multisampled renderbuffer, force a context lost and context restored event pair.

Any feedback on whether this appears to be the correct approach is greatly appreciated.
Comment 1 Kenneth Russell 2021-07-26 13:55:46 PDT
Note: this applies only to ANGLE's OpenGL backend. Since Apple's probably not going to ship that, this may be able to be closed as WontFix.
Comment 2 Brent Fulgham 2022-07-01 13:19:45 PDT
I believe we only intend to support Metal for new features, so indeed marking as WONTFIX.