summaryrefslogtreecommitdiffstats
path: root/src/core/web_engine_context.cpp
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-09-21 12:54:13 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-11-12 14:57:58 +0000
commit396ca081d7b0d9dab7de14ebaec7943c3f857a24 (patch)
tree23183b1e96d18a2e8dfee0b1f46d7b146097cbd5 /src/core/web_engine_context.cpp
parent7ebbd9e39106b3dfbac9de8f3305a7ca8712474d (diff)
Fix GPU compositing (and WebGL) to work with ANGLE on Windows
Given the changes that implement GPU compositing on the UI thread (and thus only a single thread accesses all OpenGL contexts) it is now possible to enable GPU compositing to work together with ANGLE, which did not work before due to ANGLE being thread-unsafe. This requires a couple of things: - Enable GPU compositing via kInProcessGPU switch when using ANGLE - A small fix in GLContextHelper::getEGLDisplay() to return a correct "egldisplay "handle - Improved logic when to pass the kDisableES3GLContext switch depending on which OpenGL ES version is requested (2 or 3) - Adjustments in RenderWidgetHostViewQtDelegateWidget() to set up a correct surface format which matches the shared context OpenGL ES major version - A recent enough version of ANGLE (due to bugs calling glTexImage2D with an unsupported internal texture format for GL_DEPTH_COMPONENT, from inside gpu::gles2::IsWebGLDrawBuffersSupported) By default if no special QSurfaceFormat is set as the default surface format, using ANGLE will create an OpenGL ES 2 context, and will thus provide support only for WebGL 1. To enable OpenGL ES 3 / WebGL 2 support, make sure to set a default QSurfaceFormat with major version set to 3, and enable ANGLE either via QT_OPENGL=angle or QGuiApplication::setAttribute(Qt::AA_UseOpenGLES). The default surface format must be set before the Q*App instance is created. Manual test "webgl" added. Task-number: QTBUG-53908 Task-number: QTBUG-55604 Task-number: QTBUG-69236 Change-Id: Ic31dfdff1ca22d4689db5cf64126d7d12790aa76 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/core/web_engine_context.cpp')
-rw-r--r--src/core/web_engine_context.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index db74978d3..096568570 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -422,10 +422,23 @@ WebEngineContext::WebEngineContext()
// an OpenGL Core Profile context. If the switch is not set, it would always try to create a
// Core Profile context, even if Qt uses a legacy profile, which causes
// "Could not share GL contexts" warnings, because it's not possible to share between Core and
- // legacy profiles.
- // Given that Core profile is not currently supported on Windows anyway, pass this switch to
- // get rid of the warnings.
- parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
+ // legacy profiles. See GLContextWGL::Initialize().
+ // Given that Desktop GL Core profile is not currently supported on Windows anyway, pass this
+ // switch to get rid of the warnings.
+ //
+ // The switch is also used to determine which version of OpenGL ES to use (2 or 3) when using
+ // ANGLE.
+ // If the switch is not set, Chromium will always try to create an ES3 context, even if Qt uses
+ // an ES2 context, which causes resource sharing issues (black screen),
+ // see gpu::gles2::GenerateGLContextAttribs().
+ // Make sure to disable ES3 context creation when using ES2.
+ const bool isGLES2Context = qt_gl_global_share_context()
+ && qt_gl_global_share_context()->isOpenGLES()
+ && qt_gl_global_share_context()->format().majorVersion() == 2;
+ const bool isDesktopGLOrSoftware = !usingANGLE();
+
+ if (isDesktopGLOrSoftware || isGLES2Context)
+ parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
#endif
// Needed to allow navigations within pages that were set using setHtml(). One example is
// tst_QWebEnginePage::acceptNavigationRequest.
@@ -456,8 +469,7 @@ WebEngineContext::WebEngineContext()
#ifndef QT_NO_OPENGL
bool tryGL =
- !usingANGLE()
- && (!usingSoftwareDynamicGL()
+ (!usingSoftwareDynamicGL()
// If user requested WebGL support instead of using Skia rendering to
// bitmaps, use software rendering via software OpenGL. This might be less
// performant, but at least provides WebGL support.
@@ -467,10 +479,13 @@ WebEngineContext::WebEngineContext()
if (tryGL) {
if (qt_gl_global_share_context() && qt_gl_global_share_context()->isValid()) {
- // If the native handle is QEGLNativeContext try to use GL ES/2, if there is no native handle
- // assume we are using wayland and try GL ES/2, and finally Ozone demands GL ES/2 too.
+ // If the native handle is QEGLNativeContext try to use GL ES/2.
+ // If there is no native handle, assume we are using wayland and try GL ES/2.
+ // If we are using ANGLE on Windows, use OpenGL ES (2 or 3).
if (qt_gl_global_share_context()->nativeHandle().isNull()
- || !strcmp(qt_gl_global_share_context()->nativeHandle().typeName(), "QEGLNativeContext"))
+ || !strcmp(qt_gl_global_share_context()->nativeHandle().typeName(),
+ "QEGLNativeContext")
+ || usingANGLE())
{
if (qt_gl_global_share_context()->isOpenGLES()) {
glType = gl::kGLImplementationEGLName;