Qt WebEngine 6.6甚至6.5中的新图形集成

New graphics integration in Qt WebEngine 6.6 and even 6.5

Qt WebEngine 6.6甚至6.5中的新图形集成

May 08, 2023 by Allan Sandfeld Jensen | Comments

​2023年5月8日 Allan Sandfeld Jensen | 评论

With the 6.5.1 release, there will be one new change our users might notice. Qt WebEngine has previously forced the Qt Quick SceneGraph to use the OpenGL backend on Windows and macOS, even though the Qt defaults were using D3D11 and Metal respectively. With Qt 6.5.1 Qt WebEngine will now run with the Metal and D3D11 default QSG backends.

随着6.5.1的发布,我们的用户可能会注意到一个新的变化。Qt WebEngine此前曾强制Qt Quick SceneGraph在Windows和macOS上使用OpenGL后端,尽管Qt默认值分别使用D3D11和Metal。有了Qt 6.5.1,Qt WebEngine现在将使用Metal和D3D11默认的QSG后端运行。

This has been a long time coming. Chrome has always preferred using ANGLE on Windows. Where Qt did offer ANGLE in Qt5 but defaulted to WGL (Windows OpenGL), since Qt6 the ANGLE backend has been removed from Qt Gui, and WebEngine required Chromium to run in WGL mode. This has caused many issues, due to buggy Windows OpenGL drivers, and due to not using the same backend as Chrome itself.

这已经持续了很长时间。Chrome一直倾向于在Windows上使用ANGLE。Qt在Qt5中确实提供了ANGLE,但默认为WGL(Windows OpenGL),由于Qt6,ANGLE后端已从Qt Gui中删除,WebEngine需要Chromium在WGL模式下运行。这导致了许多问题,原因是Windows OpenGL驱动程序有缺陷,以及没有使用与Chrome本身相同的后端。

In the last 6 months Chrome has switched to using ANGLE on all their desktop platforms, and also removed the integration code to native OpenGL on Linux/X11 (GLX) and macOS (CGL). On top of this Chrome has plans to move rendering from ANGLE (GL implementation) to Dawn (WebGPU implementation).

在过去的6个月里,Chrome在所有桌面平台上都改用ANGLE,并在Linux/X11(GLX)和macOS(CGL)上删除了与本地OpenGL的集成代码。除此之外,Chrome还计划将渲染从ANGLE(GL实现)转移到Dawn(WebGPU实现)。

Given the diverging differences in backends we can no longer expect Chromium and Qt to run on similar graphics backends, so we will need to bridge whatever Chromium is doing with whatever Qt is doing. The solution will be to render to native GPU memory buffers. On macOS using IOSurface, and on Windows using DXGI. We statically link Qt WebEngine Chromium with ANGLE. Let Chromium render however it wants to native backed buffers, and then pass these GPU memory buffers to the Qt Quick Scene graph in the native Qt RHI graphics modes (currently supporting Metal and D3D11).

考虑到后端的差异,我们不能再指望Chromium和Qt在类似的图形后端上运行,所以我们需要将Chromium正在做的任何事情与Qt正在做的事情桥接起来。解决方案将是渲染到本地GPU内存缓冲区。在使用IOSurface的macOS上,以及在使用DXGI的Windows上。我们将Qt WebEngine Chromium与ANGLE静态链接。让Chromium以其想要的方式渲染到本机支持的缓冲区,然后将这些GPU内存缓冲区传递到本机Qt RHI图形模式下的Qt快速场景图(目前支持Metal和D3D11)。

This should increase stability and performance for Windows and macOS users in 6.5.1, but if it unexpectedly causes any problems for anyone in 6.5.1, the old behaviour can be restored by setting QSG_RHI_BACKEND=opengl, or by calling QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL).

这应该会提高6.5.1中Windows和macOS用户的稳定性和性能,但如果它意外地给6.5.1中的任何人带来任何问题,可以通过设置QSG_RHI_BACKEND=opengl或调用QQuickWindow::setGraphicsApi(QSGRendererInterface::opengl)来恢复旧行为。

For Qt 6.6 this will go further and we will remove the old native OpenGL backends from our fork of Chromium. Chromium itself removed the code long ago, and it is getting increasingly difficult to maintain this old abandoned code. Instead we will import the native GPU memory buffers into OpenGL just like we do for Metal and D3D11. There are a few concerns however, such as the poor quality of WGL_NV_DX_interop2
implementations in Windows OpenGL drivers, and missing functionality in NVidia proprietary drivers on Linux to generate GBM buffers (GBM being the "native" graphics buffers of Linux). This means work is still ongoing for the transition in 6.6.

对于Qt 6.6,这将更进一步,我们将从Chromium的分叉中删除旧的原生OpenGL后端。Chromium本身很早以前就删除了代码,现在维护这个旧的废弃代码变得越来越困难。相反,我们将把原生GPU内存缓冲区导入OpenGL,就像我们对Metal和D3D11所做的那样。然而,也有一些问题,例如Windows OpenGL驱动程序中的WGL_NV_DX_interop2实现质量差,以及Linux上NVidia专有驱动程序中缺少生成GBM缓冲区的功能(GBM是Linux的“本机”图形缓冲区)。这意味着6.6中的过渡工作仍在进行中。

One other side effect of this work, was already shipped in 6.5.0. With the support for native GPU memory buffers, we can now also handle hardware video acceleration on Linux. Luckily even the NVidia drivers support importing GBM buffers for this purpose, even if the rest of the GBM extension is missing.

这项工作的另一个副作用已经在6.5.0中发布。有了对原生GPU内存缓冲区的支持,我们现在也可以在Linux上处理硬件视频加速。幸运的是,即使英伟达驱动程序也支持为此目的导入GBM缓冲区,即使缺少GBM扩展的其余部分。

你可能感兴趣的:(QtBlog,qt)